Ubunut 16.04默認使用nautilus進行管理資源文件夾,nautilus默認是支持參數傳遞的。
使用:
nautilus /dirurl
打開當前文件夾(可以使用$PWD代替):
nautilus "$(pwd)"
封裝:
#新建文件
sudo vim /usr/bin/opendir
#寫入如下內容
nautilus "$(pwd)" >/dev/null 2>&1
#修改權限
sudo chmod +x /usr/bin/opendir
使用:
再升級一下,支持參數傳遞:
if [ -n "$1" ]; then nautilus "$1" >/dev/null 2>&1 else nautilus "$(pwd)" >/dev/null 2>&1 fi
使用:
參考:
http://caogaoyang.blog.163.com/blog/static/422173012011111705743103/
http://www.jb51.net/article/34332.htm(Shell腳本if else知識)