Move zsh config to ~/.config
This commit is contained in:
35
.config/zsh/functions/extract
Normal file
35
.config/zsh/functions/extract
Normal file
@ -0,0 +1,35 @@
|
||||
function extract() {
|
||||
if [ -z "$1" ]; then
|
||||
# display usage if no parameters given
|
||||
echo "Usage: extract <path/file_name>.<zip|rar|bz2|gz|tar|tbz2|tgz|Z|7z|xz|ex|tar.bz2|tar.gz|tar.xz>"
|
||||
echo " extract <path/file_name_1.ext> [path/file_name_2.ext] [path/file_name_3.ext]"
|
||||
return 1
|
||||
else
|
||||
for n in $@
|
||||
do
|
||||
if [ -f "$n" ] ; then
|
||||
case "${n%,}" in
|
||||
*.tar.bz2|*.tar.gz|*.tar.xz|*.tbz2|*.tgz|*.txz|*.tar)
|
||||
tar xvf "$n" ;;
|
||||
*.lzma) unlzma ./"$n" ;;
|
||||
*.bz2) bunzip2 ./"$n" ;;
|
||||
*.rar) unrar x -ad ./"$n" ;;
|
||||
*.gz) gunzip ./"$n" ;;
|
||||
*.zip) unzip ./"$n" ;;
|
||||
*.z) uncompress ./"$n" ;;
|
||||
*.7z|*.arj|*.cab|*.chm|*.deb|*.dmg|*.iso|*.lzh|*.msi|*.rpm|*.udf|*.wim|*.xar)
|
||||
7z x ./"$n" ;;
|
||||
*.xz) unxz ./"$n" ;;
|
||||
*.exe) cabextract ./"$n" ;;
|
||||
*)
|
||||
echo "extract: '$n' - unknown archive method"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "'$n' - file does not exist"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
29
.config/zsh/functions/tmix
Normal file
29
.config/zsh/functions/tmix
Normal file
@ -0,0 +1,29 @@
|
||||
function tmix () {
|
||||
set -o shwordsplit
|
||||
|
||||
SESSION="${TMIX_SESSION:-TMIX}"
|
||||
SERVERS="${TMIX_SERVERS}"
|
||||
|
||||
if [[ $1 == "kill" ]]; then
|
||||
echo "Killing tmux session $SESSION"
|
||||
tmux kill-session -t "${SESSION}"
|
||||
else
|
||||
if [ -z "$SERVERS" ]; then
|
||||
# display usage if no parameters given
|
||||
echo "Usage: tmix"
|
||||
echo "No servers configured. define them as TMIX_SERVERS=\"<SERVER> <SERVER> <SERVER>\" e.g. in ${ZDOTDIR}/lib/30-extras.zsh"
|
||||
else
|
||||
echo "Creating tmux session $SESSION"
|
||||
tmux new-session -d -s "${SESSION}"
|
||||
|
||||
create_session=$?
|
||||
if [[ $create_session = 0 ]]; then
|
||||
for SERVER in ${SERVERS}; do
|
||||
echo ">>> Connecting to ${SERVER}"
|
||||
tmux new-window -n ${SERVER} -t ${SESSION}:
|
||||
tmux send-keys -t ${SESSION}:${SERVER} "mosh ${SERVER} -- doas tmux a -d" C-m
|
||||
done
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
Reference in New Issue
Block a user