diff --git a/aliases.zsh b/aliases.zsh index 9981c99..84e92a3 100644 --- a/aliases.zsh +++ b/aliases.zsh @@ -1,8 +1,16 @@ +#! /bin/zsh + alias cdiff="colordiff" -[ -x "$(which gpg2)" ] && alias clean-gpg="for a in `gpg2 -k | sed -rn 's/pub +[a-z0-9]+\/(0x[0-9A-Fa-f]+).*/\1/p'`; do gpg2 --quiet --no-tty --edit-key $a clean save; done;" +function clean-gpg () { + [ -z "$(command -v gpg2)" ] && exit 1; + for key in $(gpg2 -k | sed -rn 's/pub +[a-z0-9]+\/(0x[0-9A-Fa-f]+).*/\1/p'); + do + gpg2 --quiet --no-tty --edit-key "$key" clean save + done +} -alias diff="diff -W $(( $(tput cols) - 2))" +alias diff="diff -W \$(( \$(tput cols) - 2))" alias bz2c='bzip2 --best' alias gzc='gzip --best --no-name' @@ -20,7 +28,8 @@ alias urlencode='python3 -c "import sys, urllib.parse as ul; [sys.stdout.write(u function mkcdir () { mkdir -p -- "$1" && - cd -P -- "$1" + cd -P -- "$1" || + exit 1 } function chrooted() { @@ -32,13 +41,19 @@ function chrooted() { else echo "We are chrooted." fi + + # shellcheck disable=SC2046 + # Word splitting *cannot* occur in a result of `test` return $(test "$ROOT_MP" -eq "$SHELL_MP") } if [ -x "$(which lsb_release)" ]; then - current_dist=`lsb_release -c -s` - all_dkms_packages="`apt-cache rdepends --installed dkms | sed -rn 's/^ +([^ ]+)$/\1/p' | sort -iu | tr '\n' ' '`" + current_dist="$(lsb_release -c -s)" + all_dkms_packages="$(apt-cache rdepends --installed dkms | sed -rn 's/^ +([^ ]+)$/\1/p' | sort -iu | tr '\n' ' ')" + + # shellcheck disable=SC2154,2086 + # both errors are irrelevant as we are part of a bigger infrastructure if [ $use_sudo -eq 1 ]; then alias aar='sudo apt-get --purge autoremove' diff --git a/browser.zsh b/browser.zsh index 716d506..fbafbbf 100644 --- a/browser.zsh +++ b/browser.zsh @@ -1,6 +1,9 @@ -function duckduck() { elinks -dump "https://duckduckgo.com/?q=`escape "$@"`"; } -function escape() { perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$@"; } -function google() { elinks -dump "https://www.google.de/search?q=`escape "$@"`"; } +#! /bin/zsh -function wetter() { curl --tr-encoding -H "Accept-Language: ${LANG%_*}" "https://wttr.in/$@"; } -function wetter2() { curl --tr-encoding -H "Accept-Language: ${LANG%_*}" "https://v2.wttr.in/$@"; } +function escape() { perl -MURI::Escape -e 'print uri_escape($ARGV[0]);' "$@"; } + +function duckduck() { elinks -dump "https://duckduckgo.com/?q=$(escape "$@")"; } +function google() { elinks -dump "https://www.google.de/search?q=$(escape "$@")"; } + +function wetter() { curl --tr-encoding -H "Accept-Language: ${LANG%_*}" "https://wttr.in/$*"; } +function wetter2() { curl --tr-encoding -H "Accept-Language: ${LANG%_*}" "https://v2.wttr.in/$*"; } diff --git a/exa.zsh b/exa.zsh index e9e1f16..3f36d49 100644 --- a/exa.zsh +++ b/exa.zsh @@ -1,3 +1,5 @@ +#! /bin/zsh + alias exa='exa -FHhg@ --git --time-style long-iso' alias exal='exa -l' function exat() { diff --git a/local-bin.zsh b/local-bin.zsh index 7738783..1769729 100644 --- a/local-bin.zsh +++ b/local-bin.zsh @@ -1,5 +1,6 @@ +#! /bin/zsh # Make sure we include this file only once -if [ -z $ZSH_LOCAL_BIN_ALREADY_SET ]; +if [ -z "$ZSH_LOCAL_BIN_ALREADY_SET" ]; then export ZSH_LOCAL_BIN_ALREADY_SET=1 # set PATH so it includes user's private bin if it exists