3 _cgmem_which="`cgmem_which 2>/dev/null`"
4 if [ -n "$_cgmem_which" ]; then
5 echo "[$_cgmem_which] "
10 if [ "$PWD" = / ]; then
14 if [ "$PWD" = "$HOME" ]; then
19 _short_curdir="${PWD##*/}" # cut all directories, get base name
20 if [ "${#_short_curdir}" -gt 18 ]; then
21 _short_curdir="${_short_curdir::15}..." # cut long string
23 echo "${_short_curdir}"
26 # bash_prompt; adapted from
27 # https://github.com/necolas/dotfiles/blob/master/shell/bash_prompt and
28 # https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
34 # check if the current directory is in a git repository
35 if git rev-parse --is-inside-work-tree &>/dev/null; then
37 # check if the current directory is in .git before running git checks
38 if [ "$(git rev-parse --is-inside-git-dir 2> /dev/null)" == "false" ]; then
40 # ensure index is up to date
41 #git update-index --really-refresh -q &>/dev/null
43 # check for unstaged changes
44 if [ -n "$(git ls-files --modified)" ]; then
48 # check for uncommitted changes in the index
49 if ! $(git diff --quiet --ignore-submodules --cached); then
53 # check for stashed files
54 if $(git rev-parse --verify refs/stash &>/dev/null); then
58 # check for untracked files
59 if [ -n "$(git ls-files --others --exclude-standard)" ]; then
65 # get the short symbolic ref
66 # if HEAD isn't a symbolic ref, get the short SHA
67 # otherwise, just give up
68 branchName="$(git symbolic-ref --quiet --short HEAD 2> /dev/null || \
69 git rev-parse --short HEAD 2> /dev/null || \
72 [ -n "$s" ] && s=" $s"
73 printf " (%s)" "$branchName$s"
77 if test -x /usr/bin/git >/dev/null 2>&1; then
78 if [ "`type -t __git_ps1`" != function ]; then
79 git_sh_prompt=`git --exec-path`/git-sh-prompt
80 test -r $git_sh_prompt && . $git_sh_prompt || :
82 if [ "`type -t __git_ps1`" = function ]; then
83 GIT_PS1_SHOWDIRTYSTATE=true
84 GIT_PS1_SHOWSTASHSTATE=true
85 GIT_PS1_SHOWUNTRACKEDFILES=true
86 GIT_PS1_SHOWUPSTREAM=verbose
92 # display the user, host and current working directory
93 # in the terminal title
95 *rxvt*|screen*|*term*|vt100)
96 OPS1+="\[\033]0;${debian_chroot:+($debian_chroot)}\u@\h:\w\007\]"
99 OPS1+="\[\033k${debian_chroot:+($debian_chroot)}"
100 OPS1+="\u@\h:\w\033\\\\\]" # Set screen/tmux caption
110 OPS1+="${debian_chroot:+($debian_chroot)}"
111 OPS1+="\`cgmem_which_prompt\`\u@\${HOSTNAME::5}:\`short_curdir\`"
112 if test -x /usr/bin/git >/dev/null 2>&1; then
113 if [ "`type -t __git_ps1`" = function ]; then
114 OPS1+="\$(__git_ps1)"
116 OPS1+="\$(prompt_git)"
119 # This is for .screenrc: shelltitle "\$ |$SHELL"
120 #OPS1+="\[\033k\033\\\\\]"