Skip to content

Instantly share code, notes, and snippets.

@ackerleytng
Last active January 3, 2023 13:50
Show Gist options
  • Save ackerleytng/6df95a3e661f2a2eca61bc9cebe9142c to your computer and use it in GitHub Desktop.
Save ackerleytng/6df95a3e661f2a2eca61bc9cebe9142c to your computer and use it in GitHub Desktop.
zsh config
if systemctl -q is-active graphical.target && [[ ! $DISPLAY && $XDG_VTNR -eq 1 ]]; then
exec startx
fi
# ---------------------------------
# For emacs
# ---------------------------------
export ALTERNATE_EDITOR=""
export EDITOR="emacsclient -c"
export VISUAL="emacsclient -c -n"
# golang
export GOPATH=$HOME/go
# For pyenv
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
# for yarn
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
# spark
export SPARK_HOME=/opt/spark
export PATH=$PATH:$SPARK_HOME/bin
# cuda
export PATH=$PATH:/opt/cuda/bin
# /opt
export PATH=$PATH:/opt/bin
# intellij
export PATH=$PATH:$HOME/installs/intellij-idea/bin
# add $HOME/bin to path
export PATH=$PATH:$HOME/bin
### Added by Zinit's installer
if [[ ! -f $HOME/.zinit/bin/zinit.zsh ]]; then
print -P "%F{33}▓▒░ %F{220}Installing %F{33}DHARMA%F{220} Initiative Plugin Manager (%F{33}zdharma/zinit%F{220})…%f"
command mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
command git clone https://github.com/zdharma/zinit "$HOME/.zinit/bin" && \
print -P "%F{33}▓▒░ %F{34}Installation successful.%f%b" || \
print -P "%F{160}▓▒░ The clone has failed.%f%b"
fi
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
# Load a few important annexes, without Turbo
# (this is currently required for annexes)
zinit light-mode for \
zinit-zsh/z-a-rust \
zinit-zsh/z-a-as-monitor \
zinit-zsh/z-a-patch-dl \
zinit-zsh/z-a-bin-gem-node
### End of Zinit's installer chunk
# ---------------------------------------------------------
# Add programs using zinit
# ---------------------------------------------------------
# junegunn/fzf-bin
zinit pack"bgn-binary+keys" for fzf
# sharkdp/fd
zinit ice as"command" from"gh-r" mv"fd* -> fd" pick"fd/fd"
zinit light sharkdp/fd
# sharkdp/bat
zinit ice as"command" from"gh-r" mv"bat* -> bat" pick"bat/bat"
zinit light sharkdp/bat
# pyenv
zinit ice atclone'PYENV_ROOT="$PWD" ./libexec/pyenv init - > zpyenv.zsh && git clone https://github.com/pyenv/pyenv-virtualenv ./plugins/pyenv-virtualenv' \
atinit'export PYENV_ROOT="$PWD"' atpull"%atclone" \
as'command' pick'bin/pyenv' src"zpyenv.zsh" nocompile'!'
zinit light pyenv/pyenv
# sdkman
zinit ice as"program" pick"$ZPFX/sdkman/bin/sdk" id-as'sdkman' run-atpull \
atclone"curl https://get.sdkman.io/ | SDKMAN_DIR=$ZPFX/sdkman bash" \
atpull"SDKMAN_DIR=$ZPFX/sdkman sdk selfupdate" \
atinit"export SDKMAN_DIR=$ZPFX/sdkman; source $ZPFX/sdkman/bin/sdkman-init.sh"
zinit light zdharma/null
# ---------------------------------------------------------
# zinit config
# ---------------------------------------------------------
zinit ice blockf atpull'zinit creinstall -q .'
zinit light zsh-users/zsh-completions
zstyle ':completion:*' menu select
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Za-z}' '+l:|=* r:|=*'
zinit light agkozak/zsh-z
autoload compinit
compinit
# Add colours to LS
zinit ice wait"0c" lucid reset \
atclone"local P=${${(M)OSTYPE:#*darwin*}:+g}
\${P}sed -i \
'/DIR/c\DIR 38;5;63;1' LS_COLORS; \
\${P}dircolors -b LS_COLORS > c.zsh" \
atpull'%atclone' pick"c.zsh" nocompile'!' \
atload'zstyle ":completion:*" list-colors “${(s.:.)LS_COLORS}”'
zinit light trapd00r/LS_COLORS
alias ls='ls --color=auto'
# ---------------------------------------------------------
# prompt
# ---------------------------------------------------------
zinit ice pick"async.zsh" src"pure.zsh"
zinit light sindresorhus/pure
# ---------------------------------------------------------
# history
# ---------------------------------------------------------
typeset -g HISTSIZE=290000 SAVEHIST=290000 HISTFILE=~/.zhistory
setopt inc_append_history
setopt share_history
setopt hist_ignore_space
# ---------------------------------------------------------
# setopts
# ---------------------------------------------------------
setopt correct
setopt interactive_comments
setopt no_clobber
setopt auto_pushd
setopt complete_in_word
setopt complete_aliases
setopt auto_list
setopt auto_menu
# ---------------------------------------------------------
# autoloads
# ---------------------------------------------------------
autoload -Uz allopt zed zmv zcalc colors
colors
autoload -Uz url-quote-magic
zle -N self-insert url-quote-magic
autoload -Uz select-word-style
select-word-style bash
# ---------------------------------------------------------
# Aliases
# ---------------------------------------------------------
alias oe="emacsclient -c -n"
alias open=xdg-open
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
alias feh='feh --auto-zoom --scale-down --auto-rotate'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment