私が書いたいbashのヘルプを使うことができます。スクリプトの目的は、複数のプロジェクトを作業するときに開発をスピードアップすることです。コードで気になる部分を表示しておきました。
# is there a way to persist this through working enviornments besides this?
declare -x WORKING=`cat ~/.working`
#alias p='builtin cd $WORKING && pwd && ls'
alias pj='builtin cd $WORKING/public/javascripts && pwd && ls'
function pp {
echo `pwd` > ~/.working
}
# is there a way to close the scope of this function?
function p {
# how do I process flags here?
# -f and -d etc. can exist but may not
# either way I want $1 to be set to the first string if there
# is one
if [ -z "$1" ]
then
echo '*'
builtin cd $WORKING && pwd && ls
return
fi
BACK=`pwd`
builtin cd $WORKING
#f=`find . -iname "$1"`
f=( `echo $(find . -type d -o -type f -iname "$1") | grep -v -E "git|node"` )
#echo ${f[1]}
if [ -z "${f[0]}" ]
then
return
fi
if [ -z "${f[1]}" ]
then
# how can I write this as a switch?
if [ -f ${f[0]} ]
then
vim ${f[0]}
return
fi
if [ -d ${f[0]} ]
then
builtin cd ${f[0]}
return
fi
else
echo "multiple found"
#for path in $f
#do
# sort files and dirs
# sort dirs by path
# sort files by path
#done
# display dirs one color
# display files another color
# offer choices
# 1) open all files
# 2) open a file
# 3) cd to selected directory
# 4) do nothing
fi
# nothing found
builtin $BACK
}
ベストアンサー1
# is there a way to persist this through working enviornments besides this?
declare -x WORKING=`cat ~/.working`
おそらく次のものを使用できます。
export WORKING=$(cat ~/.working)
再起動するまで環境に追加する必要があります。
後で以下を使用して参照できます。
echo $WORKING
プロンプトで。