mcd() { [ $# = 1 ] && mkdir -p -- "$1" && cd -- "$1" } compdef _directories mcd ppgrep() { pgrep "$@" | xargs --no-run-if-empty ps fp } setgov() { GOVS=($(cpufreq-info -g)) if [ -z "$1" ] ; then cat </dev/null ; then virtualenv $default_name else python3 -m venv $default_name fi activate_virtualenv fi else . "$found_location" fi } edit-which() { command=$(which "$@") [ -x "$command" ] && $EDITOR "$command" } compdef edit-which=which which-package() { whence -p "$1" | xargs --no-run-if-empty apt-file search --fixed-string } compdef which-package=which ipinfo() { curl ipinfo.io/json } docker-images-clean() { docker images --format "table {{.ID}}\t{{.Repository}}\t{{.Tag}}\t{{.Size}}" | fzf --multi --header-lines=1 | awk '{print $1}' | xargs -r docker rmi -f } transfer() { curl --progress-bar --upload-file "$1" https://transfer.sh/$(basename "$1") | tee /dev/null; echo } web-bookmarks() { local bookmarks_path="$HOME/.config/chromium/Default/Bookmarks" local jq_script='def ancestors: while(. | length >= 2; del(.[-1,-2])); . as $in | paths(.url?) as $key | $in | getpath($key) | {name,url, path: [$key[0:-2] | ancestors as $a | $in | getpath($a) | .name?] | reverse | join("/") } | .path + "/" + .name + "\t" + .url' jq -r $jq_script < "$bookmarks_path" | sed -E $'s/(.*)\t(.*)/\\1\t\x1b[36m\\2\x1b[m/g' | fzf --ansi --multi | cut -d$'\t' -f2 | xargs xdg-open >/dev/null 2>&1 } vpn-up() { name="$1" nmcli connection up "$name" >/dev/null } vpn-down() { name="$1" if nmcli connection show "$name" | grep 'GENERAL.STATE' >/dev/null ; then nmcli connection down "$name" >/dev/null fi } vpn-toggle() { name="$1" if nmcli connection show "$name" | grep 'GENERAL.STATE' >/dev/null ; then vpn-down "$name" else for vpn in "WG Home" "wgDe" "riga.bobov.name" "bobov.name" ; do if [ "$name" != "$vpn" ] ; then vpn-down "$vpn" fi done vpn-up "$1" fi } # vim: ft=zsh :