Skip to content

Instantly share code, notes, and snippets.

@WillSquire
Last active October 1, 2024 21:55
Show Gist options
  • Save WillSquire/1b2eb425a4a7dedd38fb9c086bad454b to your computer and use it in GitHub Desktop.
Save WillSquire/1b2eb425a4a7dedd38fb9c086bad454b to your computer and use it in GitHub Desktop.
ZSH CLI setup

Code setup

Shell (ZSH) setup

Install oh-my-zsh:

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Download non-included plugin libraries:

# zsh-autosuggestions - https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md#oh-my-zsh
git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions

# zsh-syntax-highlighting - https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/INSTALL.md#oh-my-zsh
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

Open ~/.zshrc and edit/add plugins list (see: oh-my-zsh plugins, these plugins focus on code completion):

plugins=(
  asdf
  docker
  docker-compose
  helm
  kubectl
  npm
  nvm
  rust
  yarn
  zsh-autocomplete
  zsh-autosuggestions
  zsh-syntax-highlighting
)

Customisations (add to the end of the ~/.zshrc file):

# Custom keybindings
bindkey '^I' autosuggest-accept # tab to accept autosuggestion (replace with `forward-word` to accept part of the suggestion)

# zsh-autosuggestions config
ZSH_AUTOSUGGEST_STRATEGY=(history completion) # show both command history & auto completions, in that order

Command prompt

Starship

Install Starship:

curl -sS https://starship.rs/install.sh | sh

Install a Nerdfont to display special characters, like:

Open ~/.hyper.js and add the font, like Hack:

fontFamily: 'Hack Nerd Font, Menlo, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace',

Open ~/.zshrc and edit:

# Update `ZSH_THEME` to disable oh-my-zsh theme
ZSH_THEME=""

# Set Starship theme (after `source $ZSH/oh-my-zsh.sh`)
eval "$(starship init zsh)"

To support the terminal in VS Code, add to VS Code's settings.json:

// Nerd font for Starship command prompt
"terminal.integrated.fontFamily": "'Hack Nerd Font', monospace",

Terminal

Install Hyper. This comes with keybindings that are app controlled (such as using the cmd key) and other useful ones, such as:

# cmd+left - beginning of line
# cmd+right - end of line
# cmd+delete - delete the line
# tab - accept autosuggestion
# etc

Install Snazzy theme for Hyper:

# enabled hyper CLI first in Hyper->Tools
hyper install hyper-snazzy

Install hyper-tabs-enhanced:

# run
hyper install hyper-tabs-enhanced

Add customisations ~/.hyper.js:

module.exports = {
  config: {
    // ...
      // hyper-tabs-enhanced settings
      // see: https://github.com/henrikruscon/hyper-tabs-enhanced
      hyperTabs: {
        trafficButtons: true,
      }
    // ...
  }
}

VS Code

  • Download a ligature supported font, like Liga Menlo.
  • Open VS code.
  • Type ">Open User Settings (JSON)" in the search bar and enter to edit VS Code's settings.json.

Add the following to the settings.json:

{
  // custom font - use ligatures supported for `fontLigatures` setting to work
  "editor.fontFamily": "Liga Menlo, Menlo, Monaco, 'Courier New', monospace",

  // enable symbol replacements (e.g. !==)
  "editor.fontLigatures": true,

  // nerd font to support Starship command prompt
  "terminal.integrated.fontFamily": "'Hack Nerd Font', monospace",
}

Optional

zsh-autocomplete

NOTE: This adds extra information to the interface when typing. This hasn't been included in the setup as it can make things harder to read.

# Install zsh-autocomplete - https://github.com/marlonrichert/zsh-autocomplete
git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete

# Then add to `~/.zshrc` file:
plugins=(
  # ...
  zsh-autocomplete
  # ...
)

Pure

pure:

NOTE: This adds the current working directory path to the interface. This hasn't been included in the setup as the path can make the interface lengthy.

# Install following instructions
mkdir -p "$HOME/.zsh"
git clone https://github.com/sindresorhus/pure.git "$HOME/.zsh/pure"

# Open `~/.zshrc, then:
# Update `ZSH_THEME` to disable oh-my-zsh theme
ZSH_THEME=""

# Add after `source $ZSH/oh-my-zsh.sh`
fpath+=($HOME/.zsh/pure)
autoload -U promptinit; promptinit
prompt pure

Snazzy theme for VS Code

Install Snazzy theme for VS Code:

NOTE: This is separate from the editor theme for the code and is terminal only. This can clash with the current VS Code editor theme's colours, distracting the eye.

  • Open VS code
  • Press cmd+shift+p
  • Type "open user settings"
  • Choose "Open User Settings (JSON)"
  • Add snazzy config to settings.json

Notes

Notable fonts:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment