zsh: organize various cd
functions
This commit is contained in:
parent
3da3d04120
commit
fe24674475
1 changed files with 17 additions and 18 deletions
35
.zshrc
35
.zshrc
|
@ -197,13 +197,28 @@
|
|||
fi
|
||||
}
|
||||
|
||||
# cd file: cd to the containing dir of a file or folder, given part of its name
|
||||
# cd to: cd to the containing dir of a file or folder, given part of its name
|
||||
# can take an `fd` command
|
||||
# requires that `fzy` is installed
|
||||
cdf() {
|
||||
cdt() {
|
||||
cd "$(dirname "$(fd $@ | fzy)")" && pwd
|
||||
}
|
||||
|
||||
# cd all: opens a new shell in each of the directories below the one you're in, so
|
||||
# you can execute commands in them until you type 'exit'
|
||||
# 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 like a macro
|
||||
# - 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)
|
||||
cda() {
|
||||
for DIR in *; do
|
||||
(cd "$DIR" && zsh)
|
||||
done
|
||||
}
|
||||
|
||||
# toggles whether a file or group of files is executable
|
||||
chx() {
|
||||
for FILE in "$@";do
|
||||
|
@ -293,22 +308,6 @@
|
|||
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
|
||||
error() {
|
||||
ERROR_CODE="$?"
|
||||
|
|
Loading…
Add table
Reference in a new issue