From bd1bf49c6f0373559986a24130f63772b7001f92 Mon Sep 17 00:00:00 2001 From: "John Ankarstr\\xf6m" Date: Sun, 6 Jun 2021 14:13:33 +0200 Subject: ~/.shrc: Add 'go' function --- home/john/.shrc | 9 +++++++++ 1 file changed, 9 insertions(+) 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 -- cgit v1.2.3