gcd reprogrammed

This commit is contained in:
ville rantanen
2014-07-19 21:34:28 +03:00
parent 90e2242a06
commit ae80789ad1

View File

@@ -168,33 +168,7 @@ function whenfilechanges() {
}
function gcd() {
# guess cd, find first match in folder
local dname
local bname
local match
local join
set -o pipefail
join="$@"
join=${join// /.}
dname=$( dirname "$join" )
bname=$( basename "$join" )
match=$( ls -d "$dname"/*/ | grep "$bname" | head -n 1 )
[[ ! "$match" = "" ]] && {
echo $match | grep --color=always "$bname"
\cd "$match"
return
}
match=$( ls -d "$dname"/*/ | grep -i "$bname" | head -n 1 )
[[ ! "$match" = "" ]] && {
echo $match | grep -i --color=always "$bname"
\cd "$match"
return
}
echo No match.
}
function fcd() {
# gcd future fork
# guess cd, find first match in folder, or ask if multiple hits
local cdto
{ cdto=$( python -c '
import sys,os,re
@@ -266,7 +240,6 @@ except ValueError,IndexError:
sys.exit(1)
sys.stderr.write(os.path.join(pat_dir,key_match))
' "$@" 2>&1 1>&$out); } {out}>&1 ; \cd "$cdto"
}
function rmv () {