mirror of https://github.com/nirenjan/dotfiles.git
Fix smartwd script and update PS1 in bashrc.common
parent
7e6df80ce8
commit
48e6e5edcc
|
@ -10,9 +10,9 @@ add_to_path() {
|
||||||
# @github:git/git/contrib/completion/git_prompt.sh
|
# @github:git/git/contrib/completion/git_prompt.sh
|
||||||
if [ -f $HOME/.git_prompt.sh ]; then
|
if [ -f $HOME/.git_prompt.sh ]; then
|
||||||
source $HOME/.git_prompt.sh
|
source $HOME/.git_prompt.sh
|
||||||
export PS1='\e[34m\u@\h \e[0m[\e[32m\w$(__git_ps1 " \e[33m(%s)")\e[0m] '
|
export PS1='\e[34m\u@\h \e[0m[\e[32m$(smartwd)$(__git_ps1 " \e[33m(%s)")\e[0m] '
|
||||||
else
|
else
|
||||||
export PS1='\e[34m\u@\h \e[0m[\e[32m\w\e[0m] '
|
export PS1='\e[34m\u@\h \e[0m[\e[32m$(smartwd)\e[0m] '
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add $HOME/bin to PATH
|
# Add $HOME/bin to PATH
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
# use in the shell prompt
|
# use in the shell prompt
|
||||||
|
|
||||||
# Constants used to decide when to start chopping
|
# Constants used to decide when to start chopping
|
||||||
DIRLIM = 4
|
DIRLIM = 5
|
||||||
|
DIR_L = 3
|
||||||
|
DIR_R = 2
|
||||||
PWDLEN = 14
|
PWDLEN = 14
|
||||||
|
|
||||||
def smartwd
|
def smartwd
|
||||||
|
@ -13,7 +15,6 @@ def smartwd
|
||||||
pwd = ENV['PWD']
|
pwd = ENV['PWD']
|
||||||
|
|
||||||
path = pwd.split('/')
|
path = pwd.split('/')
|
||||||
#pwd = pwd.gsub(homedir, '~')
|
|
||||||
|
|
||||||
# Ignore the root path
|
# Ignore the root path
|
||||||
if (path.length > 0)
|
if (path.length > 0)
|
||||||
|
@ -36,9 +37,18 @@ def smartwd
|
||||||
prefix = path.shift(2).join('/')
|
prefix = path.shift(2).join('/')
|
||||||
path.unshift(prefix)
|
path.unshift(prefix)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Check to make sure that both the DIRLIM and PWDLEN constraints
|
||||||
|
# are met before splitting
|
||||||
|
pwd = path.join('/')
|
||||||
|
if path.length > DIRLIM and pwd.length > PWDLEN
|
||||||
|
pwd_l = path.shift(DIR_L).join('/')
|
||||||
|
pwd_r = path.pop(DIR_R).join('/')
|
||||||
|
pwd = pwd_l + '/.../' + pwd_r
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
puts username, homedir, pwd, prefix.inspect, path.inspect
|
print pwd
|
||||||
end
|
end
|
||||||
|
|
||||||
smartwd
|
smartwd
|
||||||
|
|
Loading…
Reference in New Issue