# Extension for zsh that cd to a simulator data container of the app with the given bundle identifier. # # See blog post at https://skagedal.github.io/2018/01/02/simcd.html function simdir () { xcrun simctl get_app_container booted $1 data } function simcd () { cd `simdir $1` } function simpushd () { pushd `simdir $1` } function simopen() { open `simdir $1` } function _bundle_identifiers () { xcrun simctl listapps booted | plutil -convert json - -o - | ruby -r json -e 'puts JSON.parse(STDIN.read).keys' } _simdir() { local state _arguments \ '1: :->bundle_identifier'\ '*: :->rest' case $state in (bundle_identifier) _arguments '1:Bundle identifier:($(_bundle_identifiers))' ;; (*) compadd "$@" esac } compdef _simdir simdir simcd simpushd simopen