dotwryn/zsh/alias

57 lines
1.7 KiB
Plaintext
Raw Normal View History

2021-09-16 20:55:50 +00:00
#!/bin/zsh
#####################################################################
2021-09-16 20:55:50 +00:00
alias pd='pushd'
alias qd='popd'
alias lsd='dirs'
2021-09-16 20:55:50 +00:00
alias pdo='pwd | xclip' # [p]aste [d]irectory [o]n clipboard
alias cdo='cd $(xclip -o)' # [c]hange to [d]irectory [o]n clipboard
2021-09-16 20:55:50 +00:00
alias restart='clear; source ~/.zshrc'
2021-09-17 01:42:11 +00:00
alias fix='vim $(git diff --name-only | uniq) -p'
2023-09-05 16:40:47 +00:00
#####################################################################
w() { # fancy(?) version of "alias w='watch -tcn1 '"
local WATCH_ARGS=()
WATCH_ARGS+=(--no-title)
WATCH_ARGS+=(--color)
WATCH_ARGS+=(--interval 1)
# don't add delay if command is available to /bin/sh
/bin/sh -c "command -v $1" >/dev/null 2>&1 && {
watch ${WATCH_ARGS[@]} $@
return $?
}
# quickly reduce first-order aliases
alias $1 >/dev/null 2>&1 && {
watch ${WATCH_ARGS[@]} $(which $1 | sed 's/.*aliased to //') ${@:2}
return $?
}
# import zshrc and inject current environment
watch ${WATCH_ARGS[@]} "zsh -c 'source ~/.zshrc >/dev/null 2>&1; $(while read e; do printf 'export '; printf '%q ' "$e"; echo; done < <(env) | grep '='); echo \" $@\n---------------------------------------------------- \$(date +%H:%m:%S)\"; $@'"
}
2022-11-06 18:05:11 +00:00
#####################################################################
2022-04-20 18:59:45 +00:00
2022-11-28 23:01:50 +00:00
command -v bat >/dev/null 2>&1 \
&& alias cat='bat --style="plain"'
command -v startplasma-x11 >/dev/null 2>&1 \
&& alias startk="startx '$DOTWRYN/config/xinitrc.kde'"
command -v i3 >/dev/null 2>&1 \
&& alias starti="startx '$DOTWRYN/config/xinitrc.i3'"
2021-09-17 01:40:59 +00:00
#####################################################################
2021-09-17 01:40:59 +00:00
alias erg='EDIT_RIPGREP_FILE_MATCHES'
EDIT_RIPGREP_FILE_MATCHES() { $EDITOR $(rg --color=never -l $@); }
2022-11-28 23:01:50 +00:00
#####################################################################