Last active
February 5, 2019 03:13
-
-
Save fael/9cf10df3cb94079c229e2eb0588b22e5 to your computer and use it in GitHub Desktop.
OSX setup
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
# operation system | |
brew install wget zsh xcv exa ccat lua | |
# xcv = copy/cut/paste tool | |
# exa = better ls | |
# ccat = better cat | |
touch ~/.rafaelrc | |
echo 'source ~/.rafaelrc' >> .zshrc | |
# zsh as default shell | |
sudo echo "$(which zsh)" >> /etc/shells | |
chsh -s $(which zsh) | |
# oh my zsh | |
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" | |
# zsh plugins | |
brew install zsh-completions zsh-syntax-highlighting zsh-autosuggestions | |
printf '\nsource /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh' >> .rafaelrc | |
printf '\nsource /usr/local/share/zsh-autosuggestions/zsh-autosuggestions.zsh' >> .rafaelrc | |
# node version manager | |
brew install n | |
# z command rewritten in lua - https://github.com/skywind3000/z.lua | |
cd ~ && git clone https://github.com/skywind3000/z.lua.git | |
printf '\neval "$(lua ~/z.lua/z.lua --init zsh)"' >> .rafaelrc | |
# possible 'n' issues https://github.com/tj/n/issues/416 | |
sudo mkdir -p /usr/local/n | |
sudo chown -R $(whoami) /usr/local/n | |
sudo chown -R $(whoami) /usr/local/bin /usr/local/lib /usr/local/include /usr/local/share | |
n lts | |
npm install --global pure-prompt | |
printf 'autoload -U promptinit; promptinit\nprompt pure' >> .rafaelrc | |
# work tools | |
brew cask install iterm2 | |
brew cask install google-chrome | |
brew cask install firefox | |
brew cask install visual-studio-code | |
brew cask install slack | |
brew cask install macdown | |
brew cask install whatsapp | |
# aliases | |
cat >> .rafaelrc <<'EOL' | |
# aliases | |
alias c='clear' | |
alias f='open -a Finder ./' | |
# git related shortcut | |
alias clo='git clone' | |
alias undopush="git push -f origin HEAD^:master" | |
alias gd="git diff" | |
alias gdc="git diff --cached" | |
alias ga="git add" | |
alias gca="git commit -a -m" | |
alias gcm="git commit -m" | |
alias gops="git commit --amend" | |
alias gbd="git branch -D" | |
alias gs="git status -sb --ignore-submodules" | |
alias gm="git merge --no-ff" | |
alias gpt="git push --tags" | |
alias gp="git push" | |
alias grs="git reset --soft" | |
alias grh="git reset --hard" | |
alias gb="git branch" | |
alias gcb="git checkout -b" | |
alias gc="git checkout" | |
alias gcd="git checkout develop" | |
alias gba="git branch -a" | |
alias gcp="git cherry-pick" | |
alias gl="git pull" | |
alias gss="git stash save" | |
alias gsp="git stash pop" | |
alias gpo="git push origin" | |
alias gcl="git clone" | |
alias conflicts="git status --short | grep '^UU '" | |
alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome" | |
EOL | |
# functions | |
cat >> .rafaelrc <<'EOL' | |
# functions | |
take () { | |
mkdir -p $@ && cd ${@:$#} | |
} | |
qrcode() { | |
npx qrip $1 | |
} | |
markdown() { | |
open -a MacDown $@ | |
} | |
git-remote-url() { | |
# usage git-remote-url origin | |
local rmt=$1; shift || { printf "Usage: git-remote-url [REMOTE]\n" >&2; return 1; } | |
local url | |
if ! git config --get remote.${rmt}.url &>/dev/null; then | |
printf "%s\n" "Error: not a valid remote name" && return 1 | |
# Verify remote using 'git remote -v' command | |
fi | |
url=`git config --get remote.${rmt}.url` | |
# Parse remote if local clone used SSH checkout | |
[[ "$url" == git@* ]] \ | |
&& { url="https://github.com/${url##*:}" >&2; }; \ | |
{ url="${url%%.git}" >&2; }; | |
printf "%s\n" "$url" | |
} | |
current_branch() { | |
git rev-parse --abbrev-ref HEAD | |
} | |
pr() { | |
open $(git-remote-url origin)/pull/$1 | |
} | |
prs() { | |
#ref - https://www.npmjs.com/package/gh#pull-requests | |
gh pr --list --detailed $@ | |
} | |
prepr() { | |
open $(git-remote-url origin)/compare/develop...$(current_branch) | |
} | |
branch() { | |
if [ ! -z "$1" ]; then | |
open $(git-remote-url origin)/tree/$1 | |
else | |
open $(git-remote-url origin)/tree/$(current_branch) | |
fi | |
} | |
EOL |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment