1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
2 "http://www.w3.org/TR/html4/strict.dtd">
5 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
6 <meta name="GENERATOR" content="Mozilla/4.61 [en] (Win98; U) [Netscape]">
8 <title>ClearSCM: Environment</title>
10 <link rel="stylesheet" type="text/css" media="screen" href="/css/Article.css">
11 <link rel="stylesheet" type="text/css" media="screen" href="/css/Code.css">
12 <link rel="stylesheet" type="text/css" media="print" href="/css/Print.css">
13 <link rel="SHORTCUT ICON" href="http://clearscm.com/favicon.ico" type="image/png">
16 <script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
18 <script type="text/javascript">
19 _uacct = "UA-89317-1";
25 include "clearscm.php";
37 <h2>Your Environment Can Make or Break You</h2>
39 <p>It's often no wonder that mere morals shudder at the site of a
40 command prompt and scream bloody murder when asked to drop into the
41 command line. It's a baren and unfamilar place for most people filled
42 with all the potential pitfalls of actually getting work done! But it
43 doesn't have to be that way.</p>
45 <p>Indeed the basic shell presented by Unix, and Windows for that
46 matter, is pretty bleak, harsh and forboding configured with default
47 settings. But shells and shell languages are wonderfully configureable
48 and customizable as well as extremely powerful. Often error messages
49 come out in command line executions that are never caught by the GUIs
50 and displayed. And you can often get and manipulate a lot of
51 information given the rich set of commands and piping techniques
52 afforded by most modern shells. Nevermind you can easily set up quick
53 loops to itterate through the information in ways that will quite
54 frankly dazzle your friends... well your geek friends at least.</p>
56 <p>All that said this document is to describe a set of start up
57 scripts that I've developed over the years that I find extremely
58 useful. The environment is easily installable yet quite sophisticated
61 <blockquote><b>Note:</b> For Windows I use Cygwin as it provides a
62 full, Linux like environment such that most stuff runs the same on
63 Unix, FreeBSD, Solaris, Linux and Windows without change. There are
64 additional <a href="#Cygwin Tweaks">Cygwin Tweaks</a> to be described
65 later that make the Windows environment further normalized and make
66 productived.</blockquote>
70 <p>For quite some time now I have packaged up my stuff to reside under
71 ~/.rc. This allows me to easily grep for the occurances of things in
72 one convienent place. I've even places my XEmacs customizations under
73 ~/.rc too. All of this is in CVS on my corporate site and I keep
74 things up to date and documented there. You can obtain the package as
75 a tarball <a href="/clearenv.tar.gz">clearenv.tar.gz</a>. Unpack the
76 tar image and simply run ~/.rc/setup_rc:</p>
78 <div class="code">$ cd ~
86 <p>Full version history can be viewed <a
87 href="/gitweb/?p=.git;a=tree;f=rc">here</a>.</p>
89 <p>I now have separated out client customizations, i.e. startup
90 functionality particular to different clients or employers, into the
91 ~/.rc/client_scripts directory. The start up scripts will source all
92 executable scripts under that directory.</p>
94 <p>A set of Clearcase functions exist under ~/.rc/clearcase and a set
95 of Multisite scripts under ~/.rc/multisite. By and large these serve
96 to set up the Clearcase environment and mostly change common Clearcase
97 commands from cleartool lsview to simply lsview. Where appropriate
98 additional functionality has been added such as lsview <part of
99 view name> which effectively does a cleartool lsview piped to grep
100 to find views with <part of view name> in their names. An lsview
101 by itself will do cleartool lsview piped to your $PAGER and lsviews
102 will generate a list of views useful in constructs such as:</p>
104 <div class="code">$ for view in $(lsviews); do
105 > echo "Processing view $view"
106 > # Do some thing with $view
110 <p>Other functions are provided like cm (an alias for cleartool -
111 stands for configuration management), cdiff (do a clearcase diff),
112 clist (list all checkouts), etc. Note this has been named cm because
113 I'm starting to integrate other CM systems such as CVS. So a cdiff
114 does a cleartool diff if we are on a machine that has Clearcase
115 whereas if we are in a diretory that has a CVS directory a cvs diff
116 will be done instead. Similarly clist works for both CM systems
117 too. Further development of this is ongoing.</p>
119 <p>Finally there are some environment variables that are available for
120 handy reference such as $RGY which points to where the Clearcase
121 registry files are, etc.</p>
125 <p>Most shell functions are defined in ~/.rc/functions. Most of these
126 functions deal with setting it up such that the title bar of the
127 terminal contains an indication of whether or not you are in a view or
128 a cvs work area, what portion of the vob or directory you are
129 currently in and whether or not you are root (called Wizard). These
130 functions seek to maintain the proper titlebar such that if you say
131 ssh'ed to another machine the titlebar would change - if you exit that
132 ssh session the titlebar should change back.</p>
134 <p>Another handy function is sj - stands for Show Job. It's basically
135 a ps -ef | grep -i <str&gr;. How many times to do you that? Why not
136 make it shorter? There is also user and group functions which
137 essentially do ypcat [passwd|group] | grep -i <str>. This allows
138 you to easily search the passwd and group NIS maps (Note I have not
139 implemented this for Windows yet but the thought would be to make it
140 function the same).</p>
144 <p>This whole start up environment is oriented for the bash(1)
145 shell. It used to be ksh(1) but I've moved on to bash. As such the
146 ~/.rc/base_login is where most stuff gets sourced and set up. It also
147 mitigates some of the differences between the various supported OSes
148 as well as sets up aliases, etc.</p>
152 <p>This script sets up the PATH from scratch. The idea was if your
153 PATH ever gets hosed you can get it all back with
154 ~/.rc/set_path. There is a list of paths to places where applications
155 may or may not exist. These are fed into a function that appends to
156 the PATH variable but only if the directory actually exists. So while
157 you might see /usr/local/mysql/bin but not have mysql installed, the
158 append_to_path function will recognize that /usr/local/mysql/bin does
159 not exist and not append it to the path.</p>
161 <a name="Cygwin Tweaks"></a><h3>Cygwin Tweaks</h3>
163 <p>In order to help out the start up scripts I mount the Clearcase
164 view drive (by default M) to /view. Now /view/<viewname> is the
165 same between Unix and Cygwin. Also I mount C:\Program Files ->
166 /apps. Just makes more sense and is easier to type.</p>
168 <h2>Clearcase Functions</h2>
170 <h3>General function - scm = cleartool</h3>
172 <p>The scm function calls cleartool (and possibly cvs). It also gets
173 rid of the problem with Clearcase under Windows sending extra carriage
174 returns. If you wish to do a Clearcase cleartool command and it is not
175 short circuted then you can use scm instead. Short circuted commands
176 are basically cleartool command that you don't need to even specify scm
177 for. Examples include lsview, lsstream, pwv, etc.</p>
179 <p><b>Note:</b> The ct command has been aliased to the scm command.</p>
181 <p>Clearcase commands, using either the scm function of the familiar scm
182 function, also provide full command line completion! This means that if
183 you do scm lsview ad and then type tab, bash will complete your ad string
184 to expand to all of the views that start with the letters "ad". In other
185 words, bash completion for Clearcase commands means that hitting tab
186 in scm commands will complete the command line much like file name
187 completion currently works in bash, except it's smart in that if the
188 context of the scm command calls for a view name here then bash
189 completes view names. If the context of a scm command calls for a vob name
190 then completion will complete vob names, or baselines or labels, etc.
191 Even options are completed (type scm lsview - then tab) or even command
192 names themselves (type scm <space> then tab twice and you'll be
193 given a list of all Clearcase commands!</p>
197 <p>The ci short circut stands for check in. This will use your
198 ~/.clearcase_profile to specify the -nc if that is your default. So
199 then the common action of check in goes from cleartool checkin ->
204 <p>Same as ci but stands for checkout.</p>
212 <p>This is the regular setview command for Unix. Setview is not
213 supported under Windows but we fake it by doing a startview then
214 mounting /view/<viewname> to /vobs and start a new bash
215 shell. We are attempting to emulate the setview of Unix but we can't
216 fully because in Unix you are chrooted and /view is what is called a
217 <i>super root</i>. when we exit the setview under Windows we then
218 umount /vobs. The problem here is that we can only have one view set
219 on the system because the /vobs mount point contains that view's
220 name. So if terminal 1 setview view1 and terminal 2 setview view2,
221 terminal 1 would see things as of the last mount of /vob which is
222 view2. Further if either terminal exists the mount is unmounted and
223 the other terminal now has no current working directory. This is a
224 known bug and... I'm working on it!</p>
228 <p>Stgarts a view then cd's the /view/<viewname></p>
232 <p>Does cm endview</p>
236 <p>Does endview with -server</p>
240 <p>Short circut of cm mkview</p>
242 <h3>makeview (experimental)</h3>
244 <p>Attempts to create or reuse a view. It takes one parameter - the
245 stream. The stream you say? Yes! This is UCM. It takes the stream name
246 and attempts create a view on that stream. First it checks to see if
247 that view has already been made and if so it does a setview. If not it
248 attempts to make the view. If it's unsuccessful it tries to do an
249 lsstream by first lopping off a few characters of the stream name and
250 searching for that hoping that the stream name you provided was
253 <p><b>Note:</b> The view tag composed will be ${USER}_$STREAM.</p>
257 <p>Short circut for cm rmview</p>
261 <p>Lists views. If no parameters are given then it does an cm lsview
262 -short | $PAGER. This lists all viewnames and pages it. If you give it
263 one parameter then it pipes the output to grep, grepping for that
264 string case insensitive. If you give it more parameters it just short
265 circuts to cm lsview <parms>.</p>
269 <p>Lists views that have $USER in them assuming they are UCM oriented
270 and getting the headline of UCM activity set in the view, if any. Note
271 that this is a little slow to talk to UCM to get the headlines. If you
272 just want to see what views are yours (i.e. have your userid in their
273 names) then do lsview $USER.</p>
277 <p>One of the "ll" commands. When you see ll think "list long". This
278 does a cm lsview -l.</p>
282 <p>Easy way to get a list of all views (remember lsview by itself will
283 use $PAGER). Useful for loops.</p>
287 <p>Short circut for cm lsvob. Functions like lsview (pages, searches, etc).
291 <p>Long vob listing</p>
295 <p>Short circut for cm setsc</p>
299 <p>Short circut for cm edsc</p>
303 <p>Short circut for cm catsc</p>
307 <p>Prints the current view (-short)</p>
311 <p>Short circut for cm rmtag</p>
315 <p>Short circut for cm mktag</p>
319 <p>Short circut for cm describe</p>
323 <p>Display version tree (cm lsvtree -g)</p>
327 <p>Short circut for cm merge</p>
331 <p>Performs graphical diff for Clearcase or with two non-Clearcase
332 files or does a cvs diff if in CVS mode.</p>
336 <p>Short circut of cm space</p>
340 <p>Short circut of cm register</p>
344 <p>Short circut of cm unregister</p>
348 <p>Short circut of cm hostinfo</p>
352 <p>Lists the trigger type if two parms are given (trtype and pvob)
353 otherwise alias for cm lstype -kind trtype | $PAGER.</p>
357 <p>Lists long the trigger type if two parms are given (trtype and pvob)
358 otherwise alias for cm lstype -long -kind trtype | $PAGER.</p>
362 <p>Lists lbtype's</p>
366 <p>Lists all streams to $PAGER to alias for cm lsstream if parameters
371 <p>Lists long all streams to $PAGER to alias for cm lsstream -lif
372 parameters are specified.</p>
376 <p>Short circut for cm rebase.</p>
380 <p>Short circut for cm deliver.</p>
384 <p>Short circut for cm lsbl.</p>
388 <p>Lists all projects to your $PAGER or alias for cm lsproject.</p>
392 <p>Lists long all projects to your $PAGER or alias for cm lsproject -long.</p>
396 <p>Lists all stglocs to your $PAGER or alias for cm lsstgloc.</p>
400 <p>Lists long all stglocs to your $PAGER or alias for cm lsstgloc -long.</p>
404 <p>Lists all streams to your $PAGER or alias for cm lsstream.</p>
408 <p>Lists long all streams to your $PAGER or alias for cm lsstream -long.</p>
412 <p>Lists all activities to your $PAGER or alias for cm lsactivity.</p>
416 <p>Lists long all activities to your $PAGER or alias for cm lsactivity -long.</p>
420 <p>Short circut for cm setactivity</p>
424 <p>Lists all currently checked out elements or locally modified cvs entries.</p>
428 <p>Check in all checked out work.</p>
429 </div> <!-- content -->
431 <?php copyright ();?>
434 <script language="JavaScript" src="/JavaScript/Menus.js" type="text/javascript"></script>