Fixes git tag and makes fzf default to ansi colours

Jonathan Hodgson 4 years ago
parent 92b8614b8c
commit 721b2aaa9d
  1. 6
      shells/zsh/includes/fzf.zsh
  2. 28
      shells/zsh/includes/promptconfig.zsh

@ -1,6 +1,6 @@
# this rg command will get a list of files that are not in gitignore or similar # this rg command will get a list of files that are not in gitignore or similar
export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --color=always --exclude .git --exclude .PlayOnLinux --exclude \"PlayOnLinux\'s virtual drives\"" export FZF_DEFAULT_COMMAND="fd --type f --hidden --follow --color=always --exclude .git --exclude .PlayOnLinux --exclude \"PlayOnLinux\'s virtual drives\""
export FZF_DEFAULT_OPTS="--reverse --height 40%" export FZF_DEFAULT_OPTS="--reverse --ansi --height 40%"
export FZF_CTRL_R_OPTS="" export FZF_CTRL_R_OPTS=""
# this is the argument completeion optionm, use the same command # this is the argument completeion optionm, use the same command
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
@ -13,8 +13,8 @@ if [ -e /usr/share/fzf/key-bindings.zsh ]; then
__fsel_wordlist() { __fsel_wordlist() {
local cmd="$FZF_DEFAULT_COMMAND --exclude \*.md --exclude \*.gif --exclude \*.jpg --exclude \*.png --exclude \*.lua --exclude \*.jar --exclude \*.pl '' /usr/share/wordlists/ | sed 's#^/usr/share/wordlists/##'" local cmd="$FZF_DEFAULT_COMMAND --exclude \*.md --exclude \*.gif --exclude \*.jpg --exclude \*.png --exclude \*.lua --exclude \*.jar --exclude \*.pl '' /usr/share/wordlists/ | sed 's#^/usr/share/wordlists/##'"
setopt localoptions pipefail 2> /dev/null setopt localoptions pipefail 2> /dev/null
eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS --preview 'bat --color=always /usr/share/wordlists/{}'" $(__fzfcmd) -m "$@" | while read item; do eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse $FZF_DEFAULT_OPTS $FZF_CTRL_T_OPTS --preview 'bat --color=always {}'" $(__fzfcmd) -m "$@" | while read item; do
echo -n "/usr/share/wordlists/${(q)item} " echo -n "${(q)item} "
done done
local ret=$? local ret=$?
echo echo

@ -117,25 +117,30 @@ function prompt_project() {
} }
prompt_git(){ prompt_git(){
local branch="$(git branch --show-current 2> /dev/null)" local repoTopLevel="$(command git rev-parse --show-toplevel 2> /dev/null)"
local color="green" if [ -n "$repoTopLevel" ]; then
local ret="" local branch="$(git branch --show-current 2> /dev/null)"
if [ -n "$branch" ]; then local tag="$(git describe --tags --exact-match HEAD 2> /dev/null)"
ret="$branch" local color="green"
local ret=""
[ -n "$branch" ] && ret="$branch "
[ -n "$tag" ] && ret+="$tag "
[ -n "$ret" ] || ret="$(git rev-parse --short HEAD 2> /dev/null)"
local repoTopLevel="$(command git rev-parse --show-toplevel 2> /dev/null)" local repoTopLevel="$(command git rev-parse --show-toplevel 2> /dev/null)"
local untrackedFiles=$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null) local untrackedFiles=$(command git ls-files --others --exclude-standard "${repoTopLevel}" 2> /dev/null)
local modified=$(command git diff --name-only 2> /dev/null)
local staged=$(command git diff --staged --name-only 2> /dev/null) local staged=$(command git diff --staged --name-only 2> /dev/null)
if [ -n "$untrackedFiles" ]; then if [ -n "$modified" ]; then
ret="$ret " ret+=" "
color="orange1" color="orange1"
fi fi
if [ -n "$staged" ]; then if [ -n "$staged" ]; then
ret="$ret " ret+=" "
color="orange1" color="orange1"
fi fi
fi fi
ret="$(echo "$ret" | sed -e 's/ *$//')"
echo "$ret" echo "$ret"
echo "$color" echo "$color"
} }
@ -197,7 +202,6 @@ set_prompts(){
#Set background to nothing at the start of the prompt #Set background to nothing at the start of the prompt
local background="" local background=""
local foreground=""
#Set the prompt to an empty string #Set the prompt to an empty string
PROMPT="" PROMPT=""
@ -224,8 +228,10 @@ set_prompts(){
PROMPT="$PROMPT$(echo "$segment" | sed -n '1p')" PROMPT="$PROMPT$(echo "$segment" | sed -n '1p')"
background="$(echo "$segment" | sed -n '2p')" background="$(echo "$segment" | sed -n '2p')"
fi fi
invisibleSeperator=$(echo -e '\u2063')
PROMPT="$PROMPT $(seperator "$background")$(resetColor)" PROMPT="$PROMPT $(seperator "$background")$(resetColor)$invisibleSeperator"
#$(resetColor) #$(resetColor)
RPROMPT="$(resetColor)$(prompt_last_exit_code "$RETVAL")$(resetColor)" RPROMPT="$(resetColor)$(prompt_last_exit_code "$RETVAL")$(resetColor)"

Loading…
Cancel
Save