Tweaks to zsh
This commit is contained in:
parent
285165913d
commit
89dbb2fccf
3 changed files with 53 additions and 2 deletions
36
shells/zsh/includes/paging.zsh
Normal file
36
shells/zsh/includes/paging.zsh
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
# Modify the input line before it runs
|
||||
function page() {
|
||||
#commands=(${(@s:/:)BUFFER})
|
||||
|
||||
# Gets the words
|
||||
words=(${(z)BUFFER})
|
||||
|
||||
# If there isn't anythng typed, fall back to old tab binding
|
||||
if [ ${#words} -lt 1 ]; then
|
||||
zle ${enterBehaviour:-accept-line}
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
lastCommand="$(printf "%s\n" words | tac | sed -E '/^(\||\&\&|\|\|)$/,$d' | tac)"
|
||||
lastCommand="${(s:\n:)lastCommand}"
|
||||
|
||||
case "$BUFFER" in
|
||||
*"--help" | *"-h" )
|
||||
BUFFER="$BUFFER | bat"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
zle ${enterBehaviour:-accept-line}
|
||||
}
|
||||
|
||||
enterBehaviour="accept-line"
|
||||
binding=$(bindkey '^M')
|
||||
[[ $binding =~ 'undefined-key' ]] || enterBehaviour=$binding[(s: :w)2]
|
||||
|
||||
unset original_binding
|
||||
|
||||
zle -N page
|
||||
# Bind to the Enter key
|
||||
bindkey '^M' page
|
||||
Loading…
Add table
Add a link
Reference in a new issue