我想運行命令「showfiles」,它將運行命令「defaults write com.apple.finder AppleShowAllFiles TRUE」和「killall Finder」我該如何去做這件事?bash_profile多行別名
2
A
回答
3
有這樣做的幾種方法...
選項1:
寫一個腳本程序在你的〜/ bin目錄
echo "defaults write com.apple.finder AppleShowAllFiles TRUE" > ~/bin/showfiles
echo "killall Finder" >> ~/bin/showfiles
chmod +x ~/bin/showfiles
選項2:
創建帶AND的別名一起加入命令:
alias showfiles='defaults write com.apple.finder AppleShowAllFiles TRUE && killall Finder'
注意:如果第一個命令成功,它將只運行第二個命令。
1
- 將兩個語句到一個文件,一個在每一行,並保存該文件作爲showfiles
- 運行
chmod 755 showfiles
。 - 要執行的文件運行
./showfiles
如果你不想做./每次,然後將showfiles到路徑中的任何目錄(您可以通過執行echo $PATH
看到)。
+1
不要忘了家當...... –
3
我不知道爲什麼建議&&
選項@gahooa是行不通的,但有另一種選擇:創建一個shell功能:
showfiles() {
defaults write com.apple.finder AppleShowAllFiles TRUE
killall Finder
}
+0
嘿,這是一個很棒的提示。 – gahooa
相關問題
- 1. bash_profile別名 - 用PWD打開Coda
- 2. 命令行bash_profile
- 3. 選擇多行別名
- 4. 解析.bash_profile中的Cygwin或Unix別名命令
- 5. 創造的.bash_profile別名爲獲得WordPress的
- 6. 如何在bash_profile別名中包含exit命令?
- 7. 將git別名添加到.bash_profile不起作用
- 8. 在同一行別名多個名稱
- 9. 多個別名
- 10. 在不使用bashrc或bash_profile或bash_aliases的終端會話中激活別名?
- 11. RVM和bash_profile
- 12. python .bash_profile alias
- 13. Rails和.bash_profile中
- 14. Bash_profile代碼
- 15. 作業運行時,PBS(扭矩)調度程序不會從.bash_profile加載我的別名?
- 16. 運行.bash_profile出現問題的原因
- 17. 執行.bash_profile後無法連接到Oracle
- 18. 關於〜/ .bash_profile中的類似出口行
- 19. 獲取多級別的類別名稱
- 20. 默認情況下,rails會使用哪個shell(因爲它不能識別我的〜/ .bash_profile別名)
- 21. 表的多個別名
- 22. msysgit多命令別名
- 23. 多次別名方法
- 24. Sybase表的多個別名?
- 25. 調用多個Bash別名
- 26. HTML多個Javascript別名
- 27. 類型別名多性狀
- 28. 多列排序的別名
- 29. 別名的多態關聯名稱
- 30. 無法獲取〜/ .bash_profile
我嘗試了選項2,但OS X不喜歡「&&」我不想創建一個腳本,所以有另一種方法來創建一個別名?我會創建一個腳本,如果我必須但是... – daviesgeek
選項2爲我工作,我再次嘗試,並且在showfiles =和第一個之間有一個空格。謝謝! – daviesgeek