Skip to content

Instantly share code, notes, and snippets.

@xavianaxw
Last active January 28, 2023 18:48
Show Gist options
  • Save xavianaxw/8e75ff37adc45bc9d3d62ada2e72ff3f to your computer and use it in GitHub Desktop.
Save xavianaxw/8e75ff37adc45bc9d3d62ada2e72ff3f to your computer and use it in GitHub Desktop.
Setup for new machine | Hyper Teminal + zsh (with autosuggestions) + spaceship prompt
// Future versions of Hyper may add additional config options,
// which will not automatically be merged into this file.
// See https://hyper.is#cfg for all currently supported options.
module.exports = {
config: {
// choose either `'stable'` for receiving highly polished,
// or `'canary'` for less polished but more frequent updates
updateChannel: "stable",
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: "FuraCode Nerd Font Mono",
// default font weight: 'normal' or 'bold'
fontWeight: "normal",
// font weight for bold characters: 'normal' or 'bold'
fontWeightBold: "bold",
// line height as a relative unit
lineHeight: 1.25,
// letter spacing as a relative unit
letterSpacing: 0,
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: "rgba(0,139,139,0.8)",
// terminal text color under BLOCK cursor
cursorAccentColor: "#000",
// `'BEAM'` for |, `'UNDERLINE'` for _, `'BLOCK'` for █
cursorShape: "BEAM",
// set to `true` (without backticks and without quotes) for blinking cursor
cursorBlink: true,
// color of the text
foregroundColor: "#c0c0c0",
// terminal background color
// opacity is only supported on macOS
backgroundColor: "#222222", // matches Freya vscode theme
// terminal selection color
selectionColor: "rgba(75,75,75,0.25)",
// border color (window, tabs)
borderColor: "#333",
// custom CSS to embed in the main window
css: "",
// custom CSS to embed in the terminal window
termCSS: "",
// if you're using a Linux setup which show native menus, set to false
// default: `true` on Linux, `true` on Windows, ignored on macOS
showHamburgerMenu: "",
// set to `false` (without backticks and without quotes) if you want to hide the minimize, maximize and close buttons
// additionally, set to `'left'` if you want them on the left, like in Ubuntu
// default: `true` (without backticks and without quotes) on Windows and Linux, ignored on macOS
showWindowControls: "",
// custom padding (CSS format, i.e.: `top right bottom left`)
padding: "12px 14px",
// the full list. if you're going to provide the full color palette,
// including the 6 x 6 color cubes and the grayscale map, just provide
// an array here instead of a color map object
colors: {
black: "#000000",
red: "#C51E14",
green: "#DAA520", // nvm|npm|clear (originally #1dc121)
yellow: "#C7C329",
blue: "#0A2FC4",
magenta: "#C839C5",
cyan: "#20C5C6",
white: "#C7C7C7",
lightRed: "#c0c0c0", // package
lightGreen: "#20B2AA", // node
lightYellow: "#708090", // time
lightBlue: "#ba0e2e", // unknown
lightMagenta: "#DAA520", // git
lightCyan: "#008b8b", // dir
lightWhite: "#ba0e2e", // prefix/suffix
lightBlack: "#708090" // autosuggestion
},
// the shell to run when spawning a new session (i.e. /usr/local/bin/fish)
// if left empty, your system's login shell will be used by default
//
// Windows
// - Make sure to use a full path if the binary name doesn't work
// - Remove `--login` in shellArgs
//
// Bash on Windows
// - Example: `C:\\Windows\\System32\\bash.exe`
//
// PowerShell on Windows
// - Example: `C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`
shell: "",
// for setting shell arguments (i.e. for using interactive shellArgs: `['-i']`)
// by default `['--login']` will be used
shellArgs: ["--login"],
// for environment variables
env: {},
// set to `false` for no bell
bell: "SOUND",
// if `true` (without backticks and without quotes), selected text will automatically be copied to the clipboard
copyOnSelect: false,
// if `true` (without backticks and without quotes), hyper will be set as the default protocol client for SSH
defaultSSHApp: true,
// if `true` (without backticks and without quotes), on right click selected text will be copied or pasted if no
// selection is present (`true` by default on Windows and disables the context menu feature)
quickEdit: false,
// choose either `'vertical'`, if you want the column mode when Option key is hold during selection (Default)
// or `'force'`, if you want to force selection regardless of whether the terminal is in mouse events mode
// (inside tmux or vim with mouse mode enabled for example).
macOptionSelectionMode: "vertical",
// URL to custom bell
// bellSoundURL: 'http://example.com/bell.mp3',
// Whether to use the WebGL renderer. Set it to false to use canvas-based
// rendering (slower, but supports transparent backgrounds)
webGLRenderer: true
// for advanced config flags please refer to https://hyper.is/#cfg
},
// a list of plugins to fetch and install from npm
// format: [@org/]project[#version]
// examples:
// `hyperpower`
// `@company/project`
// `project#1.0.1`
plugins: ["hypercwd", "hyperterm-close-on-left"],
// in development, you can create a directory under
// `~/.hyper_plugins/local/` and include it here
// to load it and avoid it being `npm install`ed
localPlugins: [],
keymaps: {
// Example
// 'window:devtools': 'cmd+alt+o',
}
};
# ========================================
# shell variables
# ========================================
export NVM_DIR="$HOME/.nvm"
# ========================================
# path manipulation
# ========================================
# Add ruby to PATH
export PATH="/usr/local/opt/ruby/bin:$PATH"
export PATH="/usr/local/lib/ruby/gems/2.6.3/bin:$PATH"
# ========================================
# Hooks
# ========================================
# load nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
#[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
# Automatically switch and load node versions when a directory has a `.nvmrc` file
load-nvmrc() {
local node_version="$(nvm version)" # Current node version
local nvmrc_path="$(nvm_find_nvmrc)" # Path to the .nvmrc file
# Check if there exists a .nvmrc file
if [ -n "$nvmrc_path" ]; then
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")")
# Check if the node version in .nvmrc is installed on the computer
if [ "$nvmrc_node_version" = "N/A" ]; then
# Install the node version in .nvmrc on the computer and switch to that node version
nvm install
# Check if the current node version matches the version in .nvmrc
elif [ "$nvmrc_node_version" != "$node_version" ]; then
# Switch node versions
nvm use
fi
# If there isn't an .nvmrc make sure to set the current node version to the default node version
elif [ "$node_version" != "$(nvm version default)" ]; then
echo "Reverting to nvm default version"
nvm use default
fi
}
# Run load-nvmrc on initial shell load
load-nvmrc
# ========================================
# aliases
# ========================================
# General Aliases
alias zsh-change="code ~/.zshrc"
alias zsh-update="source ~/.zshrc"
# colorls alias
alias l='colorls --group-directories-first --almost-all'
alias ll='colorls --group-directories-first --almost-all --long' # detailed list view
# ========================================
# prompt
# ========================================
SPACESHIP_PROMPT_ORDER=(host dir git_branch package node exec_time line_sep vi_mode jobs exit_code char)
SPACESHIP_GIT_BRANCH_SUFFIX=" "
SPACESHIP_PACKAGE_PREFIX=" ["
SPACESHIP_PACKAGE_SUFFIX="] "
SPACESHIP_PACKAGE_SYMBOL=""
SPACESHIP_GIT_SYMBOL="שׂ "
SPACESHIP_NODE_SYMBOL=" "
# init spaceship prompt
autoload -U promptinit; promptinit
prompt spaceship
# ========================================
# zsh plugins
# ========================================
# enable zsh-syntax-highlighting
# source ~/.zshrc_plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
# enable zsh-autosuggestions
source ~/.zshrc_plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
# enable zsh-autocomplete
source ~/.zshrc_plugins/zsh-autocomplete/zsh-autocomplete.plugin.zsh

Introduction

So we got a new machine, presumably a Macbook. If not, get out of here because we're probably gonna be wasting our time going through this.

Let's begin.

System Preferences

Inspired by sourabhbajaj.com, here are some preferences we should start with.

  1. Users & Groups

Update your Apple ID, add a profile picture and most importantly a password!

  1. Trackpad

Point & Click - Enable Tap to click with one finger Scroll & Zoom - Disable scroll direction: Natural More Gestures - Turn on everything and change three fingers to four fingers

  1. Accessibility

Under Pointer Control > Trackpad Options > Enable dragging (three finger drag)

  1. Dock

Small icons (2nd from smallest) Minimise windows into application icon Enable automatically hide and show the Dock Disable show recent applications in Dock

  1. Finder

Show home directory by default under Preferences Add Home and Code directory to Sidebar Under View - Enable path bar, tab bar and status bar Customize Toolbar - Add new folder option to toolbar

  1. Menubar

Change battery to show percentage, Use 24-hour clock (Mac Monterrey only)

  1. Accounts

Login to Google/iCloud to sync Calendar

Core Installations

Install the Command Line Tools to help Homebrew to compile things

xcode-select --install

Hook up some git configs

git config --global pull.ff only

Get homebrew itself so we can run brew

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Get both npm and yarn

brew install node
brew install yarn

Setting up Hyper.js to get rid of Terminal

This setup guide includes the following:

  • spaceship prompt
  • hyper terminal
  • hypercwd
  • hyperterm-close-on-left
  • zsh
  • zsh-syntax-highlighting
  • zsh-autosuggestions

Initial setup

Downloading hyper.js itself

brew install --cask hyper visual-studio-code

There isn't any special setup with VS Code here so just perform a Settings Sync and continue

spaceship-prompt

npm install -g spaceship-prompt

Go to Tools > Install Hyper CLI command in PATH to install the hyper command

If for some reason this doesn't work, make sure you have /usr/local/bin/hyper.

mkdir -p -m 775 /usr/local/bin // do this if the folder doesn't exist
ln -s /Applications/Hyper.app/Contents/Resources/bin/hyper /usr/local/bin/hyper

Add the content from .hyper.js to your local one and perform a Full Reload (View > Full Reload)

Add Fira Code fonts before updating our .hyper.js

Setting up zsh with autosuggestions and syntax highlighting

brew install zsh
chsh -s /bin/zsh // replaces bash with zsh

Create a folder to store your zsh plugins

mkdir ~/.zshrc_plugins

Install zsh-autosuggestions and zsh-syntax-highlighting

git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ~/.zshrc_plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-autosuggestions ~/.zshrc_plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-autocomplete ~/.zshrc_plugins/zsh-autocomplete

Add the content from .zshrc to your local one

If for some reason, zsh-autosuggestions do not work. cd into the directory and see if ruby complains about anything. In my case it needed rvm install ruby-2.5.3 before it started working.

Wrapping up

Installing nvm

We are installing nvm last to make sure we already have .zshrc setup

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash

Best to check the latest version before running this command. (Updated on 10.03.2022)

Installing commonly use programs

With the power of brew cask

brew install --cask google-chrome tower

Other good ones we might need.

  • slack
  • loom
  • sequel-ace
  • iterm

Other cool things I like to add

TODO: Setting up Homestead, Vagrant and Virtualbox

TODO: Update setup for iTerm2

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