View Full Version : Terminal Mods
sAMANOSKe
01-27-2002, 01:55 PM
Is there a possibility to add commands to the Shell Login script !?
I discovered the true login script in /usr/share/init/tcsh/. When adding a simple date at the end of the script, the date is shown when a new Terminal is initiated, but only at 1 out of 5 attempts the shell is not "logging off" with a message like process complete.
Any suggestions !? Or other Mods for the Terminal ?
mervTormel
01-27-2002, 02:16 PM
sam...
please see the readme at /usr/share/init/tcsh/README
it instructs you how to create your home dir setup and how to modify the startup scripts with your own callouts in ~/Library/init/tcsh/
it's probably best to revert the scripts at /usr/share/init/tcsh/ to their original versions
sAMANOSKe
01-27-2002, 08:15 PM
outta the README:
rc.mine - run commands
that would implicate, that the RC script is (for global in the dir as listed about or as you mentioned in the home dir) responsible for run commands at login. When adding a date at the end of the RC (global one), the date should be a displayed at login. however shell is closing with the same error message as mentioned above after opening more shells with the apple+n hotkey. is it a bug ?! I am scared to close every shell and trying it out ...
mervTormel
01-27-2002, 08:52 PM
hmmm, i'm afraid i'm not following this very well.
how do you exit your shell?
have you modified your logout script?
a tip: if you're modifying your startup/logout scripts, it's a good idea to leave a parent terminal window open and test your scripts in new term windows. then when your login is broken, you can fix it up with yer parent window.
and test test test
rusto
01-27-2002, 11:20 PM
Heres HOW to get the date to show on opening of a new term window in tcsh AND (added bonus tutorial) how to modify your terminal prompt.
>> Be sure to follow ALL steps.
The place you want to add mods to the term in tcsh is a file called .tcshrc which should live in your home folder.
The "." at the beginning makes the file invisible to viewing with regular listing using the ls command. To see if you have .tcshrc already, enter ls -a, the -a will show all files in a directory, visible and invisible.
.tcshrc is not created in your home folder in an OS X install so you have to make one. You can do this using the simple command line editor called pico. We'll do both mods in this pico session:
1) First, make sure you are in your home folder, type:
cd ~
2) Type
pico .tcshrc
This will open a pico session. The cursor will be at the top awaiting your first typed entry. Note that at the bottom of the term window are listed some of the common pico commands. The ^ stands for the control key.
3) Type this:
date
and hit return to go to a new line. You could save .tcshrc and quit pico now but let's do one more mod while we are in here.
4) On the new line type (or cut/paste) this:
set prompt="[%n: %/] "
What this will do is take your standard terminal prompt in OS X from this:
[h000503cc0dd3:/Library/Screen Savers] rusto%
and make it look like this:
[rusto: /Library/Screen Savers]
A little easier on the eyes, yes?
5) OK, now we have to save and exit from pico, hold down the control key and type a letter "o". Then hit return. This will "write out" (save) your .tcshrc file.
6) Exit pico by holding down the control key and typing an "x".
7) Close the terminal window. Open a new one to see the results.
It should look something like this:
Sun Jan 27 23:15:15 EST 2002
[rusto: /Users/rusto]
----
If you are feeling more confident after that exercise and think you would like your terminal listings in color (see sample here (http://www.ResExcellence.com/hack_gifs_01/05-09-01.jpg)), go to this ResExcellence tutorial (http://www.ResExcellence.com/terminal/05-09-01.shtml) to learn how.
Check this site for termcaps modifications :
http://www.kung-foo.tv/termcap.html
and this one:
http://www.termsys.demon.co.uk/vtansi.htm
for ANSI/VT100 Terminal Control Escape Sequences
Cheers...
Rusto:
After installing, to add the XFree86 directory to our path, we create a path file in ~/Library/init/tsch
If you have fink installed and created a .cshrc file with "source /sw/bin/init.csh" and then you create a .tcshrc and write your tip, you will loose fink:
"sudo fink list: command not found"
Now, will the average unix newbie know how to properly merge the required changes into his .tcshrc ?
I read an interesting thread about this:
http://sourceforge.net/mailarchive/message.php?msg_id=242403
Please advice...thanks!
Cheers...
rusto
02-01-2002, 04:30 PM
Hmm, dunno...haven't found the need to install Xfree86 (and by extension fink)...yet.
Rusto,
I solved the problem with a tip from pmccann, I wrote "source ~/.cshrc" at the end of the ~/.tcshrc file.
Now, your tip works very well for me and fink is still working.
Cheers...
hschickel
02-08-2002, 09:41 AM
Interestingly, I had no problems setting the run commands in ~/Library/init/tcsh/rc.mine (as advised by the readme /usr/share/init/tcsh/README). I wonder if the folks having problems with this have not modified something in /usr/share/init/tcsh that would screw things up?
Hugh
hschickel
02-08-2002, 11:14 AM
I just installed fink.
By adding source /sw/bin/init.csh to the ~/Library/init/tcsh/login.mine file (create it if necessary) I was able to eliminate the problematic and possibly unsupported .cshrc file. This is also spelled out in /usr/share/init/tcsh/README.
Based on this readme, these files should also take the place of .tcshrc files - if I'm reading it correctly.
Hugh
hschickel
02-08-2002, 11:35 AM
From the readme:
Welcome to Darwin!
Fri Feb 8 11:22:27 EST 2002
[localhost:~] hs2admin% cd /usr/share/init/tcsh
[localhost:share/init/tcsh] hs2admin% more readme
This directory contains some useful tcsh files.
In order to use this configuration:
echo "source /usr/share/init/tcsh/rc" > ~/.tcshrc
echo "source /usr/share/init/tcsh/login" > ~/.login
echo "source /usr/share/init/tcsh/logout" > ~/.logout
To do this system-wide, do the same instead to /etc/csh.cshrc, /etc/csh.login, a
nd /etc/csh.logout.
In order to customize tcsh:
mkdir ~/Library/init/tcsh
and create the following files there as necessary:
aliases.mine - shell aliases
completions.mine - completions
environment.mine - environment
rc.mine - run commands
path - command search path
See the corresponding file in /usr/share/init/tcsh for more information about th
e role of each file. You can easily extend or override the configuration provide
d by the default file. For example, you can add more aliases by adding the appro
priate commands in aliases.mine.
-Fred
Massachusetts Institute of Technology
tritan@mit.edu
[localhost:share/init/tcsh] hs2admin%
Please note that you can ignore the first part of this readme In order to use this configuration:
echo "source /usr/share/init/tcsh/rc" > ~/.tcshrc
echo "source /usr/share/init/tcsh/login" > ~/.login
echo "source /usr/share/init/tcsh/logout" > ~/.logout
To do this system-wide, do the same instead to /etc/csh.cshrc, /etc/csh.login, a
nd /etc/csh.logout.
as its already done system wide via the /etc/csh.cshrc, /etc/csh.login and /etc/csh.logout files. The important part is the creation of the ~/Library/init/tcsh directory and the files within.
**This readme seems to imply that creating a standalone ~/.tcshrc or ~/.cshrc file can lead to problems. The issues noted above and via the sourceforge mailing list article referenced above bear this out.
Hugh
Hi hschickel,
you wrote:
<<**This readme seems to imply that creating a standalone ~/.tcshrc or ~ /.cshrc file can lead to problems. The issues noted above and via the sourceforge mailing list article referenced above bear this out. >>
You are right, we can avoid all problems if we put the files in ~/Library/init/ tcsh directory.
The problem for newbies is that the fink installation explained at their web page tells you to create:
http://fink.sourceforge.net/doc/bundled/install-fast.php#install
----------------------
<<Run 'source /sw/bin/init.csh ; rehash' to set up this Terminal's environment
to use Fink. To make the software installed by Fink available in all of your shells, add 'source /sw/bin/init.csh' to the init script '.cshrc' in your home directory. Enjoy.
[frodo:~/fink-0.3.2a-full] testuser% cd
[frodo:~] testuser% rm -r fink-0.3.2a-full
[frodo:~] testuser% pico .cshrc
The last command launches you into a text file editor. Type source /sw/bin/init.csh, press return, press control-O, press return, press control-X.>>
---------------------
and also at :
http://fink.sourceforge.net/doc/users-guide/install.php#setup
---------------------
2.3 Setting Up Your Environment
To use the software installed in Fink's directory hierarchy, including the package management programs themselves, you must set your PATH environment variable (and some others) accordingly. Shell scripts are provided to make this easy. If you use tcsh (the default on Mac OS X), add the following line to the file .cshrc in your home directory:
source /sw/bin/init.csh
If you don't know how to add the line, run these commands:
cd
pico .cshrc
You're not in a full-screen (well, full terminal window) text editor and can simply start typing the source /sw/bin/init.csh line. It's okay if there is a note that says "New file". Be sure that you pressed Return at least once after the line, then press Control-O, Return, Control-X to get out of the editor
---------------------
That is the subject discussed at the sourceforge mailing list article referenced above and at the end of the thread the conclusion with:
---------------------
>So, the question is, should the Guide be re-written to have tcsh|csh
>users add the "source ..." line to ~/Library/init/tcsh/login.mine?
Maybe. I lack time for this ATM, but if you (or anybody else) wants
to tackle a rewrite, feel free to do so and submit your changes to
the mailing list for discussion, then we can add it to the web.
Max>>
OK,
Ken
----------------------
Cheers...
You can put colors to Rusto's great prompt tip quite easily:
Rusto's prompt:
set prompt="[%n: %/] "
Now, my prompt looks like this:
set prompt="[%{\033[32m%}%n%{\033[0m%}:%{\033[36m%}%/%{\033[0m%}]"
32m (green) and 36m (cyan) (you can choose your colors from the chart below)
which gives me:
[pm(in green):/Users/pm(cyan)]
The color codes you can use with this ANSI command are the following:
0 Reset colors to 37;40
1 Bold text. In reality, it's not really bold, text is only brighter.
5 Blinking text. Many terminal apps don't support this
7 Reverse video, inverts the background and the foreground colors
30 Black
31 Red
32 Green
33 Yellow
34 Blue
35 Magenta
36 Cyan
37 White
40 Black background
41 Red background
42 Green background
43 Yellow background
44 Blue background
45 Magenta background
46 Cyan background
47 White background
Tip learned at:
http://www.kung-foo.tv/xtips.shtml
Cheers...
Just a short note to inform I have implemented rusto's tip (with the modifications of my previous post) in the .cshrc file.
I have erased the .tcshrc file to simplify things.
I learned this at the following thread :
http://forums.macosxhints.com/showthread.php?s=&threadid=792&perpage=20&pagenumber=2
Cheers...
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.