A quick Bash Fix

Remember, not too long ago I told you how to shorten path names in a Bash prompt? Well two things. Apparently, there’s a similar mechanism in Bash 4.0 with PROMPT_DIRTRIM(which I haven’t tried yet). Second, noticed that I’m frequently using many terminals opened on many machines, and I’m not always sure which is which. Using uname -n in the terminal spews the machine name, but it’d be much better if the name appeared in the terminal title bar. To do so, use the same prompt I used previously, and add $HOSTNAME (a Bash variable that holds the machine’s name) in there:

PS1='\[\033]0;$HOSTNAME: $(shorten_path "${PWD}" 50)\007\]$(shorten_path "${PWD}" 50) >'

(again, use the view plain mode if WordPress messes up the syntax again)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: