Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
279 lines (239 sloc) 6.66 KB
#!/bin/bash
# System overrides
alias rm=trash
# Fuzzy selector of choice; fzf, selecta, pick, ...
local fuzzy_selector=fzf
# override vim
alias vi=vim
alias 🚢="git push --force"
# Common
alias c=clear
alias la="ls -lah"
alias ccat="pygmentize -g"
alias json="python -m json.tool | pygmentize -l json"
# Git
alias b=awesome_switch_branch
alias bd=awesome_branch_delete
alias bm=awesome_branch_merge
alias gp="git push --recurse-submodules=on-demand"
alias gpu=push_and_set_upstream
alias gl="git pull --rebase --stat"
#alias gs="git status -sb"
alias gs="tig status"
alias gd="git diff"
alias gdi="git diff --ignore-all-space"
alias gds="git difftool --extcmd 'icdiff --highlight --line-numbers' | less"
alias gdsi="git difftool --ignore-all-space --extcmd 'icdiff --highlight --line-numbers' | less"
alias ga="git add"
alias gc=git_awesome_commit
alias ghp="open https://github.com/pulls"
# Bundler
alias be="bundle exec"
alias bi="bundle install"
alias bu="bundle update"
# CocoaPods
alias pi="pod install"
alias pu="pod update"
# Xcode
alias stupidXcode="rm -rf ~/Library/Developer/Xcode/DerivedData"
alias decodeprovisioning="security cms -D -i"
# Open the current .xcworkspace or .xcodeproj
xopen() {
if [[ -n $1 ]]; then
open "$1"
fi
workspace=$(find . -name '*.xcworkspace' -maxdepth 1)
project=$(find . -name '*.xcodeproj' -maxdepth 1)
if [[ -n $workspace ]]; then
open "$workspace"
elif [[ -n $project ]]; then
open "$project"
else
echo "No .xcworkspace or .xcodeproj found in the working directory."
fi
}
# Bookmarks
# shellcheck disable=SC2139
craigslist() {
apts="http://sfbay.craigslist.org/search/sfc/apa\?sort\=date"
hoods="\&nh\=149\&nh\=3\&nh\=4\&nh\=6\&nh\=8\&nh\=11\&nh\=12\&nh\=10\&nh\=20\&nh\=24\&nh\=17\&nh\=18\&nh\=19\&nh\=22\&nh\=23\&nh\=25\&nh\=27\&nh\=1\&nh\=156\&nh\=29\&nh\=30"
hills="\&nh\=3\&nh\=4\&nh\=5\&nh\=11\&nh\=23\&nh\=25\&nh\=27\&nh\=29"
price="\&maxAsk\=4000"
br="\&bedrooms\=1"
alias listings="open $apts$hoods$price$br"
alias hills="open $apts$hills$price$br"
alias listings-fancy="open $apts$hoods$price$br\&query\=garage%2C%20washer"
}
craigslist
alias gifs="open http://f.cl.ly/items/1D1A1w06470M1U2P0311/gifs.txt"
# Todo.txt
alias td="todo.sh"
alias tdd="todo.sh do"
alias tdl="todo.sh ls"
alias tda="todo.sh add"
alias tdaa="todo.sh add '(A)'"
alias tdab="todo.sh add '(B)'"
alias tdac="todo.sh add '(C)'"
# Lyft todos
alias ltd="todo.sh pv @lyft"
alias tdal="tda @lyft"
alias tdala="tdaa @lyft"
alias tdalb="tdab @lyft"
# Lyft
alias mock="mux start mock-api"
# Git(hub)
alias ghpr=awesome_pull_request
pastegist() {
open "$(pbpaste | gist -p)"
}
github_slug(){
git ls-remote --get-url origin | cut -f 2 -d ':' | cut -f 1 -d '.'
}
# See git log for the work done on the current branch against `master` or the
# specified branch.
# Usage: b [branch] (default: master)
bl() {
git l "${1:-origin}"..HEAD "$@"
}
pulls() {
if [[ $1 = "me" ]]; then
open "https://github.com/$(github_slug)/pulls/supermarin"
else
open "https://github.com/$(github_slug)/pulls/$1"
fi
}
issues() {
open "https://github.com/$(github_slug)/issues/$1"
}
# Creates a pull request on Github against the provided branch or `master`
# After successfull creation, opens it in your web browser.
awesome_pull_request() {
if [[ -n $1 ]]; then
branch=$1
else
branch=master
fi
git push
hub pull-request -b $branch -o
}
# Pushes the current branch and sets it to upstream
push_and_set_upstream() {
git push -u origin "$(git branch | grep '\*' | cut -d ' ' -f 2)"
}
# The most awesome Git commit you'll find ever.
# Usage:
# $ gc handle cli argumnents. Fixes #213
git_awesome_commit() {
if [[ -n $1 ]]; then
git add .
git commit -am "$*"
else
git commit -v
fi
}
# Jira....
jira() {
if [[ -n $1 ]]; then
open "https://lyftme.atlassian.net/browse/$1"
else
open https://lyftme.atlassian.net/issues/\?filter=-1
fi
}
confluence() {
open "https://lyftme.atlassian.net/wiki"
}
# Fuzzy finds branches except your current branch, returns the selected branch
fuzzy_branch() {
git branch | grep -Ev '\*' | $fuzzy_selector | tr -d ' '
}
awesome_switch_branch() {
if [[ -n $1 ]]; then
git checkout "$1"
else
branch=$(fuzzy_branch)
if [[ -n $branch ]]; then
git checkout "$branch"
fi
fi
}
awesome_branch_delete() {
#set -e
branch=$(fuzzy_branch)
if [[ -n $branch ]]; then
git branch -D "$branch"
echo "Delete from remote? [y/N]: "
read -r delete_from_remote
if [[ $delete_from_remote = 'y' ]]; then
git push origin ":$branch"
else
echo "Not deleting from remote."
fi
fi
}
awesome_branch_merge() {
branch=$(fuzzy_branch)
if [[ -n $branch ]]; then
git merge "$branch"
fi
}
# Fuzzy finds a running proccess using `ps ax`
findproccess() {
ps ax | $fuzzy_selector
}
# man(1) with colors!!!1!
man() {
# shellcheck disable=SC2046
env \
LESS_TERMCAP_mb=$(printf "\e[1;31m") \
LESS_TERMCAP_md=$(printf "\e[1;31m") \
LESS_TERMCAP_me=$(printf "\e[0m") \
LESS_TERMCAP_se=$(printf "\e[0m") \
LESS_TERMCAP_so=$(printf "\e[1;44;33m") \
LESS_TERMCAP_ue=$(printf "\e[0m") \
LESS_TERMCAP_us=$(printf "\e[1;32m") \
man "$@"
}
# Search through your code directories and quickly open project folder
# For example:
# $ wo traz
# -> will take me to ~/code/oss/Alcatraz
#
# $ wo <Enter>
# -> Opens up the fuzzy finder for your code directories
# Requirement:
# $fuzzy_selector needs to be set, e.g.
#
# $fuzzy_selector=fzf
#
# shellcheck disable=SC2086,SC2155
wo() {
code_dirs=(
$HOME/code
$HOME/code/go/src
)
dir_list=$(find "${code_dirs[@]}" -type d -maxdepth 3 | grep -v /Pods)
if [[ -n $1 ]]; then
dir=$(grep --max-count=1 -i "$*" <<< $dir_list)
else
if [ -x "$(which $fuzzy_selector)" ]; then
dir=$(grep -v /Pods <<< $dir_list | $fuzzy_selector)
else
echo "You need to install '$fuzzy_selector' to get the fuzzy finder"
exit 1
fi
fi
cd "$dir" || echo "WAT"
tmux rename-window "$(basename $dir)"
}
transfer() {
if [ $# -eq 0 ]; then
echo -e "No arguments specified. Usage:\n$ transfer [path-to-file]"
return 1
fi
if tty -s; then
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile"
else
curl --progress-bar --upload-file "-" "https://transfer.sh/$1"
fi
}