#!/bin/zsh vmp() { col -b | \ vim -MR \ -c 'set ft=man nolist nonu nornu' } vimh() { vim -c "help $1" -c 'call feedkeys("\o")' } nnn() { test -z "$NNNLVL" && /usr/bin/nnn "$@" || exit } ranger() { test -z "$RANGER_LEVEL" && /usr/bin/ranger "$@" || exit } # googoo o () { f="$(fhome f ${1:-$HOME} | fzf)" test "$1" && shift test -n "$f" && $EDITOR $@ "$f" } go () { d="$(fhome d ${1:-$HOME} | fzf)" test -d "$d" && cd "$d" } ogo () { d="$(fhome f ${1:-$HOME} | fzf | xargs dirname)" test -d "$d" && cd "$d" } ipc () { if [[ "$(ip link show eno1 | awk -F, 'NR=1 {print $3}')" == "UP" ]] then doas ip link set eno1 down else doas ip link set eno1 up fi } calc () { echo "$@" | bc -l } unique () { f="/tmp/$(uuidgen)" awk '!x[$0]++' "$1" > "$f" mv "$f" "$1" } clip () { echo -n "$@" | xclip -selection clipboard -rmlastnl } fzh () { choice="$(tac $HOME/.config/zsh/histfile | fzf)" test -z "${choice}" && return echo "${choice}" >> "${HOME}/.config/zsh/histfile" eval "${choice}" } unzipp () { file=$1 shift unzip $file $@ || exit 1 rm $file } # fix long waiting time __git_files () { _wanted files expl 'local files' _files } esc () { $EDITOR "$(which $1)" } delfile () { curl "https://upfast.craftmenners.men/delete/$1" } upfile () { curl -F "file=@\"$1\"" "https://upfast.craftmenners.men" } sgd () { for dir in ${1:-$HOME/src/*} do cd $dir if [ "$(git status --short 2>/dev/null | grep -v "??" | head -1)" ] then # There are changes, and this is a git repo echo "$PWD \e[1;31m*changes\e[0m" git fetch > /dev/null 2>&1 fi test "$(parse_git_remote)" && echo "$PWD \e[0;32m*push/pull\e[0m" done }