Skip to content

Instantly share code, notes, and snippets.

@amekusa
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save amekusa/530eb2839f2d25160e62 to your computer and use it in GitHub Desktop.

Select an option

Save amekusa/530eb2839f2d25160e62 to your computer and use it in GitHub Desktop.
OS X Commandline Utilities

OS X Commandline Utilities

Commands

app [Application Name]

Launches the application.

finder_shows_all

Select whether Finder shows hidden files and directories.

safari_detects_enc

Select whether Safari detects encoding automatically.

clear_kotoeri_dict

Clear Kotoeri learnings.

#!/bin/bash
function app {
open "/Applications/${1}.app"
}
function clear_kotoeri_dict {
read -p "Do you want to clear Kotoeri learnings? [Y/N]:" answer
case $answer in
[Yy] )
local dict="${HOME}/Library/Preferences/com.apple.JapaneseAnalysis/LearningDictionary.dict"
if [ ! -e $dict ]; then
echo "No learning data."
return 0
fi
read -p "Backup? [Y/N]:" answer2
case $answer2 in
[Yy] )
local backup="${dict}.$(date +%Y-%m-%d)"
if [ -e $backup ]; then
rm -f $backup
fi
mv $dict $backup
echo "Backed up and Cleared.";;
* )
rm $dict
echo "Cleared.";;
esac
;;
* ) echo "Aborted.";;
esac
}
function finder_shows_all {
read -p "Do you want Finder to show all files? [Y/N]:" answer
case $answer in
[Yy] ) defaults write com.apple.finder AppleShowAllFiles YES; killall Finder /System/Library/CoreServices/Finder.app;;
[Nn] ) defaults write com.apple.finder AppleShowAllFiles NO; killall Finder /System/Library/CoreServices/Finder.app;;
* ) echo "Aborted.";;
esac
}
function safari_detects_enc {
read -p "Do you want Safari to detect encoding? [Y/N/D]:" answer
case $answer in
[Yy] ) defaults write com.apple.Safari WebKitUsesEncodingDetector -bool yes;;
[Nn] ) defaults write com.apple.Safari WebKitUsesEncodingDetector -bool no;;
[Dd] ) defaults delete com.apple.Safari WebKitUsesEncodingDetector;;
* ) echo "Aborted.";;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment