Fixes git tag and makes fzf default to ansi colours

Jonathan Hodgson 5 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
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=""
# this is the argument completeion optionm, use the same command
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
@ -13,8 +13,8 @@ if [ -e /usr/share/fzf/key-bindings.zsh ]; then
__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/##'"
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
echo -n "/usr/share/wordlists/${(q)item} "
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 "${(q)item} "
done
local ret=$?
echo

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

Loading…
Cancel
Save