Specific to OS X only
$ killall gpg-agent
# or
$ gpgconf --kill gpg-agent
$ chmod +x script.sh
# python2
$ python -m SimpleHTTPServer 8000
# python3
$ python3 -m http.server
# alias
alias http="python -m SimpleHTTPServer 8000"
# check current config and print config path
$ nginx -t
# update the config
$ open /usr/local/etc/nginx/
# run
$ nginx
# stop
$ nginx -s stop
# restart
$ nginx -s reload
# substitute and print to stdout
$ sed -e 's/one/first/g' test-file.txt
# substitute in place with backup
$ sed -i '.backup' -e 's/one/first/g' test-file.txt
# substitute in place without backup
$ sed -i '' -e 's/another/next/g' test-file.txt
# count lines of code for jsx files in current folder
$ wc -l `find . -type f -name "*.jsx" | sort -n`
# count lines of code for jsx and css files in current folder
$ wc -l `find . -type f -name "*.jsx" -or -name "*.css" | sort -n`
# count lines of code for tsx files in src folder
$ wc -l `find ./src -type f -name "*.tsx" | sort -n`
# count tsx or ts files, excluding *.test.ts and .test.tsx, sort by LOC
$ wc -l `find ./src -type f '(' -name "*.tsx" -or -name "*.ts" ')' -not '(' -name "*.test.ts" -or -name ".test.tsx" ')'` | sort -n
# alias
alias wct=$'wc -l `find ./src -type f -name "*.tsx" | sort -n`'
# prune remote-tracking branches no longer on remote
$ git fetch --prune
# print local branches that are not found on remote
$ git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}'
# remove local branches that are not found on remote
$ git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -d
#alias
alias gfp="git fetch --prune"
alias gcz="git cz"
alias grm=$'git branch -r | awk \'{print $1}\' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk \'{print $1}\' | xargs git branch -d'
$ git checkout origin/master filename
$ git ls-tree -r --name-only HEAD | while read filename; do echo "$(git log -1 --format="%ai" -- $filename) $filename"; done | sort
# list devices with identifiers
$ ~/Library/Android/sdk/emulator/emulator -list-avds
# run in background
$ ~/Library/Android/sdk/emulator/emulator -avd Pixel_2_API_28 &
$ alias android="~/Library/Android/sdk/emulator/emulator -avd Pixel_2_API_28 &"
# list devices with identifiers
$ instruments -s devices
# start Simulator
$ open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/
$ alias ios="open /Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/"
$ sudo lsof -iTCP -sTCP:LISTEN -n -P
$ sudo lsof -i -P -n | grep LISTEN
$ tar -tvf archive.tar
# check
$ find . -name "node_modules" -type d -prune | xargs du -chs
# remove
$ find . -name "node_modules" -type d -prune -exec rm -rf '{}' +
$ find . -name ".DS_Store" -delete
# turn off
$ sudo mdutil -a -i off
# turn on
$ sudo mdutil -a -i on
$ virtualenv venv
$ source venv/bin/activate
$ deactivate
MIT