This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# change directory | |
cd # back to the last one you were in | |
mkdir dir && cd !$ # cd into the director you just created | |
take dir # cd into the director you just created - a custom function |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Movement on the command line | |
ctrl + a # move to the beginning of command | |
ctrl + e # move to the end of the command | |
ctrl + w # delete one word to the left | |
ctrl + k # delete all to the right | |
esc + f # move cursor forward | |
esc + b # move cursor back |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Common Grep pattern. Recursively searches directory, case insensitive, show | |
# line numbers, show the 5 lines before and after | |
grep -irn -C 5 [pattern] [location] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'plist' | |
require 'active_support/inflector' | |
# require 'gist' | |
# include Inflector | |
r = Plist::parse_xml('snippet-export.plist') | |
r.each do |r| | |
filename = "#{r['language'].parameterize}-#{r['id']}.txt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use git archive command to export a git repo | |
git archive master | tar -x -C /someplace/else/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# show last modified date for each git branch in a project | |
for k in `git branch|sed s/^..//`;do echo -e `git log -1 --pretty=format:"%Cgreen%ci %Cblue%cr%Creset" "$k"`\\t"$k";done|sort -r |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# global search and replace | |
find test/ -type f | xargs sed -i .old -e "s/test/example/g" | |
# display control/non-printable characters | |
sed -n 'l' input.txt | |
# backup a file before changing it by adding a suffix |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# check mail log for error and warnings | |
egrep '(warning|error|fatal|panic):' /var/log/maillog | less |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create an iso from a mac | |
hdiutil makehybrid -iso -o Microsoft-Office-2011.iso /Volumes/Microsoft\ Office\ 2011/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Using a list with the mv command | |
mv README.{txt,textile} | |
mv config{,.old} | |
mv foo{,bar} | |
mv {,~}foo | |
mv {~,}foo |