diff --git a/.gitmodules b/.gitmodules index 38afa20..61d37b3 100644 --- a/.gitmodules +++ b/.gitmodules @@ -70,9 +70,6 @@ [submodule "vim/vim.symlink/bundle/vim-matchit"] path = vim/vim.symlink/bundle/vim-matchit url = https://github.com/tsaleh/vim-matchit.git -[submodule "vim/vim.symlink/bundle/syntastic"] - path = vim/vim.symlink/bundle/syntastic - url = https://github.com/scrooloose/syntastic.git [submodule "vim/vim.symlink/bundle/vim-surround"] path = vim/vim.symlink/bundle/vim-surround url = https://github.com/tpope/vim-surround.git diff --git a/git/git.zsh b/git/git.zsh index a2751f7..5096394 100644 --- a/git/git.zsh +++ b/git/git.zsh @@ -17,10 +17,13 @@ alias glog="git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C alias git-amend='git commit --amend -C HEAD' alias git-undo='git reset --soft HEAD~1' alias git-count='git shortlog -sn' +alias undopush="git push -f origin HEAD^:master" +# git root +alias gr='[ ! -z `git rev-parse --show-cdup` ] && cd `git rev-parse --show-cdup || pwd`' alias sub-pull='git submodule foreach git pull origin master' -funciton get-credit() { +funciton give-credit() { git commit --amend --author $1 <$2> -C HEAD } diff --git a/vim/vim.symlink/bundle/syntastic b/vim/vim.symlink/bundle/syntastic deleted file mode 160000 index 2e7d733..0000000 --- a/vim/vim.symlink/bundle/syntastic +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 2e7d73305b70a456abb20b1754e094cccfefa3d3 diff --git a/zsh/functions.zsh b/zsh/functions.zsh index 0a4c421..15f37c5 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -13,3 +13,91 @@ function colours() { fi done } + +# Create a new directory and enter it +function md() { + mkdir -p "$@" && cd "$@" +} + + +# find shorthand +function f() { + find . -name "$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" +} + +# git log with per-commit cmd-clickable GitHub URLs (iTerm) +# function gf() { +# local remote="$(git remote -v | awk '/^origin.*\(push\)$/ {print $2}')" +# [[ "$remote" ]] || return +# local user_repo="$(echo "$remote" | perl -pe 's/.*://;s/\.git$//')" +# git log $* --name-status --color | awk "$(cat < +# Credits to http://dotfiles.org/~pseup/.bashrc +function extract() { + if [ -f $1 ] ; then + case $1 in + *.tar.bz2) tar xjf $1 ;; + *.tar.gz) tar xzf $1 ;; + *.bz2) bunzip2 $1 ;; + *.rar) rar x $1 ;; + *.gz) gunzip $1 ;; + *.tar) tar xf $1 ;; + *.tbz2) tar xjf $1 ;; + *.tgz) tar xzf $1 ;; + *.zip) unzip $1 ;; + *.Z) uncompress $1 ;; + *.7z) 7z x $1 ;; + *) echo "'$1' cannot be extracted via extract()" ;; + esac + else + echo "'$1' is not a valid file" + fi +} diff --git a/zsh/lib/aliases.zsh b/zsh/lib/aliases.zsh index fcb83ca..a9c8cdb 100644 --- a/zsh/lib/aliases.zsh +++ b/zsh/lib/aliases.zsh @@ -1,14 +1,27 @@ # reload zsh config alias reload!='source ~/.zshrc' +# Detect which `ls` flavor is in use +if ls --color > /dev/null 2>&1; then # GNU `ls` + colorflag="--color" +else # OS X `ls` + colorflag="-G" +fi + # Filesystem aliases alias ..='cd ..' alias ...='cd ../..' -alias l='ls -lah' -alias la='ls -AF' -alias ll='ls -lFh' -alias lld='ls -l | grep ^d' -alias rmf='rm -rf' +alias ....="cd ../../.." +alias .....="cd ../../../.." + +alias l="ls -lah ${colorflag}" +alias la="ls -AF ${colorflag}" +alias ll="ls -lFh ${colorflag}" +alias lld="ls -l | grep ^d" +alias rmf="rm -rf" + +# shortcut to dotfiles +alias dot="cd ~/.dotfiles" # Helpers alias grep='grep --color=auto' @@ -22,3 +35,54 @@ alias rake="noglob rake" alias mou='open -a Mou.app' alias mark='open -a Marked.app' alias ios='open -a /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app' + +# be nice +alias please=sudo + +# IP addresses +alias ip="dig +short myip.opendns.com @resolver1.opendns.com" +alias localip="ipconfig getifaddr en1" +alias ips="ifconfig -a | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1'" + +# Enhanced WHOIS lookups +alias whois="whois -h whois-servers.net" + +# Flush Directory Service cache +alias flush="dscacheutil -flushcache" + +# View HTTP traffic +alias sniff="sudo ngrep -d 'en1' -t '^(GET|POST) ' 'tcp and port 80'" +alias httpdump="sudo tcpdump -i en1 -n -s 0 -w - | grep -a -o -E \"Host\: .*|GET \/.*\"" + +# Trim new lines and copy to clipboard +alias trimcopy="tr -d '\n' | pbcopy" + +# Recursively delete `.DS_Store` files +alias cleanup="find . -name '*.DS_Store' -type f -ls -delete" + +# File size +alias fs="stat -f \"%z bytes\"" + +# ROT13-encode text. Works for decoding, too! ;) +alias rot13='tr a-zA-Z n-za-mN-ZA-M' + +# Empty the Trash on all mounted volumes and the main HDD +alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; rm -rfv ~/.Trash" + +# Hide/show all desktop icons (useful when presenting) +alias hidedesktop="defaults write com.apple.finder CreateDesktop -bool false && killall Finder" +alias showdesktop="defaults write com.apple.finder CreateDesktop -bool true && killall Finder" + + +# PlistBuddy alias, because sometimes `defaults` just doesn’t cut it +alias plistbuddy="/usr/libexec/PlistBuddy" + +# One of @janmoesen’s ProTip™s +for method in GET HEAD POST PUT DELETE TRACE OPTIONS; do + alias "$method"="lwp-request -m '$method'" +done + +# 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'"