.profile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. export PATH="$PATH:$HOME/bin"
  2. # Homebrew
  3. export PATH="$PATH:$HOME/homebrew/bin"
  4. export PYTHONPATH="$(brew --prefix)/lib/python2.7/site-packages/" # also facilitates: easy_install -d "$PYTHONPATH" awesome_pkg
  5. # Homebrew cask
  6. export HOMEBREW_CASK_OPTS="--caskroom=$HOME/homebrew/Caskroom --binarydir=$HOME/homebrew/bin"
  7. # Custom shell aliases
  8. alias ls="ls -FG"
  9. alias d="ls"
  10. alias tree="tree -CF"
  11. alias grep="grep --color --exclude-dir=.svn --exclude-dir=.git --exclude-dir=node_modules"
  12. # MacVim shell aliases
  13. alias gvim="mvim"
  14. # Default editor
  15. export EDITOR="vim"
  16. # bash completion FTW
  17. ! [ -f "$(brew --prefix)/etc/bash_completion" ] || . "$(brew --prefix)/etc/bash_completion"
  18. # color diffs
  19. ! which colordiff &>/dev/null || alias diff="colordiff"
  20. # Git shell aliases
  21. F="/Library/Developer/CommandLineTools/usr/share/git-core/git-completion.bash"; ! [ -f "$F" ] || . "$F"
  22. # Liquid Prompt
  23. F="$HOME/liquidprompt/liquidprompt"; ! [ "$PS1" -a -f "$F" ] || . "$F"
  24. # go lang
  25. export GOROOT="$(brew --prefix go)"
  26. export PATH="$PATH:$GOROOT/bin"
  27. export GOPATH="$HOME/go"
  28. export PATH="$PATH:$GOPATH/bin"
  29. # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
  30. HISTSIZE=50000
  31. HISTFILESIZE=500000
  32. # make less allow and use colors
  33. export LESS="-FRX"
  34. ###############################################################################
  35. # Installers
  36. ###############################################################################
  37. _install_homebrew() {
  38. xcode-select --install 2>&1 | grep -q "already installed" || exit
  39. [ -d "$HOME/homebrew" ] || (mkdir "$HOME/homebrew" 2>/dev/null && curl -L "https://github.com/Homebrew/homebrew/tarball/master" | tar xz --strip 1 -C "$HOME/homebrew" && brew update)
  40. brew install caskroom/cask/brew-cask
  41. }
  42. _install_tools() {
  43. _install_homebrew
  44. [ -f "$HOME/.bash_profile" ] || ln -sv "$HOME/.profile" "$HOME/.bash_profile"
  45. [ -f "$HOME/.bashrc" ] || ln -sv "$HOME/.profile" "$HOME/.bashrc"
  46. [ -d "$HOME/liquidprompt" ] || git clone "https://github.com/nojhan/liquidprompt.git" "$HOME/liquidprompt"
  47. [ -f "$HOME/.gitconfig" ] || (
  48. git config --global color.ui true
  49. git config --global credential.helper "$([ "$(uname -s)" = "Darwin" ] && echo "osxkeychain" || echo "cache --timeout=3600")"
  50. )
  51. which git-alias >/dev/null || brew install git-extras
  52. [ "$(git alias)" ] || (
  53. git alias br branch
  54. git alias ci commit
  55. git alias co checkout
  56. git alias di diff
  57. git alias st status
  58. )
  59. which tmux >/dev/null || brew install tmux
  60. which tree >/dev/null || brew install tree
  61. [ -d "$HOME/Applications/SourceTree.app" ] || brew cask install sourcetree
  62. [ -d "$HOME/Applications/Atom.app" ] || brew cask install atom
  63. [ -d "$HOME/Applications/Google Chrome.app" ] || brew cask install google-chrome
  64. [ -d "$HOME/Applications/Firefox.app" ] || brew cask install firefox
  65. }
  66. _install_dev_js() {
  67. _install_homebrew
  68. which node >/dev/null || brew install node
  69. PKG="jshint"; which "$PKG" >/dev/null || npm install -g "$PKG"
  70. PKG="js-beautify"; which "$PKG" >/dev/null || npm install -g "$PKG"
  71. PKG="json"; which "$PKG" >/dev/null || npm install -g "$PKG"
  72. PKG="jscs"; which "$PKG" >/dev/null || npm install -g "$PKG"
  73. }
  74. _install_dev_sh() {
  75. _install_homebrew
  76. which shellcheck >/dev/null || brew install shellcheck
  77. }
  78. _install_dev_py() {
  79. _install_homebrew
  80. mkdir -p "$PYTHONPATH"
  81. PKG="pylint"; which "$PKG" >/dev/null || (easy_install -d "$PYTHONPATH" "$PKG" && ln -sv "$PYTHONPATH/$PKG" "$(brew --prefix)/bin/$PKG")
  82. PKG="pep8"; which "$PKG" >/dev/null || (easy_install -d "$PYTHONPATH" "$PKG" && ln -sv "$PYTHONPATH/$PKG" "$(brew --prefix)/bin/$PKG")
  83. }
  84. _install_dev_db() {
  85. _install_homebrew
  86. which mongod >/dev/null || brew install mongodb && ln -sfv "$(brew --prefix mongodb)"/*.plist ~/Library/LaunchAgents/
  87. which redis >/dev/null || brew install redis && ln -sfv "$(brew --prefix redis)"/*.plist ~/Library/LaunchAgents/
  88. which pg_config || brew install postgresql && ln -sfv "$(brew --prefix postgrsql)"/*.plist ~/Library/LaunchAgents/
  89. }
  90. _install_dev_go() {
  91. _install_homebrew
  92. which go >/dev/null || brew install go --with-cc-common
  93. }