Skip to content

Instantly share code, notes, and snippets.

@ggsalas
Last active August 11, 2019 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ggsalas/6dbedea7a1908e0b0d738b39363e7245 to your computer and use it in GitHub Desktop.
Save ggsalas/6dbedea7a1908e0b0d738b39363e7245 to your computer and use it in GitHub Desktop.
My zsh config
source /usr/local/share/antigen/antigen.zsh
export PATH="/usr/local/bin:$PATH"
export EDITOR='nvim'
#################################################################################
# Load plugins
#################################################################################
antigen use oh-my-zsh
antigen bundle git
antigen bundle command-not-found
antigen bundle zsh-users/zsh-autosuggestions
antigen apply
#################################################################################
# Bindings
#################################################################################
# bindkey -v # -e emacs bindings, set to -v for vi bindings
# cursor colors
# function zle-line-init zle-keymap-select {
# if [ $KEYMAP = vicmd ]; then
# echo -ne "\033]12;magenta\x7\e[1 q"
# else
# # the insert mode for vi
# echo -ne "\033]12;white\x7\e[1 q"
# fi
# zle reset-prompt
# }
# zle -N zle-line-init
# zle -N zle-keymap-select
# edit command line inside vim
autoload -U edit-command-line
zle -N edit-command-line
bindkey '^x^x' edit-command-line
# Make CTRL-Z background things and unbackground them.
function fg-bg() {
if [[ $#BUFFER -eq 0 ]]; then
fg
else
zle push-input
fi
}
zle -N fg-bg
bindkey '^Z' fg-bg
# Bind ctrl-p to ctrl-space
bindkey '^P' '\ed'
# autosuggestions config
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=243'
bindkey '^P' autosuggest-execute
#################################################################################
# Aliases
#################################################################################
# Neovim
alias vi="nvim"
alias vip="nvim -c 'term' -c 'file Console' -c 'term' -c 'file Server'"
# file snd folders
alias ..='cd ..'
# test with jest
alias tdebug="ndb npm run test -- --watch"
alias test="npm run test -- --watch"
# Others
alias reload='source ~/.zshrc'
alias untar='tar -xvf'
alias marketplace='kitty --session ~/kittySesions/marketplace'
export ZSH_TMUX_FORCEUTF8=true
#################################################################################
# FZF START
#################################################################################
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
export FZF_DEFAULT_COMMAND='rg --files --no-ignore --hidden --follow --glob "!.git/*"'
export LANG="en_US.UTF-8"
#################################################################################
# Prompt START
autoload -U colors
colors
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git hg
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr "%F{green}‚óè%f" # default 'S'
zstyle ':vcs_info:*' unstagedstr "%F{red}‚óè%f" # default 'U'
zstyle ':vcs_info:*' use-simple true
zstyle ':vcs_info:git+set-message:*' hooks git-untracked
zstyle ':vcs_info:git*:*' formats '[%b%m%c%u] ' # default ' (%s)-[%b]%c%u-'
zstyle ':vcs_info:git*:*' actionformats '[%b|%a%m%c%u] ' # default ' (%s)-[%b|%a]%c%u-'
zstyle ':vcs_info:hg*:*' formats '[%m%b] '
zstyle ':vcs_info:hg*:*' actionformats '[%b|%a%m] '
zstyle ':vcs_info:hg*:*' branchformat '%b'
zstyle ':vcs_info:hg*:*' get-bookmarks true
zstyle ':vcs_info:hg*:*' get-revision true
zstyle ':vcs_info:hg*:*' get-mq false
zstyle ':vcs_info:hg*+gen-hg-bookmark-string:*' hooks hg-bookmarks
zstyle ':vcs_info:hg*+set-message:*' hooks hg-message
function +vi-hg-bookmarks() {
emulate -L zsh
if [[ -n "${hook_com[hg-active-bookmark]}" ]]; then
hook_com[hg-bookmark-string]="${(Mj:,:)@}"
ret=1
fi
}
function +vi-hg-message() {
emulate -L zsh
if [[ -n "${hook_com[misc]}" ]]; then
hook_com[branch]=''
fi
return 0
}
function +vi-git-untracked() {
emulate -L zsh
if [[ -n $(git ls-files --exclude-standard --others 2> /dev/null) ]]; then
hook_com[unstaged]+="%F{blue}‚óè%f"
fi
}
RPROMPT_BASE="\${vcs_info_msg_0_}%F{blue}%~%f"
setopt PROMPT_SUBST
# function () {
# local LVL=$SHLVL
# local SUFFIX=$(printf '‚ùØ%.0s' {1..$LVL})
# # export PS1="%F{green}${SSH_TTY:+%n@%m}%f%B${SSH_TTY:+:}%b%F{blue}%1~%F{yellow}%B%(1j.*.)%(?..!)%b%f%F{yellow}%B${SUFFIX}%b%f "
# export PS1="%F{green}${SSH_TTY:+%n@%m}%f%B${SSH_TTY:+:}%b%F{cyan}%B%(1j.* .)%b%f%F{yellow}%B${SUFFIX}%b%f "
# }
function () {
if [[ -n "$TMUX" ]]; then
local LVL=$(($SHLVL - 1))
else
local LVL=$SHLVL
fi
local SUFFIX=$(printf '‚ùØ%.0s' {1..$LVL})
if [[ -n "$TMUX" ]]; then
# Note use a non-breaking space at the end of the prompt because we can use it as
# a find pattern to jump back in tmux.
local NBSP=' '
export PS1="%F{green}${SSH_TTY:+%n@%m}%f%B${SSH_TTY:+:}%b%F{cyan}%B%(1j.* .)%b%f%F{yellow}%B${SUFFIX}%b%f "
export ZLE_RPROMPT_INDENT=0
else
# Don't bother with ZLE_RPROMPT_INDENT here, because it ends up eating the
# space after PS1.
export PS1="%F{green}${SSH_TTY:+%n@%m}%f%B${SSH_TTY:+:}%b%F{cyan}%B%(1j.* .)%b%f%F{yellow}%B${SUFFIX}%b%f "
fi
}
export RPROMPT=$RPROMPT_BASE
export SPROMPT="zsh: correct %F{red}'%R'%f to %F{red}'%r'%f [%B%Uy%u%bes, %B%Un%u%bo, %B%Ue%u%bdit, %B%Ua%u%bbort]? "
#
# Hooks
#
autoload -U add-zsh-hook
# for prompt
add-zsh-hook precmd vcs_info
# Prompt END
#################################################################################
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment