[Ubuntu] My .zshrc

4 minute read

My .zshrc

########################
# INITS
########################
ZSH=$HOME/.oh-my-zsh                # Path to your oh-my-zsh configuration.
ZSH_CUSTOM=$HOME/.oh-my-zsh/custom                # Path to your oh-my-zsh configuration.
ZSH_DISABLE_COMPFIX=true            # Disable compfix which checks insecureness of folders (disabling it for docker)
DISABLE_AUTO_TITLE=true             # Disable shell name change (for TMUX)
HIST_STAMPS="mm/dd/yyyy"            # unable hisotry time stamp
#ZSH_THEME="robbyrussell"            # Theme

ZSH_THEME="spaceship-prompt/spaceship"            # Theme
########################
# PLUGINS
########################
plugins=(git zsh_reload zsh-autosuggestions zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh

########################
# SETTING VI MODE
########################
export EDITOR="vim -u ~/.vim/command_mode.vim"  # Set diffualt command line editor
set -o vi #bindkey -v                               # Set command line editing mode

export KEYTIMEOUT=1                                 # Make Vi mode transitions faster (KEYTIMEOUT is in hundredths of a second)

# key binding for deleting backward in insert mode
bindkey '^?' backward-delete-char

# key bindings for history searching
bindkey -M vicmd '/' history-incremental-search-backward
bindkey -M vicmd '?' history-incremental-search-forward

# key bindings for history searching with arrow keys
bindkey "^[OA" up-line-or-beginning-search
bindkey "^[OB" down-line-or-beginning-search
bindkey -M vicmd "k" up-line-or-beginning-search
bindkey -M vicmd "j" down-line-or-beginning-search

# key binkding for vim-like editor opening
bindkey -M vicmd v edit-command-line
bindkey -M vicmd "^V" edit-command-line

function zle-keymap-select() {
    zle reset-prompt
    zle -R
}
zle -N zle-keymap-select

#########################
# SPACESHIP THEME SETTING
#########################
source ~/.zsh/set_spaceship.zsh

########################
# KEY BINDINGS
########################
#autosuggestions
bindkey '^l' autosuggest-accept
bindkey '^h' autosuggest-clear

########################
# MISC
########################
#set prompt for docker cont
export SPACESHIP_PROMPT_FIRST_PREFIX_SHOW="true"
export SPACESHIP_USER_PREFIX=""
export SPACESHIP_HOST_SUFFIX=" "
if [ -f /.dockerenv ]; then
    export SPACESHIP_HOST_PREFIX="@%F{$SPACESHIP_HOST_COLOR}docker-"
    #export SPACESHIP_HOST_SUFFIX="$SPACESHIP_PROMPT_DEFAULT_SUFFIX%F{cyan}%{🐳%2G%}%f"
    export SPACESHIP_USER_NAME="junyonglee"

    # >>> conda initialize >>>
    # !! Contents within this block are managed by 'conda init' !!
    __conda_setup="$('/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
    if [ $? -eq 0 ]; then
        eval "$__conda_setup"
    else
        if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/anaconda3/etc/profile.d/conda.sh"  # commented out by conda initialize
        else
# export PATH="/anaconda3/bin:$PATH"  # commented out by conda initialize
        fi
    fi
    unset __conda_setup
    # <<< conda initialize <<<

fi

# set alias
alias tmux="tmux -2 -u"
alias count_files="find . -type f | wc -l"
alias reload_history="fc -R ~/.zsh_history"
alias dotdrop=/Jarvis/workspace/junyonglee/dotfiles/dotdrop.sh --cgf=/Jarvis/workspace/junyonglee/dotfiles/config.yaml
alias glf='git log --graph --all --pretty=format:"%h%x09%C(auto)%d%Creset%x20%s"'
alias glb='git log --graph --simplify-by-decoration --branches --topo-order --pretty=format:"%C(auto)%D%Creset"'
alias wglb="watch -c -n 3 -t 'git log --graph --simplify-by-decoration --branches --pretty=format:\"%C(auto)%D%Creset\"'"
#alias wglb="watch -c -n 3 -t 'git log --graph --simplify-by-decoration --branches --first-parent --pretty=format:\"%C(auto)%D%Creset\"'"
alias wb="watch -c -n 3 -t 'git branch --color'"
alias tb="/usr/local/bin/tb.sh"
alias ps="ps rau"
alias wn="watch -c -n 3 -t nvidia-smi --query-gpu=index,name,memory.used,memory.total --format=csv,noheader"

alias pyclean="find . | grep -E \"(__pycache__|\.pyc|\.pyo$)\" | xargs rm -rf"

# set locale
export TZ=Asia/Seoul
# set umask
umask 000

# set tab color completion as the same as dircolros
zstyle ':completion:*' list-colors "${(@s.:.)LS_COLORS}"
autoload -Uz compinit

# enable shift-tab
bindkey -M menuselect '^[[Z' reverse-menu-complete

# set zcompdump to be saved in different directory
#compinit -u ~/.cache/zsh/zcompdump-$ZSH_VERSION
skip_global_compinit=1

export LD_LIBRARY_PATH="/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH"
export PATH="/usr/local/cuda/bin:$PATH"
#export CUDA_HOME="/usr/local/cuda"

export JAVA_HOME="/usr/local/java/jdk1.8.0_221"
export JRE_HOME="$JAVA_HOME/jre"
export PATH="$PATH:$JAVA_HOME/bin:$JRE_HOME/bin"
export PYTHONDONTWRITEBYTECODE=1
export OMP_NUM_THREADS="8"


#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

eval $(thefuck --alias)