Add new, better prompt.
This commit is contained in:
parent
bbf54dd05f
commit
2e218bdc0a
3 changed files with 55 additions and 18 deletions
29
bash/super_prompt.sh
Normal file
29
bash/super_prompt.sh
Normal file
|
@ -0,0 +1,29 @@
|
|||
# Produces a nice, colorful 2-line prompt of the form:
|
||||
# [username@hostname:current_directory] (git_repo|branch)
|
||||
# $
|
||||
|
||||
source ./colorize.sh
|
||||
|
||||
function super_prompt {
|
||||
local git_dir=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
if [ "$git_dir" != "" ]; then
|
||||
local path=$(colorize green ${PWD//$git_dir/\!})
|
||||
else
|
||||
local path=$(colorize green ${PWD//$HOME/\~})
|
||||
fi
|
||||
|
||||
local git_branch=$(git branch 2>/dev/null | grep "*" | cut -d ' ' -f 2) || ""
|
||||
if [ "$git_branch" != "" ]; then
|
||||
local git_repo=$(git rev-parse --show-toplevel)
|
||||
git_branch=\($(colorize magenta ${git_repo//*\/})"|"$(colorize magenta ${git_branch})\)
|
||||
fi
|
||||
|
||||
local user=$(colorize yellow $(whoami))
|
||||
local host=$(colorize blue ${HOSTNAME})
|
||||
local prompt_char=$(colorize red '$')
|
||||
|
||||
prompt=$(printf "[%s@%s:%s] %s\n\f\r%s " "$user" "$host" "$path" "$git_branch" "$prompt_char")
|
||||
echo $prompt
|
||||
}
|
||||
|
||||
# export PS1=super_prompt
|
Loading…
Add table
Add a link
Reference in a new issue