Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jeremyfuksa/95a62675af64cf0c501ef7c89ba63421 to your computer and use it in GitHub Desktop.
Save jeremyfuksa/95a62675af64cf0c501ef7c89ba63421 to your computer and use it in GitHub Desktop.
Setting up zsh just the way I like it.

Oh my zsh: The Jeremy Fuksa Way

Install and enable plugins

  • sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

Enable plugins

git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
git clone https://github.com/denysdovhan/spaceship-prompt.git "$ZSH_CUSTOM/themes/spaceship-prompt"
ln -s "$ZSH_CUSTOM/themes/spaceship-prompt/spaceship.zsh-theme" "$ZSH_CUSTOM/themes/spaceship.zsh-theme"

Edit .zshrc

  • nano ~/.zshrc
  • Replace file contents with the following:
export ZSH="$HOME/.oh-my-zsh"

ZSH_THEME="spaceship"
SPACESHIP_PROMPT_ADD_NEWLINE="true"
SPACESHIP_CHAR_SYMBOL=" ➜ "
SPACESHIP_CHAR_PREFIX="\ue709"
SPACESHIP_CHAR_SUFFIX=(" ")
SPACESHIP_CHAR_COLOR_SUCCESS="green"
SPACESHIP_PROMPT_DEFAULT_PREFIX="$USER"
SPACESHIP_PROMPT_FIRST_PREFIX_SHOW="true"
SPACESHIP_USER_SHOW="true"

zstyle ':omz:update' mode auto
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh

# Remove if not a Raspberry Pi in a Geekworm SATA case
alias xoff='sudo /usr/local/bin/x-c1-softsd.sh'

update_git_repo() {
	local repo_path="$1"
	cd "$repo_path" || return 1
	git pull origin
	cd -
}

update-all() {
	(
		update_git_repo "$ZSH_CUSTOM/plugins/zsh-syntax-highlighting"
		update_git_repo "$ZSH_CUSTOM/plugins/zsh-autosuggestions"
		update_git_repo "$ZSH_CUSTOM/themes/spaceship-prompt"
		sudo apt update -y
		sudo apt upgrade -y
		sudo apt autoremove -y
	)
}

install() {
	if [ $# -eq 0 ]; then
		echo "Usage: install package1 [package2 ...]"
		return 1
	fi

	(command sudo apt install -y "$@")
}

ngensite() {
	if [ $# -eq 1 ]; then
		ln -s "/etc/nginx/sites-available/$1" "/etc/nginx/sites-enabled/$1"
		echo "Site enabled: $1"
	else      
		echo "Usage: ngensite <site_name>"
	fi
}

ngdissite() {
	if [ $# -eq 1 ]; then
		rm "/etc/nginx/sites-enabled/$1"
		echo "Site disabled: $1"
	else
		echo "Usage: ngdissite <site_name>"
	fi
}

bindkey '[C' forward-word
source $ZSH_CUSTOM/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh

  • source ~/.zshrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment