函数会创建一个文件夹,但如果存在,请不要将其CD到该文件夹中
以下是我在.zshrc
配置文件中添加的函数,以创建Notes文件夹,如果该文件不存在,并且如果存在该文件夹,则必须将其CD cd到该文件夹。
function mnotes(){
if [ ! -d ~/Desktop/Notes ];then
mkdir ~/Desktop/Notes
else
cd ~/Desktop/Notes
}
我设置了一个别名如下:
alias notes=mnotes
在采购.zshrc
文件之后。并键入命令注释,它将创建Notes文件夹,但如果存在文件夹,则不会CD
中。
在存在文件夹时运行脚本时的错误映像:
Following is the function I have added in the .zshrc
configuration file to create a Notes folder if it does not exist and if the folder exists it has to cd to that folder.
function mnotes(){
if [ ! -d ~/Desktop/Notes ];then
mkdir ~/Desktop/Notes
else
cd ~/Desktop/Notes
}
I have set an alias as follows:
alias notes=mnotes
After sourcing the .zshrc
file. and typing the command notes, it will create the notes folder, but doesn't cd
into it if the folder exists.
Error Image while running the script when the folder is present:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您忘了添加FI以结束说明:
You forgot to add the fi to end close the statement: