Skip to content

Instantly share code, notes, and snippets.

@h-otter
Last active May 3, 2021 14:53
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 h-otter/118454e42e16bd629c34f9c9b71677de to your computer and use it in GitHub Desktop.
Save h-otter/118454e42e16bd629c34f9c9b71677de to your computer and use it in GitHub Desktop.
# Set up the prompt
autoload -Uz promptinit
promptinit
PROMPT='
%K{blue}%n@%m%k %B%F{cyan}%~%f%b
%# '
#RPROMPT='[%(?.%?.%B%F{red}%?%f%b), %D %*] # process result
setopt histignorealldups sharehistory
# Use emacs keybindings even if our EDITOR is set to vi
bindkey -e
# Keep 1000 lines of history within the shell and save it to ~/.zsh_history:
HISTSIZE=1000
nSAVEHIST=1000
HISTFILE=~/.zsh_history
# Use modern completion system
autoload -Uz compinit
compinit
zstyle ':completion:*' auto-description 'specify: %d'
zstyle ':completion:*' completer _expand _complete _correct _approximate
zstyle ':completion:*' format 'Completing %d'
zstyle ':completion:*' group-name ''
zstyle ':completion:*' menu select=2
eval "$(dircolors -b)"
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
zstyle ':completion:*' list-colors ''
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
zstyle ':completion:*' menu select=long
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
## peco history refered "http://qiita.com/kp_ohnishi/items/3009e2083831af3a7c5c"
function peco-select-history() {
local tac
if which tac > /dev/null; then
tac="tac"
else
tac="tail -r"
fi
BUFFER=$(\history -n 1 | \
eval $tac | \
peco --query "$LBUFFER")
CURSOR=$#BUFFER
zle clear-screen
}
zle -N peco-select-history
bindkey '^r' peco-select-history
## tmux windows rename ssh refered "https://gist.github.com/numa08/6545981"
ssh() {
if [[ $# == 0 || -z $TMUX ]]; then
command ssh $@
return
fi
local remote=${${(P)#}%.*} ## will refactor
local old_name=$(tmux display-message -p '#W')
local renamed=0
if [[ $remote != -* ]]; then
renamed=1
tmux rename-window $remote
printf '\033]2;%s\033\\' "${remote}"
fi
command ssh $@
if [[ $renamed == 1 ]];then
tmux rename-window "$old_name"
printf '\033]2;%s\033\\' "${old_name}"
fi
}
ls() {
command ls --color=auto $@
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment