Created
April 14, 2020 07:48
-
-
Save max-lt/1f05f48c159c328b100ed5955fc00a8b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Complete la ligne depuis l'historique plutot que d'ecraser la frappe en cours | |
bind '"\e[A": history-search-backward' | |
bind '"\e[B": history-search-forward' | |
PS1="$(if [[ ${EUID} == 0 ]]; | |
then echo '\[\033[01;31m\]\u\[\033[01;0m\]@\h'; | |
else echo '\[\033[01;33m\]\u\[\033[01;0m\]@\h'; fi)\[\033[01;36m\] \w/ \[\033[01;0m\]\\$ \[\033[01;0m\]" | |
PS2='> ' | |
PS3='> ' | |
PS4='+ ' | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | |
} | |
parse_path() { | |
if [ / = "$PWD" ]; then | |
echo "/"; | |
return; | |
fi | |
local path=`dirs`; | |
# local len=${#path}; | |
local len=`dirs | wc -m`; | |
if [ $len -lt 24 ]; then | |
echo "$path/"; | |
return; | |
fi | |
# https://muffinresearch.co.uk/showing-last-two-directories-of-pwd-in-bash-prompt/ | |
# local path=`pwd | awk -F\/ '{print $(NF-1),$(NF)}' | sed "s/ /\\//"` | |
local path=`dirs | awk -F\/ '{print $(NF-1)"/"$(NF)}'` | |
echo ".../$path/"; | |
} | |
# User in bold yellow | |
PS1="\[\033[01;33m\]\u\[\033[01;0m\]" | |
# Hostname | |
PS1=$PS1"@\h" | |
# Full path in bold cyan (we use a function to get pwd and shorten it instead of "\w") | |
PS1=$PS1"\[\033[01;36m\] \$(parse_path)\[\033[01;0m\]" | |
# Git branch in yellow (if any) | |
PS1=$PS1"\[\033[33m\]\$(parse_git_branch)\[\033[00m\] $ " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment