我想要在MinGW中快速切换到某目录
但从windows资源管理器中复制得到的路径是这种格式的 D:\xxx\xxx\xxx
所以需要手动把\
换成/
,比较麻烦
我做了一些事情
1.写了一个shell脚本叫chdir.sh
#!/bin/bash
read -r input
path=${input//\\//}
cd "$path"
2.在.profile文件中添加alias chdir = ". chdir.sh"
这样做后,只需要
1.输入chdir,回车
2.将复制的路径粘贴到shell中,回车
然后就能切换到目标路径了
现在有一个问题:
我想少打一个回车,就是将想要转换的路径做为参数传入shell脚本,但这样的话\
会被当做转义字符给弄没,所以想问一下有没有办法解决.
The parameters provided to the script will be processed by bash and then passed in,
It seems that there is no relevant escape switch in bash, so it seems that quotation marks can only be used~
What I have to say:
You can write an intermediate layer...
Read the input, process it, and transfer it to bash...