Cleanup; fix alt keybinds + unsetopt correct_all

This commit is contained in:
Henrik Lissner 2015-01-16 15:24:51 -05:00
parent 83863f0d34
commit c216de9b26
3 changed files with 71 additions and 93 deletions

View file

@ -9,6 +9,16 @@ export VISUAL='vim'
export PAGER='less' export PAGER='less'
export RUBYOPT=rubygems export RUBYOPT=rubygems
# Set the default Less options.
# Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
# Remove -X and -F (exit if the content fits on one screen) to enable it.
export LESS='-X -F -g -i -M -R -S -w -z-4'
# Set the Less input preprocessor.
if (( $+commands[lesspipe] )); then
export LESSOPEN='| /usr/bin/env lesspipe %s 2>&-'
fi
## Language ## Language
if [[ -z "$LANG" ]]; then if [[ -z "$LANG" ]]; then
export LANG='en_US.UTF-8' export LANG='en_US.UTF-8'
@ -33,16 +43,6 @@ fpath=(
$fpath $fpath
) )
# Set the default Less options.
# Mouse-wheel scrolling has been disabled by -X (disable screen clearing).
# Remove -X and -F (exit if the content fits on one screen) to enable it.
export LESS='-X -F -g -i -M -R -S -w -z-4'
# Set the Less input preprocessor.
if (( $+commands[lesspipe] )); then
export LESSOPEN='| /usr/bin/env lesspipe %s 2>&-'
fi
# Temporary Files # Temporary Files
if [[ ! -d "$TMPDIR" ]]; then if [[ ! -d "$TMPDIR" ]]; then
export TMPDIR="/tmp/$USER" export TMPDIR="/tmp/$USER"

View file

@ -1,83 +0,0 @@
#
# A simple theme based off sorin
#
# Load dependencies.
pmodload 'helper'
# Show the hostname if this is an SSH session
_prompt_my_host=""
if [ ! -z "$SSH_CLIENT" ]; then
_prompt_my_host=" %B%F{blue}| $(hostname | sed -e 's/\.local$//')%f%b"
fi
function _prompt_my_pwd {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
__prompt_my_pwd="$MATCH"
unset MATCH
else
__prompt_my_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}"
fi
}
# Only run git-info if a) the last command used git/hub or b) the pwd
# has changed.
function _prompt_git_preexec {
[[ $2 =~ (git|hub) ]] && _EXEC_GIT_COMMAND=1
}
function _prompt_git_precmd {
if [ -n "$_EXEC_GIT_COMMAND" ]; then
_prompt_git_chpwd
unset _EXEC_GIT_COMMAND
fi
}
function _prompt_git_chpwd {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
(( $+functions[git-info] )) && git-info
}
function prompt_my_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
# Load required functions.
autoload -Uz add-zsh-hook
# Add hook for calling git-info before each command.
add-zsh-hook precmd _prompt_git_precmd
add-zsh-hook chpwd _prompt_git_chpwd
add-zsh-hook preexec _prompt_git_preexec
add-zsh-hook precmd _prompt_my_pwd
# Set editor-info parameters.
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{red}$%f%b'
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{green}#%f%b'
# Set git-info parameters.
zstyle ':prezto:module:git:info' verbose 'yes'
zstyle ':prezto:module:git:info:branch' format ':%F{green}%b%f'
zstyle ':prezto:module:git:info:dirty' format '%F{red}+%f'
zstyle ':prezto:module:git:info:keys' format 'prompt' '' 'rprompt' '%b%D'
# Define prompts.
PROMPT='
${editor_info[keymap]} '
RPROMPT='${editor_info[overwrite]}%F{cyan}${__prompt_my_pwd}${VIM:+" %B%F{green}V%f%b"}${_prompt_my_host}%(?:: %F{red}⏎%f)'
# PROMPT='%f${git_info:+${(e)git_info[prompt]}}%(!. %B%F{red}#%f%b.)${editor_info[keymap]} '
# RPROMPT='${editor_info[overwrite]}${VIM:+" %B%F{green}V%f%b"}${git_info[rprompt]}${_prompt_my_host}%(?:: %F{red}⏎%f)'
_prompt_git_chpwd
}
prompt_my_setup "$@"

View file

@ -0,0 +1,61 @@
#
# A simple theme based off sorin
#
# Load dependencies.
pmodload 'helper'
# Show the hostname if this is an SSH session
if [ ! -z "$SSH_CLIENT" ]; then
__prompt_host="%B%F{blue}[$(hostname | sed -e 's/\.local$//')]%f%b "
fi
function _prompt_pwd {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
__prompt_pwd="$MATCH"
unset MATCH
else
__prompt_pwd="${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}/${pwd:t}"
fi
}
# Why not use prezto's git module? Because git-info seems like overkill.
function _prompt_git {
__prompt_git=$(git rev-parse --abbrev-ref HEAD 2>/dev/null)
if [[ -n "$__prompt_git" ]]; then
__prompt_git=" :%F{yellow}$__prompt_git"
if ! git -c diff.autorefreshindex=true diff --quiet -- .; then
__prompt_git+="%F{white}+"
fi
fi
}
function prompt_v0_setup {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
# Load required functions.
autoload -Uz add-zsh-hook
# Add hook for calling git-info before each command.
add-zsh-hook precmd _prompt_git
add-zsh-hook precmd _prompt_pwd
# Set editor-info parameters.
zstyle ':prezto:module:editor:info:completing' format '%B%F{red}...%f%b'
zstyle ':prezto:module:editor:info:keymap:primary' format '%B%F{red}$%f%b'
zstyle ':prezto:module:editor:info:keymap:primary:overwrite' format '%F{red}♺%f'
zstyle ':prezto:module:editor:info:keymap:alternate' format '%B%F{green}|%f%b'
# Add newline before prompt
precmd() { print "" }
# Define prompts.
PROMPT='${__prompt_host}%F{cyan}${__prompt_pwd} ${editor_info[keymap]} '
RPROMPT='%F{yellow}${__prompt_git:- }'
}
prompt_v0_setup "$@"