pimp prompt
This commit is contained in:
parent
a3cc167efe
commit
6d8bf743e7
2 changed files with 57 additions and 29 deletions
42
shell/bashrc
42
shell/bashrc
|
@ -32,21 +32,39 @@ set -o vi
|
|||
|
||||
git_branch() {
|
||||
GIT_BRANCH="$(git branch 2>/dev/null | sed '/\*/!d;s/^\*\s*//g;s/\s*$//g')"
|
||||
[ -n "$GIT_BRANCH" ] && printf "%s " "$GIT_BRANCH"
|
||||
[ -n "$GIT_BRANCH" ] && printf " %s " "$GIT_BRANCH"
|
||||
}
|
||||
|
||||
TIME="$(date)"
|
||||
TIME=${TIME% [AP]M*}
|
||||
TIME=${TIME##* }
|
||||
padding() {
|
||||
text="$@"
|
||||
len="${#text}"
|
||||
tput cuf 1
|
||||
tput cub "$((len - 1))"
|
||||
printf '%s' "$text"
|
||||
tput cub "$len"
|
||||
}
|
||||
|
||||
PS1='\
|
||||
\[\033[2m\]($?)\[\033[0m\] \
|
||||
\[\033[1m\]\[\033[36m\]\u\[\033[0m\]\
|
||||
\[\033[36m\]@\h\[\033[0m\] \
|
||||
\[\033[34m\]\w \
|
||||
\[\033[1m\]\[\033[35m\]$(git_branch)\[\033[0m\]\
|
||||
\[\033[2m\][\!] $TIME\[\033[0m\]\
|
||||
\n\[\033[2m\]$\[\033[0m\] '
|
||||
short_time() {
|
||||
TIME="$(date)"
|
||||
TIME=${TIME% [AP]M*}
|
||||
TIME=${TIME##* }
|
||||
TIME="${TIME%:[0-9]*}"
|
||||
printf '%s' "$TIME"
|
||||
}
|
||||
|
||||
PS1='
|
||||
$(tput setaf 238)$(tput setab 244)[$?]\
|
||||
$(tput setaf 244)$(tput setab 108) $(tput setaf 235)$(tput setab 108)\
|
||||
${USER:=$(id -un)}@${HOSTNAME:=$(hostname -s)} \
|
||||
$(tput setaf 108)$(tput setab 66) \
|
||||
$(tput setab 66)$(tput setaf 235)\w $(tput sgr0)\
|
||||
$(tput setaf 66)\
|
||||
$(tput sgr0)$(tput cr)$(tput cuf $(tput cols))\
|
||||
$(tput setab 236)$(tput setaf 240)$(padding " $(short_time) ")$(tput sgr0)\
|
||||
$(tput bold)$(tput setab 236)$(tput setaf 5)$(padding " $(git_branch)")$(tput sgr0)\
|
||||
$(tput setaf 236)$(tput sgr0)
|
||||
$(tput dim)\$$(tput sgr0) \
|
||||
'
|
||||
|
||||
alias \
|
||||
wget="wget --hsts-file=$XDG_DATA_HOME/wget/wget-hsts"
|
||||
|
|
44
shell/mkshrc
44
shell/mkshrc
|
@ -17,32 +17,42 @@ PATH="$HOME/.local/bin${PATH:+:${PATH}}"
|
|||
|
||||
git_branch() {
|
||||
GIT_BRANCH="$(git branch 2>/dev/null | sed '/\*/!d;s/^\*\s*//g;s/\s*$//g')"
|
||||
[ -n "$GIT_BRANCH" ] && printf "%s " "$GIT_BRANCH"
|
||||
[ -n "$GIT_BRANCH" ] && printf " %s " "$GIT_BRANCH"
|
||||
}
|
||||
|
||||
TIME="$(date)"
|
||||
TIME=${TIME% [AP]M*}
|
||||
TIME=${TIME##* }
|
||||
TIME=${TIME%:[0-9]*}
|
||||
padding() {
|
||||
text="$@"
|
||||
len="${#text}"
|
||||
tput cuf 1
|
||||
tput cub "$((len - 1))"
|
||||
printf '%s' "$text"
|
||||
tput cub "$len"
|
||||
}
|
||||
|
||||
short_time() {
|
||||
TIME="$(date)"
|
||||
TIME=${TIME% [AP]M*}
|
||||
TIME=${TIME##* }
|
||||
TIME="${TIME%:[0-9]*}"
|
||||
printf '%s' "$TIME"
|
||||
}
|
||||
|
||||
short_path() {
|
||||
pwd | sed 's/\/home\/[A-Za-z]*/~/g'
|
||||
}
|
||||
|
||||
PS1='
|
||||
$(tput bold)\
|
||||
$(tput setaf 239)$(tput setab 244) [$(tput setaf 235)$?$(tput setaf 239)] \
|
||||
$(tput setaf 244)$(tput setab 108) \
|
||||
$(tput setaf 235)$(tput setab 108)${USER:=$(id -un)}@${HOSTNAME:=$(hostname -s)} \
|
||||
$(tput setaf 238)$(tput setab 244)[$?]\
|
||||
$(tput setaf 244)$(tput setab 108) $(tput setaf 235)$(tput setab 108)\
|
||||
${USER:=$(id -un)}@${HOSTNAME:=$(hostname -s)} \
|
||||
$(tput setaf 108)$(tput setab 66) \
|
||||
$(tput setab 66)$(tput setaf 235)$(short_path) \
|
||||
$(tput setaf 66)$(tput setab 236) \
|
||||
$(tput setaf 5)$(tput setab 236)$(git_branch)$(tput sgr0)\
|
||||
$(tput setab 236)\
|
||||
$(tput setaf 240)${TIME} $(tput sgr0)\
|
||||
$(tput setaf 236)\
|
||||
$(tput sgr0)
|
||||
$(tput dim)$(if (( USER_ID )); then print \$; else print \#; fi)$(tput sgr0) \
|
||||
$(tput setab 66)$(tput setaf 235)$(short_path) $(tput sgr0)\
|
||||
$(tput setaf 66)\
|
||||
$(tput sgr0)$(tput cr)$(tput cuf $(tput cols))\
|
||||
$(tput setab 236)$(tput setaf 240)$(padding " $(short_time) ")$(tput sgr0)\
|
||||
$(tput bold)$(tput setab 236)$(tput setaf 5)$(padding " $(git_branch)")$(tput sgr0)\
|
||||
$(tput setaf 236)$(tput sgr0)
|
||||
$(tput dim)\$$(tput sgr0) \
|
||||
'
|
||||
|
||||
alias \
|
||||
|
|
Loading…
Reference in a new issue