mirror of
https://github.com/dcarrillo/prezto.git
synced 2024-12-23 04:28:00 +00:00
Move common promptpwd code to external function
This commit is contained in:
parent
b963484fe7
commit
60c433d4ce
@ -11,23 +11,12 @@
|
|||||||
# Load dependencies.
|
# Load dependencies.
|
||||||
pmodload 'helper'
|
pmodload 'helper'
|
||||||
|
|
||||||
function prompt_damoekri_pwd {
|
prompt_damoekri_precmd() {
|
||||||
local pwd="${PWD/#$HOME/~}"
|
|
||||||
|
|
||||||
if [[ "$pwd" == (#m)[/~] ]]; then
|
|
||||||
_prompt_damoekri_pwd="$MATCH"
|
|
||||||
unset MATCH
|
|
||||||
else
|
|
||||||
_prompt_damoekri_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function prompt_damoekri_precmd {
|
|
||||||
setopt LOCAL_OPTIONS
|
setopt LOCAL_OPTIONS
|
||||||
unsetopt XTRACE KSH_ARRAYS
|
unsetopt XTRACE KSH_ARRAYS
|
||||||
|
|
||||||
# Format PWD.
|
# Format PWD.
|
||||||
prompt_damoekri_pwd
|
_prompt_damoekri_pwd=$(promptpwd)
|
||||||
|
|
||||||
# Get Git repository information.
|
# Get Git repository information.
|
||||||
if (( $+functions[git-info] )); then
|
if (( $+functions[git-info] )); then
|
||||||
|
@ -59,18 +59,7 @@ function prompt_paradox_build_prompt {
|
|||||||
prompt_paradox_end_segment
|
prompt_paradox_end_segment
|
||||||
}
|
}
|
||||||
|
|
||||||
function prompt_paradox_pwd {
|
prompt_paradox_print_elapsed_time() {
|
||||||
local pwd="${PWD/#$HOME/~}"
|
|
||||||
|
|
||||||
if [[ "$pwd" == (#m)[/~] ]]; then
|
|
||||||
_prompt_paradox_pwd="$MATCH"
|
|
||||||
unset MATCH
|
|
||||||
else
|
|
||||||
_prompt_paradox_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function prompt_paradox_print_elapsed_time {
|
|
||||||
local end_time=$(( SECONDS - _prompt_paradox_start_time ))
|
local end_time=$(( SECONDS - _prompt_paradox_start_time ))
|
||||||
local hours minutes seconds remainder
|
local hours minutes seconds remainder
|
||||||
|
|
||||||
@ -94,7 +83,7 @@ function prompt_paradox_precmd {
|
|||||||
unsetopt XTRACE KSH_ARRAYS
|
unsetopt XTRACE KSH_ARRAYS
|
||||||
|
|
||||||
# Format PWD.
|
# Format PWD.
|
||||||
prompt_paradox_pwd
|
_prompt_paradox_pwd=$(promptpwd)
|
||||||
|
|
||||||
# Get Git repository information.
|
# Get Git repository information.
|
||||||
if (( $+functions[git-info] )); then
|
if (( $+functions[git-info] )); then
|
||||||
|
@ -32,18 +32,7 @@
|
|||||||
# Load dependencies.
|
# Load dependencies.
|
||||||
pmodload 'helper'
|
pmodload 'helper'
|
||||||
|
|
||||||
function prompt_sorin_pwd {
|
prompt_sorin_git_info() {
|
||||||
local pwd="${PWD/#$HOME/~}"
|
|
||||||
|
|
||||||
if [[ "$pwd" == (#m)[/~] ]]; then
|
|
||||||
_prompt_sorin_pwd="$MATCH"
|
|
||||||
unset MATCH
|
|
||||||
else
|
|
||||||
_prompt_sorin_pwd="${${${${(@j:/:M)${(@s:/:)pwd}##.#?}:h}%/}//\%/%%}/${${pwd:t}//\%/%%}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function prompt_sorin_git_info {
|
|
||||||
if (( _prompt_sorin_precmd_async_pid > 0 )); then
|
if (( _prompt_sorin_precmd_async_pid > 0 )); then
|
||||||
# Append Git status.
|
# Append Git status.
|
||||||
if [[ -s "$_prompt_sorin_precmd_async_data" ]]; then
|
if [[ -s "$_prompt_sorin_precmd_async_data" ]]; then
|
||||||
@ -77,7 +66,7 @@ function prompt_sorin_precmd {
|
|||||||
unsetopt XTRACE KSH_ARRAYS
|
unsetopt XTRACE KSH_ARRAYS
|
||||||
|
|
||||||
# Format PWD.
|
# Format PWD.
|
||||||
prompt_sorin_pwd
|
_prompt_sorin_pwd=$(promptpwd)
|
||||||
|
|
||||||
# Define prompts.
|
# Define prompts.
|
||||||
RPROMPT='${editor_info[overwrite]}%(?:: %F{1}⏎%f)${VIM:+" %B%F{6}V%f%b"}'
|
RPROMPT='${editor_info[overwrite]}%(?:: %F{1}⏎%f)${VIM:+" %B%F{6}V%f%b"}'
|
||||||
|
14
modules/prompt/functions/promptpwd
Normal file
14
modules/prompt/functions/promptpwd
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# prompt setup function common to many prompts
|
||||||
|
# moved to external function to reduce code redundancy
|
||||||
|
|
||||||
|
local current_pwd="${PWD/#$HOME/~}"
|
||||||
|
local ret_directory
|
||||||
|
|
||||||
|
if [[ "$current_pwd" == (#m)[/~] ]]; then
|
||||||
|
ret_directory="$MATCH"
|
||||||
|
unset MATCH
|
||||||
|
else
|
||||||
|
ret_directory="${${${${(@j:/:M)${(@s:/:)current_pwd}##.#?}:h}%/}//\%/%%}/${${current_pwd:t}//\%/%%}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
print "$ret_directory"
|
Loading…
Reference in New Issue
Block a user