Moved gp_truncate_pwd function to gitprompt.sh

master
oGre 10 years ago
parent ff48c81587
commit fbeaa6effd
  1. 8
      gitprompt.sh
  2. 8
      themes/TruncatedPwd_WindowTitle.bgptheme
  3. 8
      themes/TruncatedPwd_WindowTitle_NoExitState.bgptheme

@ -525,6 +525,14 @@ function is_function {
declare -Ff "$1" >/dev/null; declare -Ff "$1" >/dev/null;
} }
#Helper function that truncates $PWD depending on window width
function gp_truncate_pwd {
local newPWD="${PWD/#$HOME/~}"
local pwdmaxlen=$((${COLUMNS:-80}/3))
[ ${#newPWD} -gt $pwdmaxlen ] && newPWD="...${newPWD:3-$pwdmaxlen}"
echo -n "$newPWD"
}
#Sets the window title to the given argument string #Sets the window title to the given argument string
function gp_set_window_title { function gp_set_window_title {
echo -ne "\033]0;"$@"\007" echo -ne "\033]0;"$@"\007"

@ -23,14 +23,6 @@
override_git_prompt_colors() { override_git_prompt_colors() {
GIT_PROMPT_THEME_NAME="TruncatedPwd_WindowTitle" GIT_PROMPT_THEME_NAME="TruncatedPwd_WindowTitle"
#Helper function that truncates $PWD depending on window width
function gp_truncate_pwd {
local newPWD="${PWD/#$HOME/~}"
local pwdmaxlen=$((${COLUMNS:-80}/3))
[ ${#newPWD} -gt $pwdmaxlen ] && newPWD="...${newPWD:3-$pwdmaxlen}"
echo -n "$newPWD"
}
#Overrides the prompt_callback function used by bash-git-prompt #Overrides the prompt_callback function used by bash-git-prompt
function prompt_callback { function prompt_callback {
local PS1="\u@\h: $(gp_truncate_pwd)" local PS1="\u@\h: $(gp_truncate_pwd)"

@ -23,14 +23,6 @@
override_git_prompt_colors() { override_git_prompt_colors() {
GIT_PROMPT_THEME_NAME="TruncatedPwd_WindowTitle_NoExitState" GIT_PROMPT_THEME_NAME="TruncatedPwd_WindowTitle_NoExitState"
#Helper function that truncates $PWD depending on window width
function gp_truncate_pwd {
local newPWD="${PWD/#$HOME/~}"
local pwdmaxlen=$((${COLUMNS:-80}/3))
[ ${#newPWD} -gt $pwdmaxlen ] && newPWD="...${newPWD:3-$pwdmaxlen}"
echo -n "$newPWD"
}
#Overrides the prompt_callback function used by bash-git-prompt #Overrides the prompt_callback function used by bash-git-prompt
function prompt_callback { function prompt_callback {
local PS1="\u@\h: $(gp_truncate_pwd)" local PS1="\u@\h: $(gp_truncate_pwd)"

Loading…
Cancel
Save