Skip to content

Instantly share code, notes, and snippets.

@stevenguh
Last active November 16, 2021 01:54
Show Gist options
  • Save stevenguh/f1cf27c574cc71cc795d6762c874260d to your computer and use it in GitHub Desktop.
Save stevenguh/f1cf27c574cc71cc795d6762c874260d to your computer and use it in GitHub Desktop.
My zsh settings
# The best and greatest tmux.conf ever - improved!
# https://gist.github.com/rsp/f4770a1fe8ea7e2378ac3a16e01a2b53
# Here are some customizations done by Rafał Pocztarski:
# use Ctrl+Backslash instead of Ctrl+A or Ctrl+B
# use Slash to split vertically
# use Backslash to split horizontally
unbind-key C-b
set -g prefix 'C-\'
bind-key 'C-\' send-prefix
bind-key \ split-window -h
bind-key - split-window -v
# Everything below is taken from:
# The best and greatest tmux.conf ever
# by Chad Humphries
# https://gist.github.com/spicycode/1229612
# 0 is too far from ` ;)
set -g base-index 1
# Automatically set window title
set-window-option -g automatic-rename on
set-option -g set-titles on
set -g default-terminal screen-256color
set -g status-keys vi
set -g history-limit 10000
setw -g mode-keys vi
setw -g mode-mouse on
setw -g monitor-activity on
bind-key v split-window -h
bind-key s split-window -v
bind-key -r C-j resize-pane -D
bind-key -r C-k resize-pane -U
bind-key -r C-h resize-pane -L
bind-key -r C-l resize-pane -R
bind-key M-j resize-pane -D
bind-key M-k resize-pane -U
bind-key M-h resize-pane -L
bind-key M-l resize-pane -R
# Vim style pane selection
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
# Use Alt-vim keys without prefix key to switch panes
bind -n M-h select-pane -L
bind -n M-j select-pane -D
bind -n M-k select-pane -U
bind -n M-l select-pane -R
# Use Alt-arrow keys without prefix key to switch panes
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D
# Shift arrow to switch windows
bind -n S-Left previous-window
bind -n S-Right next-window
# No delay for escape key press
set -sg escape-time 0
# Reload tmux config
bind r source-file ~/.tmux.conf
# THEME
set -g status-bg black
set -g status-fg white
set -g window-status-current-bg white
set -g window-status-current-fg black
set -g window-status-current-attr bold
set -g status-interval 60
set -g status-left-length 30
set -g status-left '#[fg=green](#S) #(whoami)'
set -g status-right '#[fg=yellow]#(cut -d " " -f 1-3 /proc/loadavg)#[default] #[fg=white]%H:%M#[default]'
# Enable Powerlevel10k instant prompt. Should stay close to the top of ${HOME}/.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
# Install `zinit` if not installed
if [ ! -d "${HOME}/.zinit" ]; then
sh -c "$(curl -fsSL https://raw.githubusercontent.com/z-shell/zinit/main/doc/install.sh)"
fi
# Load `zinit`
source "${HOME}/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
############
# Plug-ins #
############
zinit atload'!source ~/.p10k.zsh' lucid nocd for \
romkatv/powerlevel10k
# Annex
zinit lucid light-mode for \
z-shell/z-a-patch-dl
# OMZSH
zinit wait lucid light-mode for \
OMZ::lib/key-bindings.zsh \
OMZ::lib/clipboard.zsh \
OMZ::lib/git.zsh \
OMZ::lib/completion.zsh \
OMZ::lib/directories.zsh
# Binary
zinit lucid wait light-mode as"program" from"gh-r" for \
mv"ripgrep* -> rg" \
pick"rg/rg" \
@BurntSushi/ripgrep \
atclone"cp -vf bat/autocomplete/bat.zsh _bat" \
atpull"%atclone" \
mv"bat* -> bat" pick"bat/bat" \
@sharkdp/bat \
atclone"cp -vf completions/exa.zsh _exa" \
atpull"%atclone" \
mv"bin/exa* -> exa" \
@ogham/exa
# Fzf
zinit lucid wait light-mode as"program" for \
from"gh-r" \
id-as"junegunn/fzf-tmux-binary" \
dl"https://raw.githubusercontent.com/junegunn/fzf/master/shell/completion.zsh -> _fzf" \
@junegunn/fzf \
pick"bin/fzf-tmux" \
multisrc"shell/*.zsh" \
@junegunn/fzf \
zinit wait lucid light-mode for \
atinit"ZINIT[COMPINIT_OPTS]=-C; zicompinit; zicdreplay" \
Aloxaf/fzf-tab \
z-shell/fast-syntax-highlighting \
blockf \
zsh-users/zsh-completions \
atload"!_zsh_autosuggest_start" \
zsh-users/zsh-autosuggestions
zinit wait lucid light-mode for \
Tarrasch/zsh-bd \
##################
# fzf-tab styles #
##################
# disable sort when completing `git checkout`
zstyle ':completion:*:git-checkout:*' sort false
# set descriptions format to enable group support
zstyle ':completion:*:descriptions' format '[%d]'
# set list-colors to enable filename colorizing
zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}
# switch group using `,` and `.`
zstyle ':fzf-tab:*' switch-group ',' '.'
#################
# Shell history #
#################
HISTFILE=${HOME}/.zsh_history
SAVEHIST=10000
HISTSIZE=10000
setopt BANG_HIST # Treat the '!' character specially during expansion.
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space.
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
setopt HIST_BEEP # Beep when accessing nonexistent history.
###########
# Aliases #
###########
alias shutdown='sudo shutdown now'
alias restart='sudo reboot'
alias suspend='sudo pm-suspend'
alias grep="grep -n --color"
alias ls="ls -h"
alias cp='cp -iv'
alias mv='mv -iv'
alias rm='rm -i'
# git
alias ga='git add'
alias gb='git branch'
alias gbr='git branch -r'
alias gc='git commit'
alias gcln='git branch --merged | egrep -v "(^\*|master|main)" | xargs git branch -d'
alias gco='git checkout'
alias gd='git diff'
alias gl='git log'
alias glo='git log --pretty="oneline"'
alias glol='git log --graph --oneline --decorate'
alias gp='git push'
alias gpl='git pull'
alias gplo='git pull origin'
alias gpo='git push origin'
alias gr='git remote'
alias grs='git remote show'
alias gs='git status'
alias gsh='git show'
alias gtd='git tag --delete'
alias gtdr='git tag --delete origin'
update() {
# Check if the cmd exists
# https://stackoverflow.com/a/677212/2563765
if command -v zinit >/dev/null 2>&1; then
zinit update
fi
if command -v brew >/dev/null 2>&1; then
brew update
brew outdated
brew upgrade
fi
if command -v npm >/dev/null 2>&1; then
npm install -g npm
fi
}
# Active conda
if [ -f "${HOME}/anaconda3/bin/activate" ]; then
source ${HOME}/anaconda3/bin/activate
fi
# Add andorid sdk for expo
if [ -d "${HOME}/Library/Android/sdk" ]; then
export ANDROID_SDK=${HOME}/Library/Android/sdk
export PATH=${HOME}/Library/Android/sdk/platform-tools:$PATH
fi
# Add flutter
if [ -d "${HOME}/dev/flutter/bin" ]; then
export PATH=${HOME}/dev/flutter/bin:$PATH
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment