Created
November 22, 2017 20:13
-
-
Save andymcfee/d49dee2897f38e1544154dad71f489fc to your computer and use it in GitHub Desktop.
.oh-my-zsh/custom/
This file contains hidden or 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
# Easier navigation: .., ..., ~ and - | |
alias ..="cd .." | |
alias cd..="cd .." | |
alias ...="cd ../.." | |
alias ....="cd ../../.." | |
alias .....="cd ../../../.." | |
alias ~="cd ~" # `cd` is probably faster to type though | |
alias -- -="cd -" | |
alias gs="git status -sb" | |
alias gpull="git pull origin dev" | |
alias gcheckout="git checkout dev" | |
alias gcheck="git checkout dev" | |
alias gche="git checkout dev" | |
alias gpr="git pull --rebase origin" | |
alias gpush="git push origin dev" | |
alias glist="git stash list" | |
alias gnew="git checkout -b" | |
alias gdelete_local="git branch -D" | |
alias gdl="git branch -D" | |
alias gpop="git stash pop" | |
alias gdr="git push origin --delete" | |
alias gamend="git commit --amend -C HEAD" | |
alias gundo="git reset --soft HEAD^" | |
alias gcount="git shortlog -sn" | |
alias myssh="pbcopy < ~/.ssh/id_rsa.pub" | |
# Stuff I never really use but cannot delete either because of http://xkcd.com/530/ | |
alias stfu="osascript -e 'set volume output muted true'" | |
alias pumpitup="osascript -e 'set volume 10'" | |
alias hax="growlnotify -a 'Activity Monitor' 'System error' -m 'WTF R U DOIN'" | |
alias serve="python -c 'import SimpleHTTPServer; SimpleHTTPServer.test()'" | |
# Get OS X Software Updates, and update installed Homebrew, casks, npm, and their installed packages, and oh_my_zsh | |
alias updateall='sudo softwareupdate -i -a; brew update; brew upgrade; brew cleanup; brew cask reinstall `brew cask outdated`; brew cask cleanup; npm install npm -g; npm update -g; upgrade_oh_my_zsh' |
This file contains hidden or 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 a new directory and enter it | |
function md() { | |
mkdir -p "$@" && cd "$@" | |
} | |
function new() { | |
mkdir -p "$@" && cd "$@" | |
} | |
function editconflicts() { | |
subl $(git diff --name-only --diff-filter=U | xargs) | |
} | |
# find shorthand | |
function f() { | |
find . -name "$1" | |
} | |
# cd into whatever is the forefront Finder window. | |
cdf() { # short for cdfinder | |
cd "`osascript -e 'tell app "Finder" to POSIX path of (insertion location as alias)'`" | |
} | |
# Show hidden files | |
function showhidden() { | |
defaults write com.apple.finder AppleShowAllFiles -bool YES; | |
killall Finder; | |
echo "Hidden Files are now visible."; | |
} | |
# Hide hidden files | |
function hidehidden() { | |
defaults write com.apple.finder AppleShowAllFiles -bool NO; | |
killall Finder; | |
echo "Hidden Files are now hidden."; | |
} | |
# lets toss an image onto my server and pbcopy that bitch. | |
function scpp() { | |
scp "$1" [email protected]:~/paulirish.com/i; | |
echo "http://paulirish.com/i/$1" | pbcopy; | |
echo "Copied to clipboard: http://paulirish.com/i/$1" | |
} | |
# Start an HTTP server from a directory, optionally specifying the port | |
function server() { | |
local port="${1:-8000}" | |
open "http://localhost:${port}/" | |
# Set the default Content-Type to `text/plain` instead of `application/octet-stream` | |
# And serve everything as UTF-8 (although not technically correct, this doesn’t break anything for binary files) | |
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port" | |
} | |
# Copy w/ progress | |
cp_p () { | |
rsync -WavP --human-readable --progress $1 $2 | |
} | |
# Test if HTTP compression (RFC 2616 + SDCH) is enabled for a given URL. | |
# Send a fake UA string for sites that sniff it instead of using the Accept-Encoding header. (Looking at you, ajax.googleapis.com!) | |
function httpcompression() { | |
encoding="$(curl -LIs -H 'User-Agent: Mozilla/5 Gecko' -H 'Accept-Encoding: gzip,deflate,compress,sdch' "$1" | grep '^Content-Encoding:')" && echo "$1 is encoded using ${encoding#* }" || echo "$1 is not using any encoding" | |
} | |
# Syntax-highlight JSON strings or files | |
function json() { | |
if [ -p /dev/stdin ]; then | |
# piping, e.g. `echo '{"foo":42}' | json` | |
python -mjson.tool | pygmentize -l javascript | |
else | |
# e.g. `json '{"foo":42}'` | |
python -mjson.tool <<< "$*" | pygmentize -l javascript | |
fi | |
} | |
# take this repo and copy it to somewhere else minus the .git stuff. | |
function gitexport(){ | |
mkdir -p "$1" | |
git archive master | tar -x -C "$1" | |
} | |
# get gzipped size | |
function gz() { | |
echo "orig size (bytes): " | |
cat "$1" | wc -c | |
echo "gzipped size (bytes): " | |
gzip -c "$1" | wc -c | |
} | |
# All the dig info | |
function digga() { | |
dig +nocmd "$1" any +multiline +noall +answer | |
} | |
# Escape UTF-8 characters into their 3-byte format | |
function escape() { | |
printf "\\\x%s" $(printf "$@" | xxd -p -c1 -u) | |
echo # newline | |
} | |
# Decode \x{ABCD}-style Unicode escape sequences | |
function unidecode() { | |
perl -e "binmode(STDOUT, ':utf8'); print \"$@\"" | |
echo # newline | |
} | |
# Extract archives - use: extract <file> | |
# Based on http://dotfiles.org/~pseup/.bashrc | |
function extract() { | |
if [ -f "$1" ] ; then | |
local filename=$(basename "$1") | |
local foldername="${filename%%.*}" | |
local fullpath=`perl -e 'use Cwd "abs_path";print abs_path(shift)' "$1"` | |
local didfolderexist=false | |
if [ -d "$foldername" ]; then | |
didfolderexist=true | |
read -p "$foldername already exists, do you want to overwrite it? (y/n) " -n 1 | |
echo | |
if [[ $REPLY =~ ^[Nn]$ ]]; then | |
return | |
fi | |
fi | |
mkdir -p "$foldername" && cd "$foldername" | |
case $1 in | |
*.tar.bz2) tar xjf "$fullpath" ;; | |
*.tar.gz) tar xzf "$fullpath" ;; | |
*.tar.xz) tar Jxvf "$fullpath" ;; | |
*.tar.Z) tar xzf "$fullpath" ;; | |
*.tar) tar xf "$fullpath" ;; | |
*.taz) tar xzf "$fullpath" ;; | |
*.tb2) tar xjf "$fullpath" ;; | |
*.tbz) tar xjf "$fullpath" ;; | |
*.tbz2) tar xjf "$fullpath" ;; | |
*.tgz) tar xzf "$fullpath" ;; | |
*.txz) tar Jxvf "$fullpath" ;; | |
*.zip) unzip "$fullpath" ;; | |
*) echo "'$1' cannot be extracted via extract()" && cd .. && ! $didfolderexist && rm -r "$foldername" ;; | |
esac | |
else | |
echo "'$1' is not a valid file" | |
fi | |
} | |
# animated gifs from any video | |
# from alex sexton gist.github.com/SlexAxton/4989674 | |
gifify() { | |
if [[ -n "$1" ]]; then | |
if [[ $2 == '--good' ]]; then | |
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png | |
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif | |
rm out-static*.png | |
else | |
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif | |
fi | |
else | |
echo "proper usage: gifify <input_movie.mov>. You DO need to include extension." | |
fi | |
} | |
# toggle wifi on/off using command line | |
function togglewifi() { | |
local wifindx=-1 | |
local count=0 | |
while read -r line; do | |
if [ "$line" == "Wi-Fi" ] | |
then | |
# count - 1 in order to ingnore the first line | |
# of the command output | |
wifindx=`expr $count - 1` | |
fi | |
(( count++ )) | |
done < <(networksetup -listallnetworkservices) | |
local wifstatus="$(networksetup -getairportpower en$wifindx)" | |
if [ "$wifstatus" == "Wi-Fi Power (en$wifindx): Off" ] | |
then | |
networksetup -setairportpower en$wifindx on | |
echo "starting wifi..." | |
else | |
networksetup -setairportpower en$wifindx off | |
echo "stopping wifi..." | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment