Skip to content

Instantly share code, notes, and snippets.

@Mayeu
Created November 2, 2010 23:13
Show Gist options
  • Save Mayeu/660496 to your computer and use it in GitHub Desktop.
Save Mayeu/660496 to your computer and use it in GitHub Desktop.
Prompt avant insertion git
## Prompt
hostnam=$(hostname -s)
usernam=$(whoami)
#PIPE="\[\033[1;30m\]"
NCOL="\[\033[0m\]"
function prompt_command {
if [[ $? != 0 ]] ; then
>.......PIPE="\[\033[0;31m\]"
else
>.......TEST="test"
>.......PIPE="\[\033[1;30m\]"
fi
# Find the width of the prompt:
TERMWIDTH=${COLUMNS}
# Add all the accessories below ...
local temp="--(${usernam}@${hostnam}:${PWD})--(xx:xx)--"
let fillsize=${TERMWIDTH}-${#temp}
if [ "$fillsize" -gt "0" ]
then
>.......fill="qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq"
>.......# It's theoretically possible someone could need more
>.......# dashes than above, but very unlikely! HOWTO users,
>.......# the above should be ONE LINE, it may not cut and
>.......# paste properly
>.......# q because in octal q give a nice dash :)
>.......fill="${fill:0:${fillsize}}"
>.......newPWD="${PWD}"
fi
if [ "$fillsize" -lt "0" ]
then
>.......fill=""
>.......let cut=3-${fillsize}
>.......newPWD="../${PWD:${cut}}"
fi
export PS1="\n$PIPE\[\033(0\]lu\[\033(B\]$NCOL\
\u@\h:\${newPWD}\
$PIPE\[\033(0\]t\${fill}\[\033(B\]\[\033(0\]u\[\033(B\]$NCOL\
\$(date +%H:%M)\
$PIPE\[\033(0\]tq\[\033(B\]$NCOL\
\n$PIPE\[\033(0\]mqu\[\033(B\]$NCOL"
export PS2=" $PIPE\[\033(0\]x\[\033(B\]$NCOL"
}
#function twtty {
#
##local LIGHT_BLUE="\[\033[1;34m\]"
##local YELLOW="\[\033[1;33m\]"
#
##export PS1="${GREEN}Lain-ux${NC}@\h:\W > "
#PS1="\n$PIPE\[\033(0\]lu\[\033(B\]$NCOL\
#\u@\h:\${newPWD}\
#$PIPE\[\033(0\]t\${fill}\[\033(B\]\[\033(0\]u\[\033(B\]$NCOL\
#\$(date +%H:%M)\
#$PIPE\[\033(0\]tq\[\033(B\]$NCOL\
#\n$PIPE\[\033(0\]mqu\[\033(B\]$NCOL"
#PS2=" $PIPE\[\033(0\]x\[\033(B\]$NCOL"
#}
PROMPT_COMMAND=prompt_command
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment