zshrc: integrate fzf, fix errors, remove unused

- fzf was integrated for history, searching, killing, and scanmem
- unused python2 and battery aliases removed
- PgUp/PgDn "go all the way to the top/btm of history" removed (why does it exist?)
- fixed typos, linting
This commit is contained in:
Martin Sekera 2024-09-06 21:26:48 +02:00
parent 762059566f
commit ed0fcfac90

View file

@ -42,11 +42,10 @@ alias gitp="git push"
alias gitl="git log --graph --oneline --decorate --all"
alias gitd="git diff --word-diff"
alias Y="noglob yt-dlp --no-mtime --add-metadata --embed-subs -f 'bestvideo[height<=1080]+bestaudio/best[height<=1080]'"
alias Ymkv="Y-no-container --merge-output-format mkv --remux-video mkv"
alias Ymp4="Y-no-container --merge-output-format mp4 --remux-video mp4"
alias Ymkv="Y -no-container --merge-output-format mkv --remux-video mkv"
alias Ymp4="Y -no-container --merge-output-format mp4 --remux-video mp4"
alias Ysound="noglob yt-dlp --no-mtime -f bestaudio --remux-video opus"
alias battery="upower -i /org/freedesktop/UPower/devices/battery_BAT0"
alias pp=python2
alias p=python
alias ppp=python3
alias Ju="journalctl --unit"
alias Jue="journalctl --pager-end --unit"
@ -85,41 +84,62 @@ mkcd () {
mkdir -p "$1" && cd "$1"
}
psg () { ps axu | grep -v grep | grep -i $* } # hledání v běžících procesech
psg () { ps axu | grep -v grep | grep -i $* }
pskill () {
pids=($(psg $1|awk '{print $2}'))
for pid in $pids; do
echo "Killing $pid..."
kill $pid
done
}
psm () {
pid=(${=$(psg $1|grep -o --color=no -E "[0-9]+")})
echo "Found pid=${pid[1]}."
scanmem -p ${pid[1]}
# ╭─────────────────────────────────────╮
# │ ❤️ FZF ❤️ config and integrations │
# ╰─────────────────────────────────────╯
# don't follow symlinks due to Wine's love for symlink loops (dosdevices/z: -> /)
export FZF_DEFAULT_OPTS='--walker=file,dir,hidden --preview "bat --style=plain" --bind alt-a:select-all'
source <(fzf --zsh)
# Helix and Neovim launchers
alias hf='fzf -m --bind "enter:become(hx {+})"'
alias nf='fzf -m --bind "enter:become(nvim {+})"'
# get one or more PIDs using fzf
function p_pids {
ps -eo user,pid,ppid,start,time,command | fzf -m --header-lines=1 --no-preview --wrap | awk '{print $2}'
}
zres () {
# p_kill is not necessary, you can just kill -SIGNAL **<tab>
# attach scanmem to a PID
function p_scanmem {
pids=($(p_pids))
scanmem -p ${pids[1]}
}
function zres {
. /etc/zsh/zshrc
[[ -f ~/.zshrc ]] && . ~/.zshrc
hash -r
}
http-dir () {
function http-dir {
echo "Serving $PWD on 0.0.0.0:55555"
python3 -m http.server 55555
}
function failed_whike () {
function failed_while {
echo "failed while ${1}"
exit 1
}
# loop-shell COMMAND creates a shell that takes user_input and runs COMMAND user_input
# e.g. "loop-shell grep -ri" creates a grepping shell
# `loop-shell COMMAND` creates a shell that takes user_input and runs COMMAND user_input
# e.g. `loop-shell grep -ri` creates a grepping shell
function loop-shell {
while true
do
@ -183,12 +203,9 @@ bindkey "\e[1~" beginning-of-line # Home
bindkey "\e[H" beginning-of-line # Home
bindkey "\e[4~" end-of-line # End
bindkey "\e[F" end-of-line # End
bindkey "\e[5~" beginning-of-history # PgUp
bindkey "\e[6~" end-of-history # PgDn
bindkey "\e[1;5D" backward-word # Ctrl ←
bindkey "\e[1;5C" forward-word # Ctrl →
# load syntax highlighting if available; Gentoo and Arch paths are tried
for HPATH in "/usr/share/zsh/site-functions/zsh-syntax-highlighting.zsh" "/usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
do