diff --git a/.config/zsh/plugins/alias.zsh b/.config/zsh/plugins/alias.zsh index d9981e2..8f467ef 100644 --- a/.config/zsh/plugins/alias.zsh +++ b/.config/zsh/plugins/alias.zsh @@ -43,6 +43,7 @@ alias l="${aliases[ls]:-ls} -lh --time-style=long-iso" alias ll="${aliases[l]} -A" alias cd..='cd ..' + alias cl='() { cd "$@" && ${aliases[ls]:-[ls]}' alias getclip="xclip -selection c -o" alias setclip="perl -pe 'chomp if eof' | xclip -selection c" alias pdf='launch evince' @@ -84,6 +85,22 @@ # List options and their value (on|off) line by line. This makes it a lot # easier to grep for activated options than using `setopt` and `unsetopt`. alias listopts='printf "%s %s\n" "${(kv)options[@]}"' + # Launch program independent and detached from shell. + alias launch='() { ${aliases[$1]:-$1} "${@[2,-1]}" &>/dev/null &| }' + # Create copy with .bkp extension + alias bkp='() { for f; do command cp -i "$f"{,.bkp}; done }' + # Reverse bkp() + alias unbkp='() { for f; do command cp -i "$f" "${f%.bkp}; done }' + # Grep in history file + alias histgrep='() { grep "$@" "${HISTFILE:-$HOME/.zsh_history}" }' + # URL-encode + alias urlenc='() { + python3 -c "from urllib import parse; print(parse.quote('$@'), end='') + }' + # URL-decode + alias urldec='() { + python3 -c "from urllib import parse; print(parse.unquote('$@'), end='') + }' # Named directories hash -d docs="$HOME"/Documents/ diff --git a/.config/zsh/plugins/functions.zsh b/.config/zsh/plugins/functions.zsh index c1683ba..20f1a52 100644 --- a/.config/zsh/plugins/functions.zsh +++ b/.config/zsh/plugins/functions.zsh @@ -1,32 +1,6 @@ ## Author: druckdev ## Created: 2019-08-28 -## change into dir and print accordingly -function cl() { - cd "$@" && ls -} - -## Copy file and append .bkp extension -function bkp() { - for file in "$@"; do - command cp -i "$file" "$file.bkp" - done -} - -unbkp() { - for file in "$@"; do - command cp -i "$file" "${file%.bkp}" - done -} - -## Launches program and detaches it from the shell -function launch() { - # eval "$@" ## does not work with special characters? - launch_command="$1" - shift - $launch_command "$@" &>/dev/null &| -} - ## Compares two pdfs based on the result of pdftotext function pdfdiff() { if [[ $# -eq 2 && -r "$1" && -r "$2" ]]; then @@ -304,19 +278,6 @@ function mangrep() { man -P "less -p \"^ *${pattern}\"" "$@" "${file}" } -## Grep in zsh history file -function histgrep() { - grep "$@" "${HISTFILE:-$HOME/.zsh_history}" -} - -function urlenc() { - python3 -c "from urllib import parse; print(parse.quote('$@'), end='')" -} - -function urldec() { - python3 -c "from urllib import parse; print(parse.unquote('$@'), end='')" -} - safe-remove() { [ $# -gt 0 ] || return 1 [ -e "$1" ] || return 1