初用苹果机,各种不习惯。幸好和Linux有几分相似。但是操作上差别就大了去了。因为经常需要操作隐藏文件,又不想整天看到一大堆带点的文件,所 以写了个小脚本,无聊之作,勿喷。用的还是bash。我感觉应该有办法做个直接点击就能进行互相切换的操作,比如给finder加个什么操作?下次研究出 来了再说。先放代码:

#!/bin/bash
# hideshow.sh
if [ $# -lt 1 ];then
    echo "usage hideshow.sh hide|show"
    exit
fi
case $1 in
show)
    if [ `defaults read com.apple.finder AppleShowAllFiles` = "1" ];then
        echo "Hide files already been shown, did nothing!"
        exit
    else
        defaults write com.apple.finder AppleShowAllFiles -bool true
        killall Finder
        exit
    fi
    ;;
hide)
    if [ `defaults read com.apple.finder AppleShowAllFiles` = "0" ];then
        echo "Dot Files already been hided, did nothing!"
        exit
    else
        defaults write com.apple.finder AppleShowAllFiles -bool false
        killall Finder
        exit
    fi
    ;;
*)
    echo "usage hideshow.sh hide|show"
    ;;
esac