Changes to custom tab completion

master
Jonathan Hodgson 5 years ago
parent 46131a06c3
commit 459fe8cf6d
  1. 28
      shells/zsh/oh-my-zsh-custom/fzf.zsh

@ -51,26 +51,28 @@ if [ -e /usr/share/fzf/key-bindings.zsh ]; then
jhComplete(){ jhComplete(){
local comp=$(echo $1 | cut -d':' -f1) local comp=$(echo $1 | cut -d':' -f1)
local prompt=$(echo $1 | cut -d':' -f2) local prompt=$(echo $1 | cut -d':' -f2)
local currentProject=$(project current --path)
export FZF_DEFAULT_OPTS="$FZF_DEFAULT_OPTS --reverse --height 40%"
find "$HOME/.local/share/snippets/" -name \*.func | while read line; do
source "$line"
done
case "${comp}" in case "${comp}" in
ip) ip)
if [ -n "$currentProject" ]; then if [ -n "$currentProject" ]; then
project hosts ip --fzf project hosts ip --fzf
else
echo ""
fi fi
;; ;;
myip)
ip route | grep -oE '(dev|src) [^ ]+' | sed 'N;s/\n/,/;s/src //' | awk -F',' '{print $2 " " $1}' | sort -u | fzf --no-preview | cut -d' ' -f1
;;
pf) pf)
if [ -n "$currentProject" ]; then if [ -n "$currentProject" ]; then
find "$currentProject" -type f | fzf find "$currentProject" -type f | fzf
else
echo ""
fi fi
;; ;;
pd) pd)
if [ -n "$currentProject" ]; then if [ -n "$currentProject" ]; then
find "$currentProject" -type d | fzf --no-preview find "$currentProject" -type d | fzf --no-preview
else
echo ""
fi fi
;; ;;
wl|wordlist) wl|wordlist)
@ -79,9 +81,18 @@ if [ -e /usr/share/fzf/key-bindings.zsh ]; then
snip) snip)
snippets snippets
;; ;;
hcm)
hashcat --example-hashes | awk -v RS="\n\n" -F "\t" '{gsub("\n","\t",$0); print $1 "\t" $2 "\t" $3}' | sed 's/MODE: //; s/TYPE: //' | fzf -d "\t" --header="Mode Type" --with-nth='1,2' --preview='echo {3}' --preview-window=up:1 | cut -d' ' -f1
;;
network-interface|int)
ip -o link show | cut -d' ' -f2- | sed -E 's/[^:]+(UP|DOWN).*/\1/' | tr ':' ' ' | fzf --preview="interface=\$(echo {} | cut -f1 -d' ');ip address show \$interface" | cut -d' ' -f1
;;
*) *)
# Fall back to fzf completion if command -v "jhcomplete::$comp" > /dev/null; then
"jhcomplete::$comp"
else
echo "" echo ""
fi
esac esac
} }
@ -97,7 +108,6 @@ jhswap(){
local word="${LBUFFER##* }${RBUFFER%% *}" local word="${LBUFFER##* }${RBUFFER%% *}"
if [ -n "$word" ]; then if [ -n "$word" ]; then
local changeto=$(jhswap "$word" ) local changeto=$(jhswap "$word" )
if [ -n "$changeto" ]; then
local lastWord="$changeto" local lastWord="$changeto"
local LWORDS=$(echo $LBUFFER | tr ' ' '\n' | wc -l) local LWORDS=$(echo $LBUFFER | tr ' ' '\n' | wc -l)
local RWORDS=$(echo $RBUFFER | tr ' ' '\n' | wc -l) local RWORDS=$(echo $RBUFFER | tr ' ' '\n' | wc -l)
@ -115,7 +125,6 @@ jhswap(){
zle -R zle -R
return 0 return 0
fi fi
fi
} }
@ -142,7 +151,6 @@ jhswap(){
fi fi
cmd=${tokens[1]} cmd=${tokens[1]}
tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))} tail=${LBUFFER:$(( ${#LBUFFER} - ${#trigger} ))}
local currentProject=$(project current --path)
#local newLBuffer="${tokens:1:${#tokens[@]}-1}" #local newLBuffer="${tokens:1:${#tokens[@]}-1}"
local newLBuffer local newLBuffer
for i in $(seq 1 $((${#tokens[@]} - 1)) ); do for i in $(seq 1 $((${#tokens[@]} - 1)) ); do

Loading…
Cancel
Save