From ed1176993c4430e75dab13f1e5fe0b36fcb76c14 Mon Sep 17 00:00:00 2001 From: don philipe Date: Mon, 30 Sep 2024 20:44:39 +0200 Subject: [PATCH] Add bunch of functions to zsh --- .zsh-custom/functions.zsh | 67 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .zsh-custom/functions.zsh diff --git a/.zsh-custom/functions.zsh b/.zsh-custom/functions.zsh new file mode 100644 index 0000000..224e35b --- /dev/null +++ b/.zsh-custom/functions.zsh @@ -0,0 +1,67 @@ +# start/attach tmux session +# use function in .zshrc to attach at every login +autotmux() +{ + if [ -z "$TMUX" ]; then + # get the id of a deattached session + ID="`tmux ls | grep -vm1 attached | cut -d: -f1`" + if [ -z "$ID" ]; then + tmux new-session + else + tmux attach-session -t "$ID" + fi + fi +} + +checkpem() +{ + openssl x509 -in "$1" -noout -text +} +checkcert() +{ + openssl s_client -connect "$1":443 2>/dev/null +} + +# works only without tex-ending +tex2pdf() +{ + pdflatex "$1" + bibtex "$1" + pdflatex "$1" + pdflatex "$1" +} + +startx() +{ + nohup startx "$@" > /dev/null 2>&1 & + disown + vlock +} + +# generate qrcode and display it +qrcode() +{ + qrencode "$1" -o - | feh - +} + +ogg2mp3() +{ + for file in *ogg; do + ffmpeg -i $file -b:a 192k -map_metadata 0:s:a:0 "${file%.*}.mp3" + done +} +m4a2mp3() +{ + for file in *m4a; do + ffmpeg -i $file -b:a 192k -map_metadata 0:s:a:0 "${file%.*}.mp3" + done +} + +# show the current mode: +#PR_VIMODE="#" +#function zle-keymap-select +#{ +# PR_VIMODE="${${KEYMAP/vicmd/¢}/(main|viins)/$}" +# zle reset-prompt +#} +#zle -N zle-keymap-select