Skip to content

Instantly share code, notes, and snippets.

@SturmB
Created June 12, 2023 14:18
Show Gist options
  • Save SturmB/78d380e49981d7796cc2fc8582b94174 to your computer and use it in GitHub Desktop.
Save SturmB/78d380e49981d7796cc2fc8582b94174 to your computer and use it in GitHub Desktop.
My Zsh config files
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.zshrc.
# Initialization code that may require console input (password prompts, [y/n]
# confirmations, etc.) must go above this block; everything else may go below.
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
fi
export TERM="xterm-256color"
export EDITOR="nano"
export PATH="$PATH:$HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
HIST_STAMPS="yyyy-mm-dd"
UPDATE_ZSH_DAYS="30"
COMPLETION_WAITING_DOTS="true"
# ADOTDIR="$HOME/.antigen"
ANTIGEN_BUNDLES="$HOME/.antigen/bundles"
ANTIGEN_PLUGIN_UPDATE_DAYS="30"
ANTIGEN_SYSTEM_UPDATE_DAYS="30"
source "$HOME/antigen.zsh"
antigen use oh-my-zsh
antigen bundle command-not-found
antigen bundle docker
antigen bundle docker-compose
antigen bundle fancy-ctrl-z
antigen bundle git-extras
antigen bundle gnu-utils
antigen bundle kubectl
antigen bundle pip
antigen bundle rake
antigen bundle systemd
antigen bundle python
#antigen bundle tmux
#antigen bundle zsh_reload
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle popstas/zsh-command-time
antigen bundle unixorn/autoupdate-antigen.zshplugin
antigen bundle urbainvaes/fzf-marks
antigen bundle ytet5uy4/fzf-widgets
# will fixed in zsh-autosuggestion v0.4 - https://github.com/zsh-users/zsh-autosuggestions/pull/218
if (( ZSHRC_LOAD_ONCE++ == 0 )); then
antigen bundle zdharma/[email protected]
fi
antigen bundle joel-porquet/zsh-dircolors-solarized
antigen bundle romkatv/powerlevel10k
antigen bundle zsh-users/zsh-syntax-highlighting
antigen bundle zsh-users/zsh-completions
antigen bundle zsh-users/zsh-autosuggestions
antigen bundle colored-man-pages
antigen bundle npm
antigen bundle sudo
antigen bundle git
POWERLEVEL9K_INSTALLATION_PATH=$ANTIGEN_BUNDLES/bhilburn/powerlevel9k/powerlevel9k.zsh-theme
antigen theme romkatv/powerlevel10k powerlevel10k
antigen apply
###
unsetopt share_history
autoload -Uz copy-earlier-word
zle -N copy-earlier-word
# hotkeys
bindkey '\e[1~' beginning-of-line
bindkey '\e[4~' end-of-line
bindkey '^@' fzf-select-widget
bindkey '^@.' fzf-edit-dotfiles
bindkey '^@c' fzf-change-directory
bindkey '^@f' fzf-edit-files
bindkey '^@k' fzf-kill-processes
bindkey '^@s' fzf-exec-ssh
bindkey '^\' fzf-change-recent-directory
bindkey '^r' fzf-insert-history
bindkey '^xf' fzf-insert-files
bindkey '^xd' fzf-insert-directory
bindkey '^@g' fzf-select-git-widget
bindkey '^@ga' fzf-git-add-files
bindkey '^@gc' fzf-git-change-repository
bindkey '^@gco' fzf-git-checkout-branch
bindkey '^@gd' fzf-git-delete-branches
bindkey '^@gh' fzf-select-github-widget
bindkey '^@ghi' fzf-github-show-issue
bindkey '^@ghe' fzf-github-edit-issue
bindkey '^@gho' fzf-github-open-issue
bindkey '^@ghc' fzf-github-close-issue
bindkey '^@ghco' fzf-github-comment-issue
bindkey '^@d' fzf-select-docker-widget
bindkey '^@dk' fzf-docker-kill-containers
bindkey '^@dl' fzf-docker-logs-container
bindkey '^@dr' fzf-docker-remove-containers
bindkey '^@dri' fzf-docker-remove-images
bindkey '^@drv' fzf-docker-remove-volumes
bindkey '^@dsa' fzf-docker-start-containers
bindkey '^@dso' fzf-docker-stop-containers
bindkey '^U' autosuggest-accept
# aliases
alias 'apt-update-list-upgrade'="apt update && apt upgrade --dry-run | grep Inst | sort | fzf && apt upgrade"
alias 'dfh'="df -h | grep -v docker"
alias 'ubuntu-release'="lsb_release -a"
# fzf
export FZF_TMUX=0
export FZF_DEFAULT_OPTS="--height 100% --reverse"
# fzf-widgets: fzf-change-reset-dir
autoload -Uz chpwd_recent_dirs cdr add-zsh-hook
add-zsh-hook chpwd chpwd_recent_dirs
declare -p FZF_WIDGETS_OPTS > /dev/null 2>&1 && FZF_WIDGETS_OPTS[insert-history]="--exact"
declare -p FZF_WIDGET_OPTS > /dev/null 2>&1 && FZF_WIDGET_OPTS[insert-history]="--exact"
# zsh-autosuggestions
ZSH_AUTOSUGGEST_BUFFER_MAX_SIZE=15
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=240" # gray highlight
# powerlevel9k
POWERLEVEL9K_SHORTEN_DIR_LENGTH=3
POWERLEVEL9K_STATUS_VERBOSE=0
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status background_jobs vcs command_execution_time time)
DEFAULT_USER=$USER
POWERLEVEL9K_ALWAYS_SHOW_CONTEXT=false
POWERLEVEL9K_ALWAYS_SHOW_USER=false
POWERLEVEL9K_CUSTOM_COMMAND_TIME="zsh_command_time"
POWERLEVEL9K_CUSTOM_COMMAND_TIME_BACKGROUND="248"
POWERLEVEL9K_CUSTOM_COMMAND_TIME_FOREGROUND="000"
# https://github.com/bhilburn/powerlevel9k#command_execution_time
POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD="3"
POWERLEVEL9K_PROMPT_ON_NEWLINE=false
POWERLEVEL9K_RPROMPT_ON_NEWLINE=false
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_CONTEXT_DEFAULT_FOREGROUND="255"
POWERLEVEL9K_CONTEXT_DEFAULT_BACKGROUND="024"
POWERLEVEL9K_CONTEXT_REMOTE_FOREGROUND="255"
POWERLEVEL9K_CONTEXT_REMOTE_BACKGROUND="024"
POWERLEVEL9K_CONTEXT_ROOT_FOREGROUND="255"
POWERLEVEL9K_CONTEXT_ROOT_BACKGROUND="124"
POWERLEVEL9K_DIR_DEFAULT_FOREGROUND="255"
POWERLEVEL9K_DIR_DEFAULT_BACKGROUND="240"
POWERLEVEL9K_DIR_HOME_FOREGROUND="255"
POWERLEVEL9K_DIR_HOME_BACKGROUND="240"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_FOREGROUND="255"
POWERLEVEL9K_DIR_HOME_SUBFOLDER_BACKGROUND="240"
POWERLEVEL9K_DIR_ETC_FOREGROUND="255"
POWERLEVEL9K_DIR_ETC_BACKGROUND="240"
POWERLEVEL9K_DIR_PATH_HIGHLIGHT_FOREGROUND="255"
POWERLEVEL9K_DIR_PATH_HIGHLIGHT_BACKGROUND="240"
POWERLEVEL9K_VCS_CLEAN_BACKGROUND="100"
POWERLEVEL9K_VCS_MODIFIED_BACKGROUND="094"
POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND="094"
POWERLEVEL9K_VCS_CLEAN_FOREGROUND="232"
POWERLEVEL9K_VCS_MODIFIED_FOREGROUND="232"
POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND="232"
POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND="000"
POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND="248"
# Aliases
alias suser='su -'
source /etc/profile
# user configs
[[ -r /etc/zsh/zshrc.local ]] && source /etc/zsh/zshrc.local
[[ -r "$HOME/.zshrc.local" ]] && source "$HOME/.zshrc.local"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# User configuration
# export MANPATH="/usr/local/man:$MANPATH"
# You may need to manually set your language environment
# export LANG=en_US.UTF-8
# Preferred editor for local and remote sessions
# if [[ -n $SSH_CONNECTION ]]; then
# export EDITOR='vim'
# else
# export EDITOR='mvim'
# fi
# Compilation flags
# export ARCHFLAGS="-arch x86_64"
# Set personal aliases, overriding those provided by oh-my-zsh libs,
# plugins, and themes. Aliases can be placed here, though oh-my-zsh
# users are encouraged to define aliases within the ZSH_CUSTOM folder.
# For a full list of active aliases, run `alias`.
#
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
# This was inserted during fzf's installer. NJ version is below.
# [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
#source $(dirname $(gem which colorls))/tab_complete.sh
# Limit number of lines and entries in the history.
#export HISTFILESIZE=50000
#export HISTSIZE=50000
# Add a timestamp to each command.
#export HISTTIMEFORMAT="%Y/%m/%d %H:%M:%S: "
# Duplicate lines and lines starting with a space are not put into the history.
#export HISTCONTROL=ignoreboth
# Append to the history file, don't overwrite it.
#setopt APPEND_HISTORY
# Improve output of less for binary files.
#[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# Load aliases if they exist.
[ -f "$HOME/.aliases" ] && source "$HOME/.aliases"
# Enable a better reverse search experience.
# Requires: https://github.com/junegunn/fzf (to use fzf in general)
# Requires: https://github.com/BurntSushi/ripgrep (for using rg below)
#export FZF_DEFAULT_COMMAND="rg --files --hidden --follow --glob '!.git'"
#[ -f "$HOME/.fzf.zsh" ] && source "$HOME/.fzf.zsh"
# WSL (Windows Subsystem for Linux) specific settings.
if grep -qE "(Microsoft|WSL)" /proc/version &>/dev/null; then
# Adjustments for WSL's file / folder permission metadata.
if [ "$(umask)" = "0000" ]; then
umask 0022
fi
fi
# Load SSH keys
if [ -z "$SSH_AUTH_SOCK" ] ; then
eval `ssh-agent -s`
ssh-add
# ssh-add ~/.ssh/id_ed25519_iel
# ssh-add ~/.ssh/id_rsa_personal
fi
export DO_API_TOKEN=8f90a71407fcc93d39a8ad8254943a6adb82e6d6f14dd4e8e26b0a65f11aa767
export PATH="$HOME/bin:$HOME/.composer/vendor/bin:$PATH"
# Not sure why these Python-related lines are here. Commenting out for now.
#export PATH="/home/sturm/.pyenv/bin:$PATH"
#eval "$(pyenv init -)"
#eval "$(pyenv virtualenv-init -)"
export PATH="$HOME/.local/bin:$PATH"
#export PATH="/c/laragon/bin/php/php-7.2.19-Win32-VC15-x64:$PATH"
export JAVA_HOME=/usr/lib/jvm/java-11-openjdk-amd64
export PATH=$PATH:$JAVA_HOME/bin
export ANDROID_HOME=~/dev/android
PATH=$ANDROID_HOME/cmdline-tools/tools:$PATH
PATH=$ANDROID_HOME/cmdline-tools/tools/bin:$PATH
PATH=$ANDROID_HOME/platform-tools:$PATH
export TERM=xterm-256color
# NNN
export NNN_PLUG='j:jump;p:preview-tui;'
BLK="04" CHR="04" DIR="04" EXE="00" REG="00" HARDLINK="00" SYMLINK="06" MISSING="00" ORPHAN="01" FIFO="0F" SOCK="0F" OTHER="02"
export NNN_FCOLORS="$BLK$CHR$DIR$EXE$REG$HARDLINK$SYMLINK$MISSING$ORPHAN$FIFO$SOCK$OTHER"
export NNN_FIFO="/tmp/nnn.fifo"
export NNN_OPENER="~/.config/nnn/plugins/nuke"
export NNN_OPTS="cx"
export NNN_BMS="m:/volume1/data/media;t:/volume1/data/torrents;"
n ()
{
# Block nesting of nnn in subshells
if [ -n $NNNLVL ] && [ "${NNNLVL:-0}" -ge 1 ]; then
echo "nnn is already running"
return
fi
# The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set)
# To cd on quit only on ^G, either remove the "export" as in:
# NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# (or, to a custom path: NNN_TMPFILE=/tmp/.lastd)
# or, export NNN_TMPFILE after nnn invocation
NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd"
# Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn
# stty start undef
# stty stop undef
# stty lwrap undef
# stty lnext undef
nnn "$@"
if [ -f "$NNN_TMPFILE" ]; then
. "$NNN_TMPFILE"
rm -f "$NNN_TMPFILE" > /dev/null
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment