Experimenting with oh-my-zsh
This commit is contained in:
parent
c6cc2d3f9d
commit
516c67c150
@ -1,7 +1,15 @@
|
|||||||
autoload -Uz compinit
|
#
|
||||||
compinit
|
# User configuration sourced by interactive shells
|
||||||
# Completion for kitty
|
#
|
||||||
#kitty + complete setup zsh | source /dev/stdin
|
|
||||||
|
setopt LOCAL_OPTIONS # allow functions to have local options
|
||||||
|
setopt LOCAL_TRAPS # allow functions to have local traps
|
||||||
|
setopt CLOBBER
|
||||||
|
setopt RM_STAR_SILENT # dont ask for confirmation in rm globs
|
||||||
|
setopt CORRECT # auto-correct commands
|
||||||
|
setopt COMPLETE_IN_WORD # dont nice background tasks
|
||||||
|
setopt PROMPT_SUBST # expand prompt sequences
|
||||||
|
|
||||||
#
|
#
|
||||||
# .zshrc is sourced in interactive shells.
|
# .zshrc is sourced in interactive shells.
|
||||||
# It should contain commands to set up aliases,
|
# It should contain commands to set up aliases,
|
||||||
@ -16,9 +24,6 @@ compinit
|
|||||||
# terminal's default foreground colour. Abbreviations
|
# terminal's default foreground colour. Abbreviations
|
||||||
# are allowed; b or bl selects black.
|
# are allowed; b or bl selects black.
|
||||||
#
|
#
|
||||||
HISTFILE=~/.histfile
|
|
||||||
HISTSIZE=1000
|
|
||||||
SAVEHIST=1000
|
|
||||||
WORDCHARS="${WORDCHARS:s#/#}"
|
WORDCHARS="${WORDCHARS:s#/#}"
|
||||||
WORDCHARS="${WORDCHARS:s#.#}"
|
WORDCHARS="${WORDCHARS:s#.#}"
|
||||||
export EDITOR=$(which nvim)
|
export EDITOR=$(which nvim)
|
||||||
@ -39,11 +44,11 @@ bindkey "\ee[C" forward-word
|
|||||||
bindkey "\ee[D" backward-word
|
bindkey "\ee[D" backward-word
|
||||||
#Ctrl-left/right
|
#Ctrl-left/right
|
||||||
bindkey '\e[1;5C' forward-word # ctrl right
|
bindkey '\e[1;5C' forward-word # ctrl right
|
||||||
bindkey '\e[1;5D' backward-word # ctrl left o
|
bindkey '\e[1;5D' backward-word # ctrl left
|
||||||
#alt-left/right
|
#alt-left/right
|
||||||
bindkey "\e[1;3C" forward-word
|
bindkey "\e[1;3C" forward-word
|
||||||
bindkey "\e[1;3D" backward-word
|
bindkey "\e[1;3D" backward-word
|
||||||
#bindkey "^H" backward-delete-word
|
bindkey "^H" backward-delete-word
|
||||||
# for rxvt
|
# for rxvt
|
||||||
bindkey "\e[8~" end-of-line
|
bindkey "\e[8~" end-of-line
|
||||||
bindkey "\e[7~" beginning-of-line
|
bindkey "\e[7~" beginning-of-line
|
||||||
@ -56,16 +61,9 @@ bindkey "\e[F" end-of-line
|
|||||||
# completion in the middle of a line
|
# completion in the middle of a line
|
||||||
bindkey '^i' expand-or-complete-prefix
|
bindkey '^i' expand-or-complete-prefix
|
||||||
|
|
||||||
setopt appendhistory autocd nobeep extendedglob nomatch notify
|
setopt autocd nobeep extendedglob nomatch notify
|
||||||
setopt autolist auto_menu
|
setopt autolist auto_menu
|
||||||
bindkey -e
|
|
||||||
# End of lines configured by zsh-newuser-install
|
|
||||||
# The following lines were added by compinstall
|
|
||||||
zstyle :compinstall filename '/home/mwoodson/.zshrc'
|
|
||||||
|
|
||||||
autoload -Uz compinit
|
|
||||||
compinit
|
|
||||||
# End of lines added by compinstall
|
|
||||||
## completion system
|
## completion system
|
||||||
_force_rehash() {
|
_force_rehash() {
|
||||||
(( CURRENT == 1 )) && rehash
|
(( CURRENT == 1 )) && rehash
|
||||||
@ -174,10 +172,12 @@ setopt CORRECT
|
|||||||
## restart running processes on exit
|
## restart running processes on exit
|
||||||
#setopt HUP
|
#setopt HUP
|
||||||
|
|
||||||
## history
|
# Save all history
|
||||||
#setopt APPEND_HISTORY
|
# Incrementally write history to file
|
||||||
## for sharing history between zsh processes
|
|
||||||
setopt INC_APPEND_HISTORY
|
setopt INC_APPEND_HISTORY
|
||||||
|
# Save timestamp to history file too
|
||||||
|
setopt EXTENDED_HISTORY
|
||||||
|
# Import newly written commands from the history file
|
||||||
setopt SHARE_HISTORY
|
setopt SHARE_HISTORY
|
||||||
|
|
||||||
setopt nonomatch # do not print error on non matched patterns
|
setopt nonomatch # do not print error on non matched patterns
|
||||||
@ -292,6 +292,10 @@ fi
|
|||||||
|
|
||||||
precmd(){
|
precmd(){
|
||||||
|
|
||||||
|
if [ "$(id -u)" -ne 0 ]; then
|
||||||
|
echo "$(date "+%Y-%m-%d.%H:%M:%S") $(pwd) $(history | tail -n 1)" >>! $HOME/.history/zsh-history-$(date "+%Y-%m-%d").log;
|
||||||
|
fi
|
||||||
|
|
||||||
local exit_status=$?
|
local exit_status=$?
|
||||||
|
|
||||||
vcs_info 'prompt'
|
vcs_info 'prompt'
|
||||||
@ -336,24 +340,28 @@ precmd(){
|
|||||||
|
|
||||||
#PROMPT LINE
|
#PROMPT LINE
|
||||||
#${PR_BRIGHT_YELLOW}%D{%R.%S %a %b %d %Y}${PR_RESET}\
|
#${PR_BRIGHT_YELLOW}%D{%R.%S %a %b %d %Y}${PR_RESET}\
|
||||||
LINE1_PROMPT="\
|
|
||||||
%B%F{black}▶%f%b%F{red}▶%B%F{red}▶%f%b \
|
#LINE1_PROMPT="\
|
||||||
%B%F{$HASH_MOD}%D{%R.%S %a %b %d %Y}%b%f\
|
#%B%F{black}▶%f%b%F{red}▶%B%F{red}▶%f%b \
|
||||||
${EXIT_STATUS}\
|
#%B%F{$HASH_MOD}%D{%R.%S %a %b %d %Y}%b%f\
|
||||||
%(1j. %B%F{green}◆%f%b %B%F{yellow}Jobs: %j%f%b.)\
|
#${EXIT_STATUS}\
|
||||||
${PR_BATTERY}\
|
#%(1j. %B%F{green}◆%f%b %B%F{yellow}Jobs: %j%f%b.)\
|
||||||
%B%F{red}◀%f%b%F{red}◀%B%F{black}◀%f%b"
|
#${PR_BATTERY}\
|
||||||
|
# %B%F{red}◀%f%b%F{red}◀%B%F{black}◀%f%b"
|
||||||
###################
|
###################
|
||||||
|
|
||||||
local TERMWIDTH
|
local TERMWIDTH
|
||||||
(( TERMWIDTH = ${COLUMNS} - 2 ))
|
(( TERMWIDTH = ${COLUMNS} - 2 ))
|
||||||
LINE1=${(e%)LINE1_PROMPT} SSH_P=${(e%)SSH_PROMPT}
|
#LINE1=${(e%)LINE1_PROMPT} SSH_P=${(e%)SSH_PROMPT}
|
||||||
|
LINE1=SSH_P=${(e%)SSH_PROMPT}
|
||||||
#$LINE1
|
#$LINE1
|
||||||
LINE1_LENGTH=${#${LINE1//\[[^m]##m/}}
|
#LINE1_LENGTH=${#${LINE1//\[[^m]##m/}}
|
||||||
SSH_P_LENGTH=${#${SSH_P//\[[^m]##m/}}
|
SSH_P_LENGTH=${#${SSH_P//\[[^m]##m/}}
|
||||||
FILL_SPACES=${(l:TERMWIDTH - (LINE1_LENGTH + SSH_P_LENGTH):: :)}
|
#FILL_SPACES=${(l:TERMWIDTH - (LINE1_LENGTH + SSH_P_LENGTH):: :)}
|
||||||
|
FILL_SPACES=${(l:TERMWIDTH - (SSH_P_LENGTH):: :)}
|
||||||
|
|
||||||
print -- "$LINE1 $FILL_SPACES $SSH_P"
|
#print -- "$LINE1 $FILL_SPACES $SSH_P"
|
||||||
|
print -- "$FILL_SPACES $SSH_P"
|
||||||
}
|
}
|
||||||
|
|
||||||
PROMPT='${PROMPT_LINE}%B%F{green}:%f%b${PR_PWDCOLOR}%~${PR_RESET}${vcs_info_msg_0_}%(!.%B%F{red}%#%f%b.%B%F{green}➤%f%b) '
|
PROMPT='${PROMPT_LINE}%B%F{green}:%f%b${PR_PWDCOLOR}%~${PR_RESET}${vcs_info_msg_0_}%(!.%B%F{red}%#%f%b.%B%F{green}➤%f%b) '
|
||||||
@ -385,8 +393,6 @@ fi
|
|||||||
# [[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
|
# [[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
# Enable Ctrl-x-e to edit command line
|
|
||||||
autoload -U edit-command-line
|
|
||||||
# Emacs style
|
# Emacs style
|
||||||
#zle -N edit-command-line
|
#zle -N edit-command-line
|
||||||
#bindkey '^xe' edit-command-line
|
#bindkey '^xe' edit-command-line
|
||||||
|
87
shell/.zshrc
87
shell/.zshrc
@ -1,17 +1,80 @@
|
|||||||
#!/bin/zsh
|
#!/bin/zsh
|
||||||
|
|
||||||
#
|
|
||||||
# User configuration sourced by interactive shells
|
|
||||||
#
|
|
||||||
|
|
||||||
setopt LOCAL_OPTIONS # allow functions to have local options
|
|
||||||
setopt LOCAL_TRAPS # allow functions to have local traps
|
|
||||||
setopt CLOBBER
|
|
||||||
setopt RM_STAR_SILENT # dont ask for confirmation in rm globs
|
|
||||||
setopt CORRECT # auto-correct commands
|
|
||||||
setopt COMPLETE_IN_WORD # dont nice background tasks
|
|
||||||
setopt PROMPT_SUBST # expand prompt sequences
|
|
||||||
|
|
||||||
# Load basic settings
|
# Load basic settings
|
||||||
source ${HOME}/.basic.zshrc
|
source ${HOME}/.basic.zshrc
|
||||||
|
|
||||||
|
# Path to oh-my-zsh configuration.
|
||||||
|
ZSH=$HOME/.oh-my-zsh
|
||||||
|
|
||||||
|
# This is faster than loading all of oh-my-zsh
|
||||||
|
source $ZSH/lib/functions.zsh
|
||||||
|
source $ZSH/lib/theme-and-appearance.zsh
|
||||||
|
source $ZSH/lib/git.zsh
|
||||||
|
source $ZSH/lib/history.zsh
|
||||||
|
source $ZSH/lib/key-bindings.zsh
|
||||||
|
source $ZSH/lib/completion.zsh
|
||||||
|
source $ZSH/lib/misc.zsh
|
||||||
|
source $ZSH/plugins/gitfast/gitfast.plugin.zsh
|
||||||
|
|
||||||
|
# Use vi mode
|
||||||
|
bindkey -v
|
||||||
|
|
||||||
|
# Vi mode settings
|
||||||
|
# Better searching in command mode
|
||||||
|
bindkey -M vicmd '?' history-incremental-search-backward
|
||||||
|
bindkey -M vicmd '/' history-incremental-search-forward
|
||||||
|
|
||||||
|
# Beginning search 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
|
||||||
|
|
||||||
|
# Easier, more vim-like editor opening
|
||||||
|
# `v` is already mapped to visual mode, so we need to use a different key to
|
||||||
|
# open Vim
|
||||||
|
bindkey -M vicmd "^V" edit-command-line
|
||||||
|
|
||||||
|
# Make Vi mode transitions faster (KEYTIMEOUT is in hundredths of a second)
|
||||||
|
export KEYTIMEOUT=1
|
||||||
|
|
||||||
|
autoload -Uz compinit
|
||||||
|
compinit
|
||||||
|
# Completion for kitty
|
||||||
|
kitty + complete setup zsh | source /dev/stdin
|
||||||
|
|
||||||
|
# Theme: https://github.com/Stratus3D/dotfiles/blob/master/zsh/blinks-modified.zsh-theme
|
||||||
|
|
||||||
|
#
|
||||||
|
# https://github.com/blinks zsh theme
|
||||||
|
|
||||||
|
# I have modified the blinks theme to make it more lightweight. There is no
|
||||||
|
# right prompt, and the exit code is displayed on the left just before Git
|
||||||
|
# prompt character.
|
||||||
|
|
||||||
|
function _prompt_char() {
|
||||||
|
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
|
||||||
|
echo "%{%F{blue}%}±%{%f%k%b%}"
|
||||||
|
else
|
||||||
|
echo ' '
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# This theme works with both the "dark" and "light" variants of the
|
||||||
|
# Solarized color schema. Set the SOLARIZED_THEME variable to one of
|
||||||
|
# these two values to choose. If you don't specify, we'll assume you're
|
||||||
|
# using the "dark" variant.
|
||||||
|
|
||||||
|
case ${SOLARIZED_THEME:-dark} in
|
||||||
|
light) bkg=white;;
|
||||||
|
*) bkg=black;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
ZSH_THEME_GIT_PROMPT_PREFIX=" [%{%B%F{blue}%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_SUFFIX="%{%f%k%b%B%F{green}%}]"
|
||||||
|
ZSH_THEME_GIT_PROMPT_DIRTY=" %{%F{red}%}*%{%f%k%b%}"
|
||||||
|
ZSH_THEME_GIT_PROMPT_CLEAN=""
|
||||||
|
|
||||||
|
PROMPT='%{%f%k%b%}
|
||||||
|
%{%B%F{green}%}%n%{%B%F{blue}%}@%{%B%F{cyan}%}%m%{%B%F{green}%} %{%b%F{yellow}%}%~%{%B%F{green}%}$(git_prompt_info)%E %{%}%{$fg_bold[red]%}%(?..%?)%{%f%b%}%{%f%k%b%}
|
||||||
|
$(_prompt_char)%{%} %#%{%f%k%b%} '
|
||||||
|
Loading…
Reference in New Issue
Block a user