diff options
author | John Ankarstr\xf6m <john@ankarstrom.se> | 2021-06-06 14:13:33 +0200 |
---|---|---|
committer | John Ankarstr\xf6m <john@ankarstrom.se> | 2021-06-06 14:13:33 +0200 |
commit | bd1bf49c6f0373559986a24130f63772b7001f92 (patch) | |
tree | 6db5856ab890209e14eb0b5e8131c1a416e9334c /home | |
parent | 9b84f8d96519ec49a3f7d087f88aeb6ee830b9e9 (diff) | |
download | lbsd-bd1bf49c6f0373559986a24130f63772b7001f92.tar.gz |
~/.shrc: Add 'go' function
Diffstat (limited to 'home')
-rw-r--r-- | home/john/.shrc | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/home/john/.shrc b/home/john/.shrc index 4102b36..39e9dba 100644 --- a/home/john/.shrc +++ b/home/john/.shrc @@ -15,5 +15,14 @@ case "$-" in *i*) noice -p "$@" >$f && cd "$(cat $f)" rm $f } + go() { + [ -z "$1" ] && { echo usage: $0 [cmd ...] name 2>&1; return 1; } + eval name=\$$# + r=`find . -name "$name" -print -exit` + [ -z "$r" ] && { echo "$name" not found 2>&1; return 1; } + [ -f "$r" ] && name="$(dirname "$r")" + cd "$name" && + { [ $# -eq 1 ] && return; BASH_COMMAND=$* cmdtitle 2>&-; "$@"; } + } ;; esac |