Tweaks to zsh

master
Jonathan Hodgson 2 months ago
parent 285165913d
commit 89dbb2fccf
  1. 2
      shells/zsh/includes/lfcd.zsh
  2. 36
      shells/zsh/includes/paging.zsh
  3. 17
      shells/zsh/includes/promptconfig.zsh

@ -9,4 +9,4 @@ lfcd () {
fi
}
alias lf="lfcd"
bindkey -s '^o' 'lf\n'
#bindkey -s '^o' 'lf\n'

@ -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

@ -98,7 +98,7 @@ function prompt_project() {
local current_project_name="$(project current)"
local background=""
if [[ "$parent_process" == "/usr/bin/script" ]]; then
segment_content=""
segment_content=" "
fi
# If there is a current project
if [ -n "$current_project_name" ]; then
@ -157,6 +157,14 @@ prompt_git(){
echo "$color"
}
prompt_edinburughairport(){
if [ -n "$(find ~/.local/share/airportwait -mmin '+1')" ]; then
https https://blip-api.edinburghairport.com/blip-api/blip | jq -r '" " + (.queue | tostring) + " " + (.minutes | tostring)' > ~/.local/share/airportwait
fi
cat ~/.local/share/airportwait
echo "yellow3"
}
prompt_last_exit_code() {
local LAST_EXIT_CODE="$1"
if [[ $LAST_EXIT_CODE -ne 0 ]]; then
@ -262,6 +270,13 @@ set_prompts(){
PROMPT="$PROMPT$(echo "$segment" | sed -n '1p')"
background="$(echo "$segment" | sed -n '2p')"
fi
#
# Airport
#segment="$(draw_segment "prompt_edinburughairport" "$background")"
#if [ -n "$(echo "$segment" | sed -n '1p')" ];then
# PROMPT="$PROMPT$(echo "$segment" | sed -n '1p')"
# background="$(echo "$segment" | sed -n '2p')"
#fi
PROMPT="$PROMPT $(seperator "$background")$(resetColor)"

Loading…
Cancel
Save