Skip to content

Instantly share code, notes, and snippets.

@dezman
Last active May 22, 2019 22:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dezman/c288db7779ee45b1e8e50f9c9c1efe23 to your computer and use it in GitHub Desktop.
Save dezman/c288db7779ee45b1e8e50f9c9c1efe23 to your computer and use it in GitHub Desktop.
#!/bin/bash
# math
echo $(( 1 + 1 ))
# look for a process by port number
lsof -i:3000
# look for a process and print its pid
ps aux | grep ruby | awk '{print $2}'
# look for a port to kill
kill -9 `lsof -t -i:3000`
# update a file using ruby
cat file.csv | ruby -e 'puts STDIN.read.split("\n").join(";")' > new_file.csv
# search directory for files containing a string
grep -rnw . -e search_string
# use a command from history
history | grep ssh
# 396 rm -rf .atom/
# 397 cd ~
# 398 cd Desktop/
!396
# create a screen
screen -S <name>
# ctrl-a then c to make a new tab
# ctrl-a then [0-9] to switch between tabs
# ctrl-a then d to detach from a screen
# list screens
screen -ls
# There are screens on:
# 7654.reindex_workspaces (05/16/2016 09:53:40 PM) (Detached)
# 2391.pts-0.job01 (05/09/2016 05:43:15 PM) (Detached)
# re-attatch to screen
screen -r reindex_workspaces
# kill all screen sessions
pkill SCREEN
# send keystrokes via terminal
osascript -e 'tell application "System Events" to keystroke "TROLLFACE" & return'
# press F8 (key code 100)
osascript -e 'tell application "System Events" to key code {100}'
# loops
while [ true ]; do
# do stuff
done
ids=("1" "2" "3" "4" "5")
for i in ${ids[@]}
do
echo $i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment