Skip to content

Instantly share code, notes, and snippets.

@nasyxx nasyxx/zshrc.org Secret
Created Feb 13, 2020

Embed
What would you like to do?
zshrc 2020.02.12

Prologue

New config with new plugin management named zinit.

This kind of config uses literature programming to generate .zshrc to ~~~.

Path & Flags

PATH

export NPATH="/Users/Nasy/.local/bin"
export NPATH="/Users/Nasy/.cargo/bin:$NPATH"
export NPATH="/Users/Nasy/.pyenv/bin:$NPATH"
export NPATH="/Users/Nasy/.pyenv/shims:$NPATH"
export NPATH="/Users/Nasy/.poetry/bin:$NPATH"

export NPATH="$NPATH:/usr/local/opt/libxml2/bin"
# export NPATH="$NPATH:/usr/local/opt/llvm/bin"
export NPATH="$NPATH:/usr/local/opt/ncurses/bin"
export NPATH="$NPATH:/usr/local/opt/bison/bin"

PKG_CONFIG_PATH

export PCP="/usr/local/opt/libffi/lib/pkgconfig"
export PCP="/usr/local/opt/libxml2/lib/pkgconfig:$PCP"
export PCP="/usr/local/opt/ncurses/lib/pkgconfig:$PCP"

Flags

export LDFLAGS="-L/usr/local/opt/bison/lib"
# export LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"
# export CPPFLAGS="-I/usr/local/opt/llvm/include"

Load

export PATH="$NPATH:$PATH"
export PKG_CONFIG_PATH="$PCP:$PKG_CONFIG_PATH"

Load

Load zinit

source ~/.zinit/bin/zinit.zsh

Theme

SPACESHIP_PROMPT_ORDER=(
  time          # Time stamps section
  user          # Username section
  battery       # Battery level and status
  host          # Hostname section
  git           # Git section (git_branch + git_status)
  hg            # Mercurial section (hg_branch  + hg_status)
  package       # Package version
  node          # Node.js section
  ruby          # Ruby section
  elixir        # Elixir section
  xcode         # Xcode section
  swift         # Swift section
  golang        # Go section
  php           # PHP section
  rust          # Rust section
  haskell       # Haskell Stack section
  julia         # Julia section
  docker        # Docker section
  aws           # Amazon Web Services section
  venv          # virtualenv section
  conda         # conda virtualenv section
  pyenv         # Pyenv section
  dotnet        # .NET section
  ember         # Ember.js section
  #kubecontext   # Kubectl context section
  terraform     # Terraform workspace section
  exec_time     # Execution time
  line_sep      # Line break
  jobs          # Background jobs indicator
  dir           # Current directory section
  exit_code     # Exit code section
  line_sep
  char          # Prompt character
)

SPACESHIP_CHAR_SYMBOL="λ≻ "

SPACESHIP_TIME_SHOW=true
SPACESHIP_TIME_FORMAT=%D{%c}
SPACESHIP_TIME_COLOR=green

SPACESHIP_DIR_TRUNC=3

SPACESHIP_DIR_TRUNC_PREFIX="…/"

SPACESHIP_USER_SHOW=always
SPACESHIP_USER_COLOR=magenta

SPACESHIP_EXEC_TIME_COLOR=cyan

SPACESHIP_BATTERY_SHOW=always

SPACESHIP_EXIT_CODE_SHOW=true

PS1="READY ?"
zinit ice wait'!'
zinit light denysdovhan/spaceship-prompt

Plugins

quotify

Quotify is an Zsh plugin to display inspiring coding quotes and haikus when starting up your favourite shell 🤓

https://github.com/damofthemoon/zsh-quotify

zinit light damofthemoon/zsh-quotify

alias-tips

A plugin to help remembering those aliases you defined once.

zinit ice wait"2"
zinit light djui/alias-tips

auto-ls

A zsh plugin for auto-ls.

https://github.com/desyncr/auto-ls

auto-ls-exa () {
    exa -Gla --group-directories-first --git --icons
}

zinit ice wait"0"
zinit load desyncr/auto-ls
export AUTO_LS_COMMANDS=(exa)

autopair

Auto-close and delete matching delimiters in zsh.

https://github.com/hlissner/zsh-autopair

zinit ice wait"2"
zinit load hlissner/zsh-autopair

autosuggestions

Fish-like autosuggestions for zsh.

https://github.com/zsh-users/zsh-autosuggestions

zinit ice wait atload"_zsh_autosuggest_start"
zinit light zsh-users/zsh-autosuggestions

clipboard

Zsh clipboard plugin who adds cross-platform helper functions to access the system clipboard. Works on macOS, X11 (and Wayland) and Cygwin.

https://github.com/zpm-zsh/clipboard

zinit ice wait"2"
zinit light zpm-zsh/clipboard

colorize

Colorize the output of various programs.

https://github.com/zpm-zsh/colorize

zinit ice wait"2"
zinit light zpm-zsh/colorize

colors

Enhanced colors for zsh.

https://github.com/zpm-zsh/colors

echo $c_bold Bold text $c_reset
echo $c_dim Dim text $c_reset
echo $c_italic Italic or Coursive text $c_reset
echo $c_underline Underline text $c_reset
echo $c_blink Blink text $c_reset "<- Blink"
echo $c_reverse Reverse text $c_reset
echo $c_hidden Hidden text $c_reset "<- Hidden text"
echo $c_strike Strike or Strikethrough text $c_reset
echo $c_overline Overlined text $c_reset
echo
echo $c[red] Red color $c_reset
echo $c[bg_red] Red Background $c_reset
zinit ice wait"2"
zinit light zpm-zsh/colors

Completions

Additional completion definitions for Zsh.

https://github.com/zsh-users/zsh-completions

zinit ice wait blockf atpull'zinit creinstall -q .'
zinit light zsh-users/zsh-completions

enhancd

A next-generation cd command with your interactive filter.

https://github.com/b4b4r07/enhancd

zinit ice wait"2" pick"init.sh"
zinit light b4b4r07/enhancd

export ENHANCD_FILTER=sk:fzy:fzf:peco

exercism

An Excercism.io plugin for Oh-My-Zsh ZSH Framework compatible frameworks that will help you to improve your experience on the tool.

https://github.com/fabiokiatkowski/exercism.plugin.zsh

zinit light fabiokiatkowski/exercism.plugin.zsh

Fast Syntax Highlighting (F-Sy-H)

Syntax-highlighting for Zshell.

https://github.com/zdharma/fast-syntax-highlighting

zinit ice atload"fast-theme sv-plant > /dev/null" atinit"zpcompinit"
zinit light zdharma/fast-syntax-highlighting

Funcitonal

ZSH higher order functions.

https://github.com/Tarrasch/zsh-functional

zinit light Tarrasch/zsh-functional

Fzf tab

Replace zsh’s default completion selection menu with fzf!

zinit light Aloxaf/fzf-tab
export FZF_TAB_COMMAND=sk
export FZF_TAB_OPTS=(
    --ansi   # Enable ANSI color support, necessary for showing groups
    '--color=hl:$(( $#headers == 0 ? 108 : 255 ))'
    --expect='/'
    --nth=1,2 --delimiter='\0'  # Don't search FZF_TAB_PREFIX
    --layout=reverse --height=70%
    --tiebreak=begin -m --bind=tab:down,ctrl-j:accept,change:top,ctrl-space:toggle --cycle
    '--query=$query'   # $query will be expanded to query string at runtime.
    '--header-lines=$#headers' # $#headers will be expanded to lines of headers at runtime
)

history-search-multi-word

Multi-word, syntax highlighted history searching for Zsh.

https://github.com/zdharma/history-search-multi-word

zinit load zdharma/history-search-multi-word

iterm-tab-colors

Tabs automatically change colors depending on the folder you are in.

https://github.com/tysonwolker/iterm-tab-colors

zinit light tysonwolker/iterm-tab-colors

oh-my-matrix

Turns your terminal into the Matrix just for fun

https://github.com/amstrad/oh-my-matrix

zinit light amstrad/oh-my-matrix

pyenv-lazy-load

A zsh plugin for lazy loading of pyenv. The initial eval “$(pyenv init -)” is executed the first time pyenv is called

https://github.com/davidparsson/zsh-pyenv-lazy

zinit light davidparsson/zsh-pyenv-lazy

z

z - jump around

https://github.com/rupa/z

zinit ice pic"z.sh"
zinit load rupa/z

Oh-my-zsh Lib & Plugins

Lib

zinit ice svn pick"/dev/null" multisrc"*.zsh"
zinit snippet OMZ::lib

command-not-found

This plugin uses the command-not-found package for zsh to provide suggested packages to be installed if a command cannot be found.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/command-not-found

https://github.com/Homebrew/homebrew-command-not-found

zinit ice wait
zinit snippet OMZ::plugins/command-not-found/command-not-found.plugin.zsh

extract

This plugin defines a function called extract that extracts the archive file you pass it, and it supports a wide variety of archive filetypes.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/extract

zinit ice wait
zinit snippet OMZ::plugins/extract/extract.plugin.zsh

git

The git plugin provides many aliases and a few useful functions.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git

zinit ice wait atload"unalias grv"
zinit snippet OMZ::plugins/git/git.plugin.zsh

dash

This plugin adds command line functionality for Dash, an API Documentation Browser for macOS. This plugin requires Dash to be installed to work.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/dash

zinit ice wait
zinit snippet OMZ::plugins/dash/dash.plugin.zsh

iterm

This plugin adds a few functions that are useful when using iTerm2.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/iterm2

zinit ice wait
zinit snippet OMZ::plugins/iterm2/iterm2.plugin.zsh

pip

This plugin adds completion for pip, the Python package manager.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/pip

zinit ice wait
zinit snippet OMZ::plugins/pip/pip.plugin.zsh

ripgrep

This plugin adds completion for the text search tool ripgrep, also known as rg.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/ripgrep

zinit ice wait as"completion"
zinit snippet OMZ::plugins/ripgrep/_ripgrep

rust

This plugin adds completion for rustc, the compiler for the Rust programming language.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/rust

zinit ice wait as"completion"
zinit snippet OMZ::plugins/rust/_rust

stack

This plugin provides completion for Stack.

https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/stack

zinit ice wait
zinit snippet OMZ::plugins/stack/stack.plugin.zsh

Configs

bat

export BAT_CONFIG_PATH=/Users/Nasy/.config/bat/bat.conf

Aliases

My aliases

alias lsa="exa -Gla --group-directories-first --git --icons"

alias j=z

alias ccat=bat

alias ghcrepl="stack exec -- ghci-color"

Functions

My useful functions.

update () {
    update_the=$c[red]$c_bold"Now beign to updating..."

    echo $update_the$c[green]"homebrew\n$c[yellow]==> brew update\n$c_reset"
    brew update

    echo $c_bold$c[yellow]"==> brew outdated\n$c_reset"
    outdated=$(brew outdated)
    echo $outdated

    echo $c_bold$c[yellow]"==> brew upgrade\n$c_reset"
    brew upgrade

    echo $update_the$c[green]"cargo\n$c[yellow]==> cargo install-update -a\n$c_reset"
    cargo install-update -a

    # echo $update_the$c[green]"Python\n$c[yellow]==> pipupgrade\n$c_reset"
    # pipupgrade -s -y
    # pipupgrade --l -y -j 8 --pip-path pip

    echo $c_bold$c[yellow]"==> pipx upgrade-all\n$c_reset"
    pipx upgrade-all

    echo $update_the$c[green]"Node\n$c[yellow]==> npm up -g\n$c_reset"
    npm up -g

    echo $update_the$c[green]"homebrew cask\n$c[yellow]==> brew cu -a -y\n$c_reset"
    brew cu -a -y
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.