|
|
Very good tip for terminal.
|
|
|
|
Junior Member
Join Date: Jan 2002
Status:
Offline
|
|
Try this.
At terminal prompt,
vi .cshrc
type SHIFT g and return
type O
type alias cd 'cd \!*; echo -n "^[]0;`pwd`^G"'
type ESC
type SHIFT zz
shift and esc - press correct keyboard
to type ^[
CTRL-v and ESC
to type ^G
CTRL-v and CTRL-G
Quit terminal and relaunch~
You can see the title window is dynamically changes when you change your working directory.
Sorry for confusion. To make this easy, I made a small script.
download 'termtip' from
homepage.mac.com/wujekim
% chmod +x termtip
% ./termtip
% source ~/.cshrc
You can remove 'termtip' file now. Don't run termtip twice.
Power of Unix
[ 01-28-2002: Message edited by: netgo ]
[ 01-28-2002: Message edited by: netgo ]
[ 01-28-2002: Message edited by: netgo ]
|
Apple G4 Cube 450/1.5GB(3 133Mhz 512MB Dimm)/CDRW/WD 7200RPM 120GB/GeForce3/Fan/Apple 17" LCD/SoundStick/HP G85
External WD 7200RPM 120GB firewire
Logitech Wireless keyboard and mouse
iMic, Palm usb-serial, a Router, powered usb hub
|
|
|
|
|
|
|
|
Professional Poster
Join Date: May 2001
Location: Hampton Roads, VA
Status:
Offline
|
|
Originally posted by netgo:
<STRONG>Try this.
At terminal prompt,
vi .cshrc
type SHIFT g and return
type O
type alias cd 'cd \!; echo -n "^[]0;`pwd`^G"'
type ESC
type SHIFT zz
shift and esc - press correct keyboard
to type ^[
CTRL-v and ESC
to type ^G
CTRL-v and CTRL-G
Quit terminal and relaunch~
You can see the title window is dynamically changes when you change your working directory.
Power of Unix
[ 01-28-2002: Message edited by: netgo ]</STRONG>
Maybe if you explained what this did I would try it. However, for all I know this could be one long "rm -rf /"
So what does it do?
|
All glory to the hypnotoad.
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: May 2001
Location: Copping a feel on Endor
Status:
Offline
|
|
Originally posted by jokell82:
<STRONG>
Maybe if you explained what this did I would try it. However, for all I know this could be one long "rm -rf /"
So what does it do?</STRONG>
"You can see the title window is dynamically changes when you change your working directory."
|
"I thought they smelt bad on the outside."
|
|
|
|
|
|
|
|
Banned
Join Date: Sep 2000
Location: Fightclub
Status:
Offline
|
|
Don't see why or how this could work.
In fact, it doesn't.
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: May 2001
Location: Hampton Roads, VA
Status:
Offline
|
|
Originally posted by Han's Hands on Leia:
<STRONG>
"You can see the title window is dynamically changes when you change your working directory."</STRONG>
Maybe I just wanted it in english.
|
All glory to the hypnotoad.
|
|
|
|
|
|
|
|
Clinically Insane
Join Date: Nov 1999
Location: 888500128, C3, 2nd soft.
Status:
Offline
|
|
Originally posted by Han's Hands on Leia:
<STRONG>"You can see the title window is dynamically changes when you change your working directory."</STRONG>
How's that for the Gratuitous Stupid Post of the Day Award?
Thank you for enlightenment. Next time, don't think with your hands.
Now, can somebody perhaps explain what those commands actually do, step by step? Thank you.
-chris.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Dec 2001
Location: Toronto, ON
Status:
Offline
|
|
Originally posted by Spheric Harlot:
<STRONG>
How's that for the Gratuitous Stupid Post of the Day Award?
Thank you for enlightenment. Next time, don't think with your hands.
-chris.</STRONG>
I guess you don't get it. Oh well.
|
Iguana: The other green meat.
|
|
|
|
|
|
|
|
Senior User
Join Date: Jul 2000
Status:
Offline
|
|
Alrighty, well, after looking at this, there are some problems with the initial post.
I got it to work, and this is what I did:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
% cd ~
% vi .cshrc
<command>SHIFT-o</command>
alias cd 'cd \!*; echo -n <font color = red>"^[]<font color = blue>0</font>`pwd`^G"</font>'
cd ~
<command>ESC</command>
<command>SHIFT-zz</command>
</font>[/code]
Where I've deliniated the areas with the 'command' tag, simple type these commands in with no returns after completion; obviously do not type the <command> stuff.
As originally stated:
To get the '^[' sequence, type: CONTROL-v ESC
To get the '^G' sequence, type: CONTROL-v CONTROL-g
Now, for a better description of what this does: When you have a terminal window open, this will put the path of the current directory in the title bar of the window. This way, if you have multiple terminal windows open, then you can tell which one is in which directory without having to 'remember'.
For those that care, this is what I changed from the original post: First, I have the user do a 'cd ~'. This ensures that the user is in their root directory, which is where the .cshrc file needs to be for this to work. Then, I added the '*' to the aliased cd command. The '*' is required and this is what 'copies' the arguments from the as-typed 'cd' command to the new aliased 'cd' command. I also added a 'cd ~' at the end of the .cshrc file. This makes sure that the user is in their home directory when a new terminal is open and it also makes sure that the directory is prepended to the Terminal Window's title.
[ 01-28-2002: Message edited by: cwasko ]
|
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Jan 2001
Status:
Offline
|
|
Originally posted by jokell82:
<STRONG>
Maybe if you explained what this did I would try it. However, for all I know this could be one long "rm -rf /"
So what does it do?</STRONG>
Well, just by looking at it, you have a keyboard virus. Email me and I'll arrange for you to have your machine sent to my home to be disinfected. Don't worry, it happens to all users once in a while. OK?
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Oct 2001
Location: East Coast, U.S.
Status:
Offline
|
|
Originally posted by cwasko:
<STRONG>Alrighty, well, after looking at this, there are some problems with the initial post.
I got it to work, and this is what I did:
For those that care, this is what I changed from the original post: First, I have the user do a 'cd ~'. This ensures that the user is in their root directory, which is where the .cshrc file needs to be for this to work. Then, I added the '*' to the aliased cd command. The '*' is required and this is what 'copies' the arguments from the as-typed 'cd' command to the new aliased 'cd' command. I also added a 'cd ~' at the end of the .cshrc file. This makes sure that the user is in their home directory when a new terminal is open and it also makes sure that the directory is prepended to the Terminal Window's title.
[ 01-28-2002: Message edited by: cwasko ]</STRONG>
What passes arguments in Bash? This works for me in cshrc, but in bash I get
<font face = "courier"> bash: cd: 1*: no such file or directory </font>
[ 01-28-2002: Message edited by: Adam Price ]
[ 01-28-2002: Message edited by: Adam Price ]
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Jul 2000
Status:
Offline
|
|
Originally posted by Adam Price:
<STRONG>
What passes arguments in Bash?
</STRONG>
Well, eventhough it may seem like I know something, I figured it out through trial and error. I did look up a few things to figure out that the '*' was required for csh. You could try just deleting the '*' for Bash.
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2002
Status:
Offline
|
|
Thank cwasko.
You can change pwd to proper unix command to change the window title.
Actually this tip is Xterminal escape sequence and works well in Aqua.
|
Apple G4 Cube 450/1.5GB(3 133Mhz 512MB Dimm)/CDRW/WD 7200RPM 120GB/GeForce3/Fan/Apple 17" LCD/SoundStick/HP G85
External WD 7200RPM 120GB firewire
Logitech Wireless keyboard and mouse
iMic, Palm usb-serial, a Router, powered usb hub
|
|
|
|
|
|
|
|
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
Is this supposed to work for tcsh as well as csh? I assumed it would but I can't get it working. I know how to edit my .cshrc file so that's not the problem. I get a weird looking prompt (only because echo isn't printing a newline). Here is what comes before my regular prompt:
<font face = "courier">^[]0;/Applications^G</font>
The only thing I can assume is that it won't work for tcsh. I used the exact command cwasko posted.
[edit: I just tried it with csh instead of tcsh. Same problem. Doesn't work.]
[ 01-28-2002: Message edited by: Xeo ]
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2002
Status:
Offline
|
|
xeo, it should work in both csh and tcsh environment. Please make sure that you correct escape sequence. ctrl-v ctrl-esc and ctrl-v ctrl-g
Don't copy and paste. You will lose control character info.
|
Apple G4 Cube 450/1.5GB(3 133Mhz 512MB Dimm)/CDRW/WD 7200RPM 120GB/GeForce3/Fan/Apple 17" LCD/SoundStick/HP G85
External WD 7200RPM 120GB firewire
Logitech Wireless keyboard and mouse
iMic, Palm usb-serial, a Router, powered usb hub
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2002
Status:
Offline
|
|
Sorry for confusion. To make this easy, I made a small script.
download 'termtip' from
homepage.mac.com/wujekim
% chmod +x termtip
% ./termtip
% source ~/.cshrc
You can remove 'termtip' file now. Don't run termtip twice.
[ 01-28-2002: Message edited by: netgo ]
|
Apple G4 Cube 450/1.5GB(3 133Mhz 512MB Dimm)/CDRW/WD 7200RPM 120GB/GeForce3/Fan/Apple 17" LCD/SoundStick/HP G85
External WD 7200RPM 120GB firewire
Logitech Wireless keyboard and mouse
iMic, Palm usb-serial, a Router, powered usb hub
|
|
|
|
|
|
|
|
Dedicated MacNNer
Join Date: Oct 2001
Location: Philly
Status:
Offline
|
|
A alternative to this, for tcsh users, is to add the following line to your .tcshrc file:
set prompt = "%n@%m %~>"
You'll get a prompt that looks like:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier> username@hostname /current/working/directory/using/tilde/for/home> </font>[/code]
it's nifty. Man tcsh (or whatever shell you prefer) for many more variations on this...
|
|
|
|
|
|
|
|
|
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
Ahh, I see. I copied and pasted. I didn't realize I needed specific keyboard input like that. Anyway it still didn't work for me. I only tried once so it was probably a mistype again. However, I downloaded that shell script and now it works.
There is a bug in the shell script though. It doesn't exactly copy the <font face = "courier">`pwd`</font> into the .cshrc file. Since it's a shell script, it first executed that as a command and included the result. Every window had the path to my home directory in it. I manually edited my .cshrc file to include <font face = "courier">`pwd`</font> in place of that path and now it works.
You should fix that shell script though.
|
|
|
|
|
|
|
|
|
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
Originally posted by rantweasel:
<STRONG>it's nifty. Man tcsh (or whatever shell you prefer) for many more variations on this...</STRONG>
I have a custom prompt too. I like having only what I need as a prompt. I recommend using ManOpen or manThor or something like that to view the man pages on tcsh and other shells. They are very long and trying to view them in the terminal can be difficult. You can search for "prompt" with those GUI apps too and get you right where you want to be.
[ 01-28-2002: Message edited by: Xeo ]
|
|
|
|
|
|
|
|
|
Professional Poster
Join Date: Jul 2001
Location: Dis
Status:
Offline
|
|
When will thou blasphemous vi users realize that The One True Editor is emacs! Seriously, I never use vi, I use either emacs or TextEdit, and I may consider using pico, but vi has always felt so kludgy. Please change the instructions to the following:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>cd ~/
open .tcshrc</font>[/code]
then add the following text to the file:
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>Insert Text Here</font>[/code]
so that it is more generally understandable.
Thanx
BlackGriffen
[ 01-28-2002: Message edited by: BlackGriffen ]
|
I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use. -Galileo Galilei, physicist and astronomer (1564-1642)
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: Sep 1999
Location: Boston, MA USA
Status:
Offline
|
|
Originally posted by BlackGriffen:
<STRONG>When will thou blasphemous vi users realize that The One True Editor is emacs! </STRONG>
vi is too little, emacs is too much. Pico is juuust right!
And for a change of pace, I put
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
alias bbedit 'open -a /applications/BBEdit/BBedit'
</font>[/code]
in my aliases.mine file and open files in bbedit from the command line. It roxxors.
I like the idea of having the path in the title. Having a prompt that long is kind of a bother for me.
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2002
Status:
Offline
|
|
Oops, updated script
|
Apple G4 Cube 450/1.5GB(3 133Mhz 512MB Dimm)/CDRW/WD 7200RPM 120GB/GeForce3/Fan/Apple 17" LCD/SoundStick/HP G85
External WD 7200RPM 120GB firewire
Logitech Wireless keyboard and mouse
iMic, Palm usb-serial, a Router, powered usb hub
|
|
|
|
|
|
|
|
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
Originally posted by dogzilla:
<STRONG>And for a change of pace, I put
<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>alias bbedit 'open -a /applications/BBEdit/BBedit' </font>[/code]
in my aliases.mine file and open files in bbedit from the command line. It roxxors.</STRONG>
You know with BBEdit 6.5 there is the <font face = "courier">bbedit</font> command line tool.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Nov 2001
Location: State of Denial
Status:
Offline
|
|
Yep, and it works much better than using the above alias...
|
[Wevah setPostCount:[Wevah postCount] + 1];
|
|
|
|
|
|
|
|
Grizzled Veteran
Join Date: May 2000
Location: ON, Canada
Status:
Offline
|
|
I find my prompt nice and elegant this way:
set prompt="[%c3]"
Darcy
|
Macbook (white glossy) 2.16GHz | 4GB RAM | 7200RPM HD | 10.5.x
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2002
Status:
Offline
|
|
Here is my prompt
set prompt = "\! `whoami`@`hostname` : "
|
Apple G4 Cube 450/1.5GB(3 133Mhz 512MB Dimm)/CDRW/WD 7200RPM 120GB/GeForce3/Fan/Apple 17" LCD/SoundStick/HP G85
External WD 7200RPM 120GB firewire
Logitech Wireless keyboard and mouse
iMic, Palm usb-serial, a Router, powered usb hub
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Oct 2001
Location: Seattle
Status:
Offline
|
|
Originally posted by darcybaston:
<STRONG>I find my prompt nice and elegant this way:
set prompt="[%c3]"
Darcy</STRONG>
I'm not very good at terminal command stuff. But I like the simplicity of this. I also like the permanence of the .cshrc file. What would I have to type in the ..cshrc file to get the above prompt permanently?
Thanks!
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Bristol, UK, living in Melbourne, Australia
Status:
Offline
|
|
Originally posted by wil:
<STRONG>
I'm not very good at terminal command stuff. But I like the simplicity of this. I also like the permanence of the .cshrc file. What would I have to type in the ..cshrc file to get the above prompt permanently?
Thanks!</STRONG>
exactly that:
set prompt = "whatever you like"
it's your .cshrc file yeah, not ..cshrc file. That was probably just a typo I know but just in case...
|
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Oct 2001
Location: Seattle
Status:
Offline
|
|
Originally posted by tinrib:
<STRONG>
exactly that:
set prompt = "whatever you like"
it's your .cshrc file yeah, not ..cshrc file. That was probably just a typo I know but just in case...</STRONG>
Awesome! I didn't realize that the .cshrc file was always automatically read to the terminal. Does that mean I could instruct it to open a telnet prompt or something like that?
I just tried it and it works! I guess what I'm asking is: Does each line in the .cshrc file represent a terminal command/script? And if so, how do you put pauses in? Also, can you specify that only the first terminal window you open runs a particular script?
Thanks again. This is like candy!
[ 02-01-2002: Message edited by: wil ]
[ 02-01-2002: Message edited by: wil ]
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: May 1999
Location: San Jose, CA
Status:
Offline
|
|
Originally posted by wil:
<STRONG>Does that mean I could instruct it to open a telnet prompt or something like that?
Does each line in the .cshrc file represent a terminal command/script? And if so, how do you put pauses in? Also, can you specify that only the first terminal window you open runs a particular script?
</STRONG>
The lines in the .cshrc file are the exact same format as you'd type them on the command line if you were doing it manually.
All the commands are automatically run whenever a new terminal is opened. This means you COULD set a command to telnet to some other machine, but you'd telnet to that machine EVERY TIME you opened a new terminal - probably not what you want.
You can't add pauses because if you did you'd have to wait for the entire .cshrc file to finish before you got your prompt. This means if you have a 1 minute pause in your script, you'd be waiting at least one minute before you were able to do anything on the command line, each time you opened a terminal window.
You can add logic to the script to conditionally run commands based on whatever criteria you decide. A good book on shell scripting is a wonderful read
|
Gods don't kill people - people with Gods kill people.
|
|
|
|
|
|
|
|
Mac Enthusiast
Join Date: Oct 2001
Location: Seattle
Status:
Offline
|
|
What I'd like to do is have the prompt mirrored in the window title. Terminal windows could be stacked but the current state of each would be easily spotted by glancing at their titles. Not sure how to go about it though!
|
|
|
|
|
|
|
|
|
Junior Member
Join Date: Jan 2002
Status:
Offline
|
|
Will, after run my small script termtip, change 'pwd' to 'echo $prompt' it will display your prompt on window title.
|
Apple G4 Cube 450/1.5GB(3 133Mhz 512MB Dimm)/CDRW/WD 7200RPM 120GB/GeForce3/Fan/Apple 17" LCD/SoundStick/HP G85
External WD 7200RPM 120GB firewire
Logitech Wireless keyboard and mouse
iMic, Palm usb-serial, a Router, powered usb hub
|
|
|
|
|
|
|
|
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
Originally posted by darcybaston:
<STRONG>I find my prompt nice and elegant this way:
set prompt="[%c3]"
Darcy</STRONG>
Mine is:
<font face = "courier">set prompt="(%c05): "</font>
Very close to yours. I prefer the space afterwards so what I type doesn't attach directly to the prompt. I would prefer [] instead of () but it was a compromise my roommate and I had.
|
|
|
|
|
|
|
|
|
Moderator Emeritus
Join Date: Mar 2001
Location: Austin, MN, USA
Status:
Offline
|
|
Originally posted by netgo:
<STRONG>Here is my prompt
set prompt = "\! `whoami`@`hostname` : "</STRONG>
My question is why not just use the built in representations of "whoami" and "hostname" unless you aren't using tcsh.
<font face = "courier">`hostname`</font> could be replaced with <font face = "courier">%m</font> for the hostname up to the first dot or <font face = "courier">%M</font> for the whole thing.
<font face = "courier">`whoami`</font> could be replaced with <font face = "courier">%n</font>.
That's why these shortcuts are there. The whole list of shortcuts are in the man pages of tcsh.
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Oct 2001
Location: Sweden
Status:
Offline
|
|
Originally posted by netgo:
<STRONG>Try this.
...
type alias cd 'cd \!*; echo -n "^[]0;`pwd`^G"'
...
</STRONG>
even better is:
alias cwdcmd 'echo -n "^[]0;`pwd`^G"'
cwdcmd is a command that is run every time the current directory is changed. This way the window title is updated, not just when you use cd, but also on pushd and popd.
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Oct 2001
Location: Sweden
Status:
Offline
|
|
double post =(
[ 03-27-2002: Message edited by: tobli ]
|
|
|
|
|
|
|
|
|
Forum Regular
Join Date: Feb 2002
Location: Hawaii
Status:
Offline
|
|
Originally posted by tobli:
<STRONG>
even better is:
alias cwdcmd 'echo -n "^[]0;`pwd`^G"'
cwdcmd is a command that is run every time the current directory is changed. This way the window title is updated, not just when you use cd, but also on pushd and popd.</STRONG>
Optimized version:
alias cwdcmd printf '"\e]2;$PWD\a"'
No embedded control characters or backquoted pwd command.
|
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2002
Location: Live at the BBQ
Status:
Offline
|
|
*sniffsniff*
<moved to tears> isn't community grand? </moved to tears>
I never knew you could do this stuff... and it's so much fun!
|
"Bill Gates can't guarantee Windows... how can you guarantee my safety?"
-John Crichton
|
|
|
|
|
|
|
|
Professional Poster
Join Date: May 2000
Location: Urbandale, IA
Status:
Offline
|
|
Hehehe....all these Mac users who, for years, snickered at the Windows users and their dumb 'ol command line...hehehe
Of course, the Unix command line kicks all kindsa booty compared to DOS, but still...the irony is quite amusing.
|
"Yields a falsehood when preceded by its quotation" yields a falsehood when preceded by its quotation.
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Jan 2002
Location: Live at the BBQ
Status:
Offline
|
|
Originally posted by Oneota:
<STRONG>Hehehe....all these Mac users who, for years, snickered at the Windows users and their dumb 'ol command line...hehehe
Of course, the Unix command line kicks all kindsa booty compared to DOS, but still...the irony is quite amusing. </STRONG>
Granted, but only a small few Mac users will appreciate this and make use of it (but i assume many more will understand how useful it can be).
|
"Bill Gates can't guarantee Windows... how can you guarantee my safety?"
-John Crichton
|
|
|
|
|
|
|
|
Mac Elite
Join Date: Feb 2001
Location: Bristol, UK, living in Melbourne, Australia
Status:
Offline
|
|
can I have the hostname of the computer I am currently logged into (via SSH) in the titlebar? I tried adding $HOSTNAME instead of $PWD but of course once I am logged into another computer it doesn't work! (duh!).
This would be really cool as I often am logged in to 4 or 5 different servers at a time.
|
|
|
|
|
|
|
|
|
Admin Emeritus
Join Date: Nov 2000
Location: New Yawk
Status:
Offline
|
|
|
"Do not be too positive about things. You may be in error." (C. F. Lawlor, The Mixicologist)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|