mirror of
https://github.com/sorin-ionescu/prezto.git
synced 2025-01-23 04:52:16 +08:00
Compare commits
9 Commits
971c5a9b0c
...
3fb17b8e9b
Author | SHA1 | Date | |
---|---|---|---|
|
3fb17b8e9b | ||
|
6e564503f1 | ||
|
0e24b6b606 | ||
|
0d64389d6d | ||
|
9d89a67162 | ||
|
5291eae55a | ||
|
c257740c53 | ||
|
b0ef5e14cf | ||
|
6f38c9ce36 |
2
init.zsh
2
init.zsh
@ -173,7 +173,7 @@ if [[ -s "${ZDOTDIR:-$HOME}/.zpreztorc" ]]; then
|
||||
fi
|
||||
|
||||
# Disable color and theme in dumb terminals.
|
||||
if [[ "$TERM" == 'dumb' ]]; then
|
||||
if [[ $TERM == dumb ]]; then
|
||||
zstyle ':prezto:*:*' color 'no'
|
||||
zstyle ':prezto:module:prompt' theme 'off'
|
||||
fi
|
||||
|
@ -7,7 +7,7 @@
|
||||
#
|
||||
|
||||
# Return if requirements are not found.
|
||||
if [[ $TERM == 'dumb' ]]; then
|
||||
if [[ $TERM == dumb ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
||||
# paste had a regression. Additionally, 5.2 added bracketed-paste-url-magic
|
||||
# which is generally better than url-quote-magic so we load that when possible.
|
||||
autoload -Uz is-at-least
|
||||
if [[ ${ZSH_VERSION} != 5.1.1 && ${TERM} != "dumb" ]]; then
|
||||
if [[ $ZSH_VERSION != 5.1.1 && $TERM != dumb ]]; then
|
||||
if is-at-least 5.2; then
|
||||
autoload -Uz bracketed-paste-url-magic
|
||||
zle -N bracketed-paste bracketed-paste-url-magic
|
||||
@ -34,7 +34,8 @@ setopt COMBINING_CHARS # Combine zero-length punctuation characters (accent
|
||||
# with the base character.
|
||||
setopt INTERACTIVE_COMMENTS # Enable comments in interactive shell.
|
||||
setopt RC_QUOTES # Allow 'Henry''s Garage' instead of 'Henry'\''s Garage'.
|
||||
unsetopt MAIL_WARNING # Don't print a warning message if a mail file has been accessed.
|
||||
unsetopt MAIL_WARNING # Don't print a warning message if a mail file has
|
||||
# been accessed.
|
||||
|
||||
# Allow mapping Ctrl+S and Ctrl+Q shortcuts
|
||||
[[ -r ${TTY:-} && -w ${TTY:-} && $+commands[stty] == 1 ]] && stty -ixon <$TTY >$TTY
|
||||
@ -43,23 +44,23 @@ unsetopt MAIL_WARNING # Don't print a warning message if a mail file has b
|
||||
# Jobs
|
||||
#
|
||||
|
||||
setopt LONG_LIST_JOBS # List jobs in the long format by default.
|
||||
setopt AUTO_RESUME # Attempt to resume existing job before creating a new process.
|
||||
setopt NOTIFY # Report status of background jobs immediately.
|
||||
unsetopt BG_NICE # Don't run all background jobs at a lower priority.
|
||||
unsetopt HUP # Don't kill jobs on shell exit.
|
||||
unsetopt CHECK_JOBS # Don't report on jobs when shell exit.
|
||||
setopt LONG_LIST_JOBS # List jobs in the long format by default.
|
||||
setopt AUTO_RESUME # Attempt to resume existing job before creating a new process.
|
||||
setopt NOTIFY # Report status of background jobs immediately.
|
||||
unsetopt BG_NICE # Don't run all background jobs at a lower priority.
|
||||
unsetopt HUP # Don't kill jobs on shell exit.
|
||||
unsetopt CHECK_JOBS # Don't report on jobs when shell exit.
|
||||
|
||||
#
|
||||
# Termcap
|
||||
#
|
||||
|
||||
if zstyle -t ':prezto:environment:termcap' color; then
|
||||
export LESS_TERMCAP_mb=$'\E[01;31m' # Begins blinking.
|
||||
export LESS_TERMCAP_md=$'\E[01;31m' # Begins bold.
|
||||
export LESS_TERMCAP_me=$'\E[0m' # Ends mode.
|
||||
export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode.
|
||||
export LESS_TERMCAP_so=$'\E[00;47;30m' # Begins standout-mode.
|
||||
export LESS_TERMCAP_ue=$'\E[0m' # Ends underline.
|
||||
export LESS_TERMCAP_us=$'\E[01;32m' # Begins underline.
|
||||
export LESS_TERMCAP_mb=$'\E[01;31m' # Begins blinking.
|
||||
export LESS_TERMCAP_md=$'\E[01;31m' # Begins bold.
|
||||
export LESS_TERMCAP_me=$'\E[0m' # Ends mode.
|
||||
export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode.
|
||||
export LESS_TERMCAP_so=$'\E[00;47;30m' # Begins standout-mode.
|
||||
export LESS_TERMCAP_ue=$'\E[0m' # Ends underline.
|
||||
export LESS_TERMCAP_us=$'\E[01;32m' # Begins underline.
|
||||
fi
|
||||
|
@ -6,8 +6,6 @@
|
||||
# Zeh Rizzatti <zehrizzatti@gmail.com>
|
||||
#
|
||||
|
||||
# function node-info {
|
||||
|
||||
local version
|
||||
local version_format
|
||||
local version_formatted
|
||||
@ -15,18 +13,25 @@ local version_formatted
|
||||
unset node_info
|
||||
typeset -gA node_info
|
||||
|
||||
if (( $+commands[nodenv] )); then
|
||||
version="${${$(nodenv version)#v}[(w)0]}"
|
||||
elif (( $+functions[nvm_version] )); then
|
||||
version="${$(nvm_version)#v}"
|
||||
elif (( $+commands[node] )) ; then
|
||||
version="${$(node -v)#v}"
|
||||
fi
|
||||
|
||||
if [[ "$version" != (none|system) ]]; then
|
||||
# Only proceed if we're in a Node.js project
|
||||
if [[ -f "package.json" || -f ".nvmrc" || -f ".node-version" ]]; then
|
||||
# Get the format
|
||||
zstyle -s ':prezto:module:node:info:version' format 'version_format'
|
||||
zformat -f version_formatted "$version_format" "v:$version"
|
||||
node_info[version]="$version_formatted"
|
||||
fi
|
||||
|
||||
# }
|
||||
if [[ -n "$version_format" ]]; then
|
||||
if (( $+commands[nodenv] )); then
|
||||
version="${${$(nodenv version)#v}[(w)0]}"
|
||||
elif (( $+commands[volta] )); then
|
||||
version="${${$(volta list node | grep 'default')#*@}%% *}"
|
||||
elif (( $+functions[nvm_version] )); then
|
||||
version="${$(nvm_version)#v}"
|
||||
elif (( $+commands[node] )) ; then
|
||||
version="${$(node -v)#v}"
|
||||
fi
|
||||
|
||||
if [[ -n "$version" && "$version" != "system" ]]; then
|
||||
zformat -f version_formatted "$version_format" "v:$version"
|
||||
node_info[version]="$version_formatted"
|
||||
fi
|
||||
fi
|
||||
fi
|
@ -8,19 +8,23 @@
|
||||
# Indrajit Raychaudhuri <irc@indrajit.com>
|
||||
#
|
||||
|
||||
# Possible lookup locations for manually installed nodenv and nvm.
|
||||
# Possible lookup locations for manually installed version managers
|
||||
local_nodenv_paths=({$NODENV_ROOT,{$XDG_CONFIG_HOME/,$HOME/.}nodenv}/bin/nodenv(N))
|
||||
local_nvm_paths=({$NVM_DIR,{$XDG_CONFIG_HOME/,$HOME/.}nvm}/nvm.sh(N))
|
||||
local_volta_paths=({$VOLTA_HOME,$HOME/.volta}/bin/volta(N))
|
||||
|
||||
# Load manually installed or package manager installed nodenv into the shell
|
||||
# session.
|
||||
if (( $#local_nodenv_paths || $+commands[nodenv] )); then
|
||||
|
||||
# Ensure manually installed nodenv is added to path when present.
|
||||
[[ -s $local_nodenv_paths[1] ]] && path=($local_nodenv_paths[1]:h $path)
|
||||
|
||||
eval "$(nodenv init - zsh)"
|
||||
|
||||
# Use volta if it's installed
|
||||
elif (( $#local_volta_paths || $+commands[volta] )); then
|
||||
export VOLTA_HOME="${VOLTA_HOME:-$HOME/.volta}"
|
||||
path=("$VOLTA_HOME/bin" $path)
|
||||
|
||||
# Load manually installed nvm into the shell session.
|
||||
elif (( $#local_nvm_paths )); then
|
||||
source "$local_nvm_paths[1]" --no-use
|
||||
@ -31,10 +35,10 @@ elif (( $+commands[brew] )) \
|
||||
source "$nvm_path/nvm.sh" --no-use
|
||||
fi
|
||||
|
||||
unset local_n{odenv,vm}_paths nvm_path
|
||||
unset local_{nodenv,nvm,volta}_paths nvm_path
|
||||
|
||||
# Return if requirements are not found.
|
||||
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] )); then
|
||||
if (( ! $+commands[node] && ! $#functions[(i)n(odenv|vm)] && ! $+commands[volta] )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -64,4 +68,12 @@ if ! zstyle -t ':prezto:module:node:alias' skip; then
|
||||
alias npmci='npm ci'
|
||||
alias npmcit='npm cit'
|
||||
alias npmit='npm it'
|
||||
fi
|
||||
|
||||
# Add Volta-specific aliases if Volta is installed
|
||||
if (( $+commands[volta] )); then
|
||||
alias vl='volta list'
|
||||
alias vla='volta list all'
|
||||
alias vi='volta install'
|
||||
alias vp='volta pin'
|
||||
fi
|
||||
fi
|
@ -31,6 +31,7 @@
|
||||
|
||||
# Load dependencies.
|
||||
pmodload 'helper'
|
||||
pmodload 'node'
|
||||
|
||||
function prompt_sorin_async_callback {
|
||||
case $1 in
|
||||
@ -57,7 +58,7 @@ function prompt_sorin_async_callback {
|
||||
"[async]")
|
||||
# Code is 1 for corrupted worker output and 2 for dead worker.
|
||||
if [[ $2 -eq 2 ]]; then
|
||||
# Our worker died unexpectedly.
|
||||
# Our worker died unexpectedly.
|
||||
typeset -g prompt_prezto_async_init=0
|
||||
fi
|
||||
;;
|
||||
@ -110,6 +111,11 @@ function prompt_sorin_precmd {
|
||||
python-info
|
||||
fi
|
||||
|
||||
# Run node info
|
||||
if (( $+functions[node-info] )); then
|
||||
node-info
|
||||
fi
|
||||
|
||||
prompt_sorin_async_tasks
|
||||
}
|
||||
|
||||
@ -155,6 +161,9 @@ function prompt_sorin_setup {
|
||||
# Set python-info parameters.
|
||||
zstyle ':prezto:module:python:info:virtualenv' format '%f%F{3}(%v)%F{7} '
|
||||
|
||||
# Set node-info parameters
|
||||
zstyle ':prezto:module:node:info:version' format ' %F{2}⬡ %v%f'
|
||||
|
||||
# Set up non-zero return value display
|
||||
local show_return="✘ "
|
||||
# Default is to show the return value
|
||||
@ -170,7 +179,7 @@ function prompt_sorin_setup {
|
||||
|
||||
# Define prompts.
|
||||
PROMPT='${SSH_TTY:+"%F{9}%n%f%F{7}@%f%F{3}%m%f "}%F{4}${_prompt_sorin_pwd}%(!. %B%F{1}#%f%b.)${editor_info[keymap]} '
|
||||
RPROMPT='$python_info[virtualenv]${editor_info[overwrite]}%(?:: %F{1}'
|
||||
RPROMPT='$python_info[virtualenv]${node_info[version]} ${editor_info[overwrite]}%(?:: %F{1}'
|
||||
RPROMPT+=${show_return}
|
||||
RPROMPT+='%f)${VIM:+" %B%F{6}V%f%b"}${_prompt_sorin_git}'
|
||||
SPROMPT='zsh: correct %F{1}%R%f to %F{2}%r%f [nyae]? '
|
||||
@ -186,4 +195,4 @@ function prompt_sorin_preview {
|
||||
}
|
||||
|
||||
prompt_sorin_setup "$@"
|
||||
# vim: ft=zsh
|
||||
# vim: ft=zsh
|
@ -7,7 +7,7 @@
|
||||
#
|
||||
|
||||
# Return if requirements are not found.
|
||||
if [[ "$TERM" == 'dumb' ]]; then
|
||||
if [[ $TERM == dumb ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
#
|
||||
|
||||
# Return if requirements are not found.
|
||||
if [[ "$TERM" == (dumb|linux|*bsd*|eterm*) ]]; then
|
||||
if [[ $TERM == (dumb|linux|*bsd*|eterm*) ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
@ -60,7 +60,7 @@ function _terminal-set-titles-with-command {
|
||||
local truncated_cmd="${cmd/(#m)?(#c15,)/${MATCH[1,12]}...}"
|
||||
unset MATCH
|
||||
|
||||
if [[ "$TERM" == screen* ]]; then
|
||||
if [[ $TERM == screen* ]]; then
|
||||
set-multiplexer-title "$truncated_cmd"
|
||||
fi
|
||||
set-tab-title "$truncated_cmd"
|
||||
@ -78,7 +78,7 @@ function _terminal-set-titles-with-path {
|
||||
local truncated_path="${abbreviated_path/(#m)?(#c15,)/...${MATCH[-12,-1]}}"
|
||||
unset MATCH
|
||||
|
||||
if [[ "$TERM" == screen* ]]; then
|
||||
if [[ $TERM == screen* ]]; then
|
||||
set-multiplexer-title "$truncated_path"
|
||||
fi
|
||||
set-tab-title "$truncated_path"
|
||||
@ -89,7 +89,7 @@ function _terminal-set-titles-with-path {
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
# Set up the Apple Terminal.
|
||||
if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \
|
||||
if [[ $TERM_PROGRAM == Apple_Terminal ]] \
|
||||
&& ( ! [[ -n "$STY" || -n "$TMUX" || -n "$DVTM" ]] )
|
||||
then
|
||||
# Sets the Terminal.app current working directory before the prompt is
|
||||
|
@ -14,6 +14,6 @@ SAYINGS=(
|
||||
)
|
||||
|
||||
# Print a randomly-chosen message:
|
||||
echo $SAYINGS[$(($RANDOM % ${#SAYINGS} + 1))]
|
||||
echo $SAYINGS[$(($RANDOM % $#SAYINGS + 1))]
|
||||
|
||||
} >&2
|
||||
|
Loading…
Reference in New Issue
Block a user