zsh: possible new feature: remove invalid aliases
This commit is contained in:
parent
c65266da35
commit
45c511e337
1 changed files with 49 additions and 15 deletions
40
.zshrc
40
.zshrc
|
@ -49,7 +49,9 @@
|
||||||
{
|
{
|
||||||
## Short hand programs (ex: sc = shellcheck) >>>
|
## Short hand programs (ex: sc = shellcheck) >>>
|
||||||
# use nvim rather than vim if the command exists
|
# use nvim rather than vim if the command exists
|
||||||
[ -x "$(command -v nvim)" ] && alias vim='nvim' vimdiff='nvim -d'
|
alias \
|
||||||
|
vim='nvim' \
|
||||||
|
vimdiff='nvim -d'
|
||||||
|
|
||||||
alias \
|
alias \
|
||||||
vv="$EDITOR" \
|
vv="$EDITOR" \
|
||||||
|
@ -60,8 +62,8 @@
|
||||||
alias :q='exit' \
|
alias :q='exit' \
|
||||||
q='exit' \
|
q='exit' \
|
||||||
|
|
||||||
alias vim=nvim
|
|
||||||
alias sc=shellcheck
|
alias sc=shellcheck
|
||||||
|
|
||||||
# rmdir is long
|
# rmdir is long
|
||||||
alias \
|
alias \
|
||||||
rmd='rmdir' \
|
rmd='rmdir' \
|
||||||
|
@ -164,6 +166,22 @@
|
||||||
# <<<
|
# <<<
|
||||||
# optionally source an external alias file
|
# optionally source an external alias file
|
||||||
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc"
|
[ -f "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc" ] && source "${XDG_CONFIG_HOME:-$HOME/.config}/shell/aliasrc"
|
||||||
|
|
||||||
|
# # TODO: remove all aliases that refrence programs which do not exist >>>
|
||||||
|
# validate_alias() {
|
||||||
|
# # check if the alias points to an alias
|
||||||
|
# if alias "$(alias lsd | grep -Po "(?<=').*(?=')")"; then
|
||||||
|
# :
|
||||||
|
# else
|
||||||
|
# # see if the thing the alias points to is an executable
|
||||||
|
# test -x "$(command -V "$1" | grep -Po "(?<=$1 is )/.*$")"
|
||||||
|
# fi
|
||||||
|
# }
|
||||||
|
# for ALIAS in $(alias | cut -d = -f 1);do
|
||||||
|
# validate_alias "$ALIAS" &&
|
||||||
|
# unalias "$ALIAS" &&
|
||||||
|
# echo "alias $ALIAS was removed"
|
||||||
|
# done # <<<
|
||||||
}
|
}
|
||||||
# <<<
|
# <<<
|
||||||
### Functions >>>
|
### Functions >>>
|
||||||
|
@ -179,7 +197,7 @@
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# cd file: cd to the containing dir of a file, given part of its name
|
# cd file: cd to the containing dir of a file or folder, given part of its name
|
||||||
# can take an `fd` command
|
# can take an `fd` command
|
||||||
# requires that `fzy` is installed
|
# requires that `fzy` is installed
|
||||||
cdf() {
|
cdf() {
|
||||||
|
@ -275,6 +293,22 @@
|
||||||
echo "$FILEPATH" | grep -o 'site.*' | sed 's+^site+https://blakenorth.net+g'
|
echo "$FILEPATH" | grep -o 'site.*' | sed 's+^site+https://blakenorth.net+g'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Opens a subshell in each of the directories below the one you're in, so
|
||||||
|
# you can execute commands in them
|
||||||
|
# If I use this enough, I may make something that can do more
|
||||||
|
# Ideas for what it could do in the future:
|
||||||
|
# - somehow record typed commands so they can be automatically repeated
|
||||||
|
# - maybe get the length of the histfile before and after, executing the
|
||||||
|
# last X number of commands
|
||||||
|
# - Maybe just add an argument that takes a command and executes it in all dirs
|
||||||
|
# (although that wouldn't be as good as recording actions bc it's easy to do
|
||||||
|
# that by just writing a for loop)
|
||||||
|
foreachdir() {
|
||||||
|
for DIR in *; do
|
||||||
|
(cd "$DIR" && zsh)
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
# for sending error messages from functions and whatnot
|
# for sending error messages from functions and whatnot
|
||||||
error() {
|
error() {
|
||||||
ERROR_CODE="$?"
|
ERROR_CODE="$?"
|
||||||
|
|
Loading…
Add table
Reference in a new issue