Ok, so I’ve made this, because I got tired of ssh’ing into a machine and copy it back over for everytime I got access to a new machine. So here it is my prompt on just about every single nix based machine I use….My prompt.. You may take and use any of this information if you find it useful. I find that the prompt needs some color and other visualization, my Terminal background-color is always black…
Please note that all BLUE text are comments.
fully.qualified.domain_name
Machine Type + Version
username @ hostname (IFace[#] = IP)
[ working dir ]
Preview of my laptop, [iBook G4 w/ 1.5 gig ram. Terminal]
ppcg4.local
Darwin 9.8.0
dscott@ppcg4 ( en0 = 192.168.2.1 en1 = 192.168.2.102 )
[~] $ |
The file that makes the above prompt is located at either ~/.profile or ~/.bash_profile; the ~ or tilde is a inbedded shortcut to the $LOGNAME home directory, or /home/username (Unix / Linux) or /Users/username (Darwin).
ppcg4.local
Darwin 9.8.0
dscott@ppcg4 ( en0 = 192.168.2.1 en1 = 192.168.2.102 )
[~] $ cat ~/.profile|
# Set my aliases [ command line shortcuts ]
alias ls=’ls -G’
alias ce=’mcedit –colors editnormal=lightgray,black’
alias grep=’grep –color’
alias mv=’mv -v’
alias cp=’cp -v’
alias rm=’rm -v’
# Add the root/bin directory to my path and add some more stuff
# notice the colon as the separator
export PATH=$PATH:/root/bin:/${HOME}/bin:/opt/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
#
# Use this to mac a Mac terminal look like the colors in a Linux terminal
#export PATH=/sw/bin:/opt/local/bin:/opt/local/sbin:/usr/local/pgsql/bin:$HOME/bin:$PATH
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
# Taken from the man page.
# LSCOLORS The value of this variable describes what color to use for which attribute when colors are
# enabled with CLICOLOR. This string is a concatenation of pairs of the format fb, where f is the
# foreground color and b is the background color.
#
# The color designators are as follows:
#
# a black
# b red
# c green
# d brown
# e blue
# f magenta
# g cyan
# h light grey
# A bold black, usually shows up as dark grey
# B bold red
# C bold green
# D bold brown, usually shows up as yellow
# E bold blue
# F bold magenta
# G bold cyan
# H bold light grey; looks like bright white
# x default foreground or background
# Have a list of the escape colors to change the color in the prompt.
# all color codes below are preluded with \[\00[
# and postluded with \]
#
# EG. export TEST=’\[\033[1;33m\]TESTING\[\033[0;m\]‘
# yields TESTING
#
#Black 0;30
#Blue 0;34
#Green 0;32
#Cyan 0;36
#Red 0;31
#Purple 0;35
#Brown 0;33
#Light Gray 0;37
#Light Gray 1;30
#Light Blue 1;34
#Light Green 1;32
#Light Cyan 1;36
#Light Red 1;31
#Light Purple 1;35
#Yellow 1;33
#White 1;37
## Default prompt
# export PS1=’\u@\h \w #’
# I added some interface stuff for IP…(got tired of typing ifconfig)
EN[0]=`ifconfig en0 | grep inet | grep -v inet6 | awk ‘{print $2}’ | tr -d “\n”`
EN[1]=`ifconfig en1 | grep inet | grep -v inet6 | awk ‘{print $2}’ | tr -d “\n”`
# the checks to see if we can use them
if [ ! -z "${EN[0]}” ]; then
INET[0]=”en0 = ${EN[0]}”
else
INET[0]=”"
fi
if [ ! -z "${EN[1]}” ]; then
INET[1]=”en1 = ${EN[1]}”
else
INET[1]=”"
fi
# And now put it to work for me… the FQDN will change when connecting to another network.
# the IP doesn’t though….
export PS1=’\n\[\033[1;32m\]$(hostname)\n $(uname -s) $(uname -r)\n\[\033[1;36m\]\u@\h \[\033[1;37m\]( ${INET[0]} ${INET[1]} )\n[\w] \[\033[1;33m\]$ \[\033[0;37m\]‘
# auto complete our ssh command ( tab completion for ssh command.. ssh hos )
complete -W “$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ‘ ‘ | sed -e s/,.*//g | uniq | grep -v “\[“`;)” ssh
# complete -W “$(echo `cat ~/.ssh/known_hosts | cut -f 1 -d ‘ ‘ | sed -e s/,.*//g | uniq | grep -v “\[“`;)” scp