Adding cdfactor script.

db4
John Benediktsson 2009-06-01 11:20:49 -07:00
parent 71f9a4c2ae
commit e0df03bfb1
1 changed files with 18 additions and 0 deletions

18
misc/bash/cdfactor.sh Executable file
View File

@ -0,0 +1,18 @@
#!/bin/bash
# change directories to a factor module
function cdfactor {
code=$(printf "USING: io io.pathnames vocabs vocabs.loader ; "
printf "\"%s\" <vocab> vocab-source-path (normalize-path) print" $1)
echo $code > $HOME/.cdfactor
fn=$(factor $HOME/.cdfactor)
dn=$(dirname $fn)
echo $dn
if [ -z "$dn" ]; then
echo "Warning: directory '$1' not found" 1>&2
else
cd $dn
fi
}