这段代码只是在“ cd”后面添加一行。./../../d/work _ space _ for _ my _ company/project/code _ source”转到名为“。巴希尔”。如果文件不存在,“ > >”将创建一个文件,然后附加。那个。Bashrc 文件对于在启动/登录时运行命令非常有用(例如,加载模块等)
#!/bin/bash
ppath="/d/-projects/-github"
cd $ppath
unset PROJECTS
PROJECTS+=(".")
i=0
echo
echo -e "projects:\n-------------"
for f in *
do
if [ -d "$f" ]
then
PROJECTS+=("$f")
echo -e $((++i)) "- \e[1m$f\e[0m"
fi
done
if [ ${#PROJECTS[@]} -gt 1 ]
then
echo -ne "\nchoose project: "
read proj
case "$proj" in
[0-`expr ${#PROJECTS[@]} - 1`]) cd "${PROJECTS[proj]}" ;;
*) echo " wrong choice" ;;
esac
else
echo "there is no projects"
fi
unset PROJECTS
当我将工作目录的 cd 放入 ~/. bashrc 时,Windows 上的 Git Bash 快捷方式出现了问题
WARNING: Found ~/.bashrc but no ~/.bash_profile, ~/.bash_login or ~/.profile.
This looks like an incorrect setup.
A ~/.bash_profile that loads ~/.bashrc will be created for you.
所以 git 创建了这个.bash _ profile:
$ cat ~/.bash_profile
# generated by Git for Windows
test -f ~/.profile && . ~/.profile
test -f ~/.bashrc && . ~/.bashrc