Skip to content

Mac_Terminal

bootstraponline edited this page Mar 31, 2019 · 38 revisions

iTerm2 & ZSH on Mac

  • Install Visual Studio Code

  • Install homebrew

    • brew tap caskroom/versions
    • brew cask install java8
    • brew install git hub ruby gradle
  • Install iTerm2 stable

  • iTerm2Preferences...ProfilesColorsColor Presets...Import

    • After importing, manually select Solarized Dark from the drop down list.
  • Install powerline font

    • git clone https://github.com/powerline/fonts.git
    • cd fonts; ./install.sh
    • iTerm2Preferences...ProfilesTextChange FontMeslo LG M DZ Regular for Powerline
      • Make sure to uncheck Use a different font for non-ASCII text. If this is checked, the Git symbols won't render correctly.
- Install [Agnoster on bash.](https://github.com/speedenator/agnoster-bash)
cd $HOME
mkdir -p .bash/themes/agnoster-bash
git clone https://github.com/speedenator/agnoster-bash.git
cp agnoster-bash/agnoster.bash ~/agnoster.bash

code ~/.bash_profile

. ./agnoster.bash
export DEFAULT_USER=`whoami`

--

Custom alias

Open the Command Palette in visual studio code then type shell command and click Shell Command: Install 'code' command in PATH

$ code ~/.bash_profile
export DEFAULT_USER=`whoami`
. ~/agnoster.bash

eval "$(hub alias -s)"

function reload() {
  . ~/.bash_profile
}

function config() {
  code ~/.bash_profile
}

alias c="cd $HOME/code"
alias o="code --reuse-window"
alias config="o \"$HOME/.bash_profile\""
alias dd="rm -rf \"$HOME/Library/Developer/Xcode/DerivedData\""
alias ddo="open \"$HOME/Library/Developer/Xcode/DerivedData\""

mc() {
  mkdir "$@"
  cd "$@"
}

Set any custom exports.

$ code ~/.bash_rpfile
# Add brew bins to PATH
export PATH="/usr/local/bin:$PATH"
export PATH="/usr/local/sbin:$PATH"

export GOPATH="$HOME/go"
export PATH="$PATH:$GOPATH/bin"

export PATH="$PATH:`yarn global bin`"

export ANDROID_HOME="$HOME/Library/Android/sdk"
export PATH="$ANDROID_HOME/tools:$PATH"
export PATH="$ANDROID_HOME/tools/bin:$PATH"
export PATH="$ANDROID_HOME/platform-tools:$PATH"
export PATH="$ANDROID_HOME/build-tools/23.0.2:$PATH"

export GRADLE_OPTS="-Dorg.gradle.daemon=true"
export GRADLE_HOME="/usr/local/opt/gradle/libexec"

export JAVA_HOME=$(/usr/libexec/java_home)

Install Java8 with brew

brew tap caskroom/versions
brew cask install java8

macOS CI servers may require a symlink

sudo ln -sf $(/usr/libexec/java_home)/bin/java /usr/bin/java

Install Ruby with brew

brew install ruby

PATH="$(brew --prefix ruby)/bin:$PATH"

gem update --system --no-document
gem install --no-document bundler fastlane cocoapods

Skip documentation on gem install

Open ~/.gemrc and add

gem: --no-document

--

ZSH Git Cheat Sheet

ZSH shortcuts:

  • Ctrl + U = Clear
  • Ctrl + A = Go to start
  • Ctrl + E = Go to end
  • ⌥← = Back one word (option + left arrow)
  • ⌥→ = Forward one word (option + right arrow)

Add word jumping to iTerm2

Configure left ⌥ to act as +Esc then add Escape codes for ⌥← and ⌥→

word_jump_left word_jump_right

--

Set working directory

Preferences → Profile → General → Working directory.... → Advanced Configuration

  • Working Directory for New Windows~/code
  • Working Directory for New Tabs → Reuse previous session's directory

--

General usage tip

  • Store code in ~/code. Make Alias on desktop so it's easy to reach via Finder.

--

Jump directly to a location in a path

  • Option + Click

--

History info

  • cat ~/.zsh_history
  • history

Clone this wiki locally