Skip to content

Instantly share code, notes, and snippets.

@raybird
Created December 15, 2019 03:26
Show Gist options
  • Save raybird/94052d5719d68a9ae94f24e49b1e3bb7 to your computer and use it in GitHub Desktop.
Save raybird/94052d5719d68a9ae94f24e49b1e3bb7 to your computer and use it in GitHub Desktop.
add git branch on bash-prompt
## INCLUDE CUSTOM `.bashrc` CODE
##
#if [ -f ~/.bashrc_custom ]; then
# . ~/.bashrc_custom
#fi
# THIS FILE IS A USER-CUSTOM BASHRC FILE TO KEEP CLEAN THE DEFAULT ~/.barshrc FILE.
# PUT THERE ANY CUSTOM CODE MANUALLY ADDED BY YOU
# Show git branch name
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u \[\033[00m\]at \[\033[01;32m\]\h \[\033[00m\]in \[\033[01;34m\]\w\[\033[00m\]\non \[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ '
fi
unset color_prompt force_color_prompt
@raybird
Copy link
Author

raybird commented Dec 16, 2019

@raybird
Copy link
Author

raybird commented Mar 14, 2020

now PS1

PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\D{%F %T}\[\033[00m\] \[\033[01;32m\]\u \[\033[00m\]at \[\033[01;33m\]\h \[\033[00m\]in \[\033[01;36m\]\w\[\033[00m\]\non \[\033[00;33m\]$(parse_git_branch)\[\033[00m\]\$ '

@raybird
Copy link
Author

raybird commented Jan 28, 2022

    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\n\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\D{%F %T}\[\033[00m\] \[\033[01;32m\]\u \[\033[00m\]at \[\033[01;33m\]\h \[\033[00m\]in \[\033[01;36m\]\w\[\033[00m\]\non \[\033[00;33m\]$(parse_git_branch)\[\033[00m\]\$ '
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\[\033[01;32m\]\u \[\033[00m\]at \[\033[01;33m\]\h \[\033[00m\]in \[\033[01;36m\]\w\[\033[00m\]\non \[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '

@raybird
Copy link
Author

raybird commented Sep 1, 2022

alias dsize='du -chd 1 | sort -h'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment