zsh: realized some things need to be functions
By that, I mean things that change my working directory need to be functions
This commit is contained in:
parent
cba8e92e1d
commit
06ab216290
11 changed files with 93 additions and 94 deletions
20
.config/shell/functions/cds
Normal file
20
.config/shell/functions/cds
Normal file
|
@ -0,0 +1,20 @@
|
|||
#!/bin/bash
|
||||
|
||||
# cd search: cd to a directory, given part of its name
|
||||
# (also can take arguments for an `fd` commnd)
|
||||
# (also can cd to a file if `-t f` is passed)
|
||||
|
||||
cds() {
|
||||
if ! [ -z "$1" ];then
|
||||
DIR="$(fd --max-results=1 -t d $@)"
|
||||
if [ -f "$DIR" ];then
|
||||
cd "$(dirname "$DIR")" && pwd
|
||||
else
|
||||
cd "$DIR" && pwd
|
||||
fi
|
||||
else
|
||||
echo "$0: no arguments provided"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue