1
0
Fork 0

zsh cleanup, better lf widget

This commit is contained in:
Luca Bilke 2023-11-20 14:30:34 +01:00
parent 7ed2d5afab
commit 77a6828d60
7 changed files with 29 additions and 39 deletions

View file

@ -2,7 +2,6 @@
source $ZDOTDIR/configs/vars
source $ZDOTDIR/configs/functions
source $ZDOTDIR/configs/setup
source $ZDOTDIR/configs/widgets
source $ZDOTDIR/configs/bindings
source $ZDOTDIR/configs/aliases
[ -r $ZDOTDIR/configs/host-setup ] && source $ZDOTDIR/configs/host-setup

View file

@ -1,4 +1,5 @@
# vim:set ft=zsh
# vim: set ft=sh:
# shellcheck disable=SC2142
# sudo not required for some system commands
for command in mount umount sv pacman xbps-install xbps-remove apt aptitude updatedb su shutdown poweroff reboot; do
command -v $command 1>/dev/null 2>&1 && alias $command="sudo $command"
@ -59,13 +60,8 @@ fi
# Misc.
alias \
ll="ls -lhpAN --color=auto --group-directories-first" \
ref="shortcuts >/dev/null; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/shortcutrc ; source ${XDG_CONFIG_HOME:-$HOME/.config}/shell/zshnameddirrc" \
weath="less -S ${XDG_CACHE_HOME:-$HOME/.cache}/weatherreport" \
remvirt="virt-manager -c 'qemu+ssh://luca@192.168.178.200/system'" \
wikidown='rclone sync cloud:files/luca/Notes ~/Documents/vimwiki' \
wikiup='rclone sync ~/Documents/vimwiki cloud:files/luca/Notes' \
ahv="export ANSIBLE_VAULT_PASSWORD_FILE=~/.ansible/secrets/ansible-homelab && ansible-vault" \
xgetkeys="xev | sed -ne '/^KeyPress/,/^$/p'" \
whed='() { $EDITOR $(which "$1") }' \
xpick=" xprop | awk '
/^WM_CLASS/{sub(/.* =/, \"instance:\"); sub(/,/, \"\nclass:\"); print}
/^WM_NAME/{sub(/.* =/, \"title:\"); print}'"

View file

@ -1,4 +1,4 @@
# vim:set ft=zsh
# vim: set ft=sh
# vi mode
bindkey -v
@ -9,9 +9,9 @@ bindkey -M menuselect 'l' vi-forward-char
bindkey -M menuselect 'j' vi-down-line-or-history
# Widgets
bindkey '^e' _lfwrap
bindkey '^e' lfwrap
bindkey '^g' lg
bindkey -M vicmd v edit-command-line
bindkey -M vicmd '^v' edit-command-line
bindkey '^?' backward-delete-char
bindkey '^[[P' delete-char

View file

@ -1,20 +1,2 @@
# vim:set ft=zsh
# vim: set ft=sh
whed() {
$EDITOR "$(which "$1")"
}
venv_prompt() {
[[ -n ${VIRTUAL_ENV} ]] || return
echo -e "%F{yellow}%f ${VIRTUAL_ENV:t:gs/%/%%}"
}
function write_title_cmd() {
if [ ${1[(w)1]} != "lfwrap" ]; then
echo -ne "\033]0;$(print -P "%n@%m [%3~] » ${1[(w)1]}")\007"
fi
}
function write_title_wd() { echo -ne "\033]0;$(print -P "%n@%m [%3~]")\007" }
# reset_beam() { echo -ne '\e[5 q' } # Use beam shape cursor for each new prompt.

View file

@ -1,4 +1,4 @@
# vim:set ft=zsh
# vim: set ft=sh
[ ! -f $XDG_DATA_HOME/zsh/history ] && mkdir -p $XDG_DATA_HOME/zsh && touch $XDG_DATA_HOME/zsh/history
setopt HIST_IGNORE_ALL_DUPS HIST_REDUCE_BLANKS HIST_VERIFY BANG_HIST interactive_comments autocd noflowcontrol longlistjobs nonomatch notify hash_list_all share_history histignorespace PROMPT_SUBST

View file

@ -1,4 +1,4 @@
# vim:set ft=zsh
# vim: set ft=sh
HISTSIZE=10000000
SAVEHIST=10000000
HISTFILE="$XDG_DATA_HOME/zsh/history"

View file

@ -1,4 +1,18 @@
# vim:set ft=zsh
# vim: set ft=sh
venv_prompt() {
[[ -n ${VIRTUAL_ENV} ]] || return
echo -e "%F{yellow}%f ${VIRTUAL_ENV:t:gs/%/%%}"
}
function write_title_cmd() {
if [ ${1[(w)1]} != "lfwrap" ]; then
echo -ne "\033]0;$(print -P "%n@%m [%3~] » ${1[(w)1]}")\007"
fi
}
function write_title_wd() { echo -ne "\033]0;$(print -P "%n@%m [%3~]")\007" }
function reset_beam() { echo -ne '\e[5 q' }
function lfwrap () {
LF_DIRFILE="/tmp/lfdir.$(uuidgen)"
@ -10,14 +24,13 @@ function lfwrap () {
cd "$dir"
fi
fi
tput cuu1;tput el
zle reset-prompt
zle redisplay
write_title_wd
reset_beam
}
function _lfwrap () {
BUFFER=" lfwrap"
zle accept-line
}
zle -N _lfwrap
zle -N lfwrap
# Cursor Shape
function zle-keymap-select () {