1
0
Fork 0

Update functions to all use POSIX syntax

I'm not a huge fan of this change, as I've made it known. However, this
is semi-recommended by the style guide we've chosen to use and is a more
common syntax.

Fixes #692.
pull/1364/head
Kaleb Elwert 7 years ago
parent 75a60bc7bf
commit 47467a1b0e

@ -18,10 +18,10 @@ fi
unset min_zsh_version unset min_zsh_version
# zprezto convenience updater # zprezto convenience updater
# The function is surrounded by ( ) instead of { } so it starts in a subshell # The function is surrounded by ( ) instead of() { } so it starts in a subshell
# and won't affect the environment of the calling shell # and won't affect the environment of the calling shell
function zprezto-update () ( zprezto-update() (
function cannot-fast-forward { cannot-fast-forward() {
local STATUS="$1" local STATUS="$1"
[[ -n "${STATUS}" ]] && printf "%s\n" "${STATUS}" [[ -n "${STATUS}" ]] && printf "%s\n" "${STATUS}"
printf "Unable to fast-forward the changes. You can fix this by " printf "Unable to fast-forward the changes. You can fix this by "
@ -68,7 +68,7 @@ function zprezto-update () (
# #
# Loads Prezto modules. # Loads Prezto modules.
function pmodload { pmodload() {
local -a pmodules local -a pmodules
local pmodule local pmodule
local pfunction_glob='^([_.]*|prompt_*_setup|README*|*~)(-.N:t)' local pfunction_glob='^([_.]*|prompt_*_setup|README*|*~)(-.N:t)'

@ -15,7 +15,7 @@ fi
# #
# Set Docker Machine environment # Set Docker Machine environment
function dkme { dkme() {
if (( ! $+commands[docker-machine] )); then if (( ! $+commands[docker-machine] )); then
return 1 return 1
fi fi
@ -24,7 +24,7 @@ function dkme {
} }
# Set Docker Machine default machine # Set Docker Machine default machine
function dkmd { dkmd() {
if (( ! $+commands[docker-machine] )); then if (( ! $+commands[docker-machine] )); then
return 1 return 1
fi fi

@ -80,7 +80,7 @@ zle -N edit-command-line
# #
# Runs bindkey but for all of the keymaps. Running it with no arguments will # Runs bindkey but for all of the keymaps. Running it with no arguments will
# print out the mappings for all of the keymaps. # print out the mappings for all of the keymaps.
function bindkey-all { bindkey-all() {
local keymap='' local keymap=''
for keymap in $(bindkey -l); do for keymap in $(bindkey -l); do
[[ "$#" -eq 0 ]] && printf "#### %s\n" "${keymap}" 1>&2 [[ "$#" -eq 0 ]] && printf "#### %s\n" "${keymap}" 1>&2
@ -89,7 +89,7 @@ function bindkey-all {
} }
# Exposes information about the Zsh Line Editor via the $editor_info associative # Exposes information about the Zsh Line Editor via the $editor_info associative
# array. # array.
function editor-info { editor-info() {
# Clean up previous $editor_info. # Clean up previous $editor_info.
unset editor_info unset editor_info
typeset -gA editor_info typeset -gA editor_info
@ -117,7 +117,7 @@ zle -N editor-info
# Reset the prompt based on the current context and # Reset the prompt based on the current context and
# the ps-context option. # the ps-context option.
function zle-reset-prompt { zle-reset-prompt() {
if zstyle -t ':prezto:module:editor' ps-context; then if zstyle -t ':prezto:module:editor' ps-context; then
# If we aren't within one of the specified contexts, then we want to reset # If we aren't within one of the specified contexts, then we want to reset
# the prompt with the appropriate editor_info[keymap] if there is one. # the prompt with the appropriate editor_info[keymap] if there is one.
@ -133,13 +133,13 @@ function zle-reset-prompt {
zle -N zle-reset-prompt zle -N zle-reset-prompt
# Updates editor information when the keymap changes. # Updates editor information when the keymap changes.
function zle-keymap-select { zle-keymap-select() {
zle editor-info zle editor-info
} }
zle -N zle-keymap-select zle -N zle-keymap-select
# Enables terminal application mode and updates editor information. # Enables terminal application mode and updates editor information.
function zle-line-init { zle-line-init() {
# The terminal must be in application mode when ZLE is active for $terminfo # The terminal must be in application mode when ZLE is active for $terminfo
# values to be valid. # values to be valid.
if (( $+terminfo[smkx] )); then if (( $+terminfo[smkx] )); then
@ -153,7 +153,7 @@ function zle-line-init {
zle -N zle-line-init zle -N zle-line-init
# Disables terminal application mode and updates editor information. # Disables terminal application mode and updates editor information.
function zle-line-finish { zle-line-finish() {
# The terminal must be in application mode when ZLE is active for $terminfo # The terminal must be in application mode when ZLE is active for $terminfo
# values to be valid. # values to be valid.
if (( $+terminfo[rmkx] )); then if (( $+terminfo[rmkx] )); then
@ -167,14 +167,14 @@ function zle-line-finish {
zle -N zle-line-finish zle -N zle-line-finish
# Toggles emacs overwrite mode and updates editor information. # Toggles emacs overwrite mode and updates editor information.
function overwrite-mode { overwrite-mode() {
zle .overwrite-mode zle .overwrite-mode
zle editor-info zle editor-info
} }
zle -N overwrite-mode zle -N overwrite-mode
# Enters vi insert mode and updates editor information. # Enters vi insert mode and updates editor information.
function vi-insert { vi-insert() {
zle .vi-insert zle .vi-insert
zle editor-info zle editor-info
} }
@ -182,21 +182,21 @@ zle -N vi-insert
# Moves to the first non-blank character then enters vi insert mode and updates # Moves to the first non-blank character then enters vi insert mode and updates
# editor information. # editor information.
function vi-insert-bol { vi-insert-bol() {
zle .vi-insert-bol zle .vi-insert-bol
zle editor-info zle editor-info
} }
zle -N vi-insert-bol zle -N vi-insert-bol
# Enters vi replace mode and updates editor information. # Enters vi replace mode and updates editor information.
function vi-replace { vi-replace () {
zle .vi-replace zle .vi-replace
zle editor-info zle editor-info
} }
zle -N vi-replace zle -N vi-replace
# Expands .... to ../.. # Expands .... to ../..
function expand-dot-to-parent-directory-path { expand-dot-to-parent-directory-path() {
if [[ $LBUFFER = *.. ]]; then if [[ $LBUFFER = *.. ]]; then
LBUFFER+='/..' LBUFFER+='/..'
else else
@ -206,7 +206,7 @@ function expand-dot-to-parent-directory-path {
zle -N expand-dot-to-parent-directory-path zle -N expand-dot-to-parent-directory-path
# Displays an indicator when completing. # Displays an indicator when completing.
function expand-or-complete-with-indicator { expand-or-complete-with-indicator() {
local indicator local indicator
zstyle -s ':prezto:module:editor:info:completing' format 'indicator' zstyle -s ':prezto:module:editor:info:completing' format 'indicator'
print -Pn "$indicator" print -Pn "$indicator"
@ -216,7 +216,7 @@ function expand-or-complete-with-indicator {
zle -N expand-or-complete-with-indicator zle -N expand-or-complete-with-indicator
# Inserts 'sudo ' at the beginning of the line. # Inserts 'sudo ' at the beginning of the line.
function prepend-sudo { prepend-sudo() {
if [[ "$BUFFER" != su(do|)\ * ]]; then if [[ "$BUFFER" != su(do|)\ * ]]; then
BUFFER="sudo $BUFFER" BUFFER="sudo $BUFFER"
(( CURSOR += 5 )) (( CURSOR += 5 ))

@ -36,7 +36,7 @@ source "$cache_file"
unset cache_file init_args unset cache_file init_args
function fasd_cd { fasd_cd() {
local fasd_ret="$(fasd -d "$@")" local fasd_ret="$(fasd -d "$@")"
if [[ -d "$fasd_ret" ]]; then if [[ -d "$fasd_ret" ]]; then
cd "$fasd_ret" cd "$fasd_ret"

@ -7,7 +7,7 @@
# Gets the Git special action (am, bisect, cherry, merge, rebase). # Gets the Git special action (am, bisect, cherry, merge, rebase).
# Borrowed from vcs_info and edited. # Borrowed from vcs_info and edited.
function _git-action { _git-action() {
local action_dir local action_dir
local git_dir="$(git-dir)" local git_dir="$(git-dir)"
local apply_formatted local apply_formatted
@ -90,7 +90,7 @@ function _git-action {
} }
# Gets the Git status information. # Gets the Git status information.
function git-info { git-info() {
# Extended globbing is needed to parse repository status. # Extended globbing is needed to parse repository status.
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
setopt EXTENDED_GLOB setopt EXTENDED_GLOB

@ -50,7 +50,7 @@ for _gnu_utility_cmd in "${_gnu_utility_cmds[@]}"; do
_gnu_utility_pcmd="${_gnu_utility_p}${_gnu_utility_cmd}" _gnu_utility_pcmd="${_gnu_utility_p}${_gnu_utility_cmd}"
if (( ${+commands[${_gnu_utility_pcmd}]} )); then if (( ${+commands[${_gnu_utility_pcmd}]} )); then
eval " eval "
function ${_gnu_utility_cmd} { ${_gnu_utility_cmd}() {
'${commands[${_gnu_utility_pcmd}]}' \"\$@\" '${commands[${_gnu_utility_pcmd}]}' \"\$@\"
} }
" "

@ -40,7 +40,7 @@ if grep 'enable-ssh-support' "$_gpg_agent_conf" &> /dev/null; then
pmodload 'ssh' pmodload 'ssh'
# Updates the GPG-Agent TTY before every command since SSH does not set it. # Updates the GPG-Agent TTY before every command since SSH does not set it.
function _gpg-agent-update-tty { _gpg-agent-update-tty() {
gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null gpg-connect-agent UPDATESTARTUPTTY /bye >/dev/null
} }
add-zsh-hook preexec _gpg-agent-update-tty add-zsh-hook preexec _gpg-agent-update-tty

@ -7,7 +7,7 @@
# #
# Adds a function name to a list to be called when a trap is triggered. # Adds a function name to a list to be called when a trap is triggered.
function add-zsh-trap { add-zsh-trap() {
if (( $# < 2 )); then if (( $# < 2 )); then
print "usage: $0 type function" >&2 print "usage: $0 type function" >&2
return 1 return 1
@ -26,7 +26,7 @@ function add-zsh-trap {
if (( ! $+functions[TRAP${1}] )); then if (( ! $+functions[TRAP${1}] )); then
eval " eval "
function TRAP${1} { TRAP${1}() {
for trap_function in \"\$TRAP${1}_FUNCTIONS[@]\"; do for trap_function in \"\$TRAP${1}_FUNCTIONS[@]\"; do
if (( \$+functions[\$trap_function] )); then if (( \$+functions[\$trap_function] )); then
\"\$trap_function\" \"\$1\" \"\$trap_function\" \"\$1\"

@ -6,23 +6,23 @@
# #
# Checks if a file can be autoloaded by trying to load it in a subshell. # Checks if a file can be autoloaded by trying to load it in a subshell.
function is-autoloadable { is-autoloadable() {
( unfunction $1 ; autoload -U +X $1 ) &> /dev/null ( unfunction $1 ; autoload -U +X $1 ) &> /dev/null
} }
# Checks if a name is a command, function, or alias. # Checks if a name is a command, function, or alias.
function is-callable { is-callable() {
(( $+commands[$1] || $+functions[$1] || $+aliases[$1] || $+builtins[$1] )) (( $+commands[$1] || $+functions[$1] || $+aliases[$1] || $+builtins[$1] ))
} }
# Checks a boolean variable for "true". # Checks a boolean variable for "true".
# Case insensitive: "1", "y", "yes", "t", "true", "o", and "on". # Case insensitive: "1", "y", "yes", "t", "true", "o", and "on".
function is-true { is-true() {
[[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)|[Oo]([Nn]|)) ]] [[ -n "$1" && "$1" == (1|[Yy]([Ee][Ss]|)|[Tt]([Rr][Uu][Ee]|)|[Oo]([Nn]|)) ]]
} }
# Prints the first non-empty string in the arguments array. # Prints the first non-empty string in the arguments array.
function coalesce { coalesce() {
for arg in $argv; do for arg in $argv; do
print "$arg" print "$arg"
return 0 return 0

@ -5,7 +5,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
function mand { mand() {
if (( $# > 0 )); then if (( $# > 0 )); then
open "dash://manpages:$1" 2>/dev/null open "dash://manpages:$1" 2>/dev/null
if (( $? != 0 )); then if (( $? != 0 )); then

@ -5,7 +5,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
function manp { manp() {
local page local page
if (( $# > 0 )); then if (( $# > 0 )); then
for page in "$@"; do for page in "$@"; do

@ -36,7 +36,7 @@ including a function that displays help or a function used to preview it.
The most basic example of this function can be seen below. The most basic example of this function can be seen below.
function prompt_name_setup { prompt_name_setup() {
PROMPT='%m%# ' PROMPT='%m%# '
RPROMPT='' RPROMPT=''
} }
@ -48,7 +48,7 @@ function **should** be defined. The user will access it via `prompt -h name`.
The most basic example of this function can be seen below. The most basic example of this function can be seen below.
function prompt_name_help { prompt_name_help() {
cat <<EOH cat <<EOH
This prompt is color-scheme-able. You can invoke it thus: This prompt is color-scheme-able. You can invoke it thus:
@ -65,7 +65,7 @@ function **should** be defined. The user will access it via `prompt -p name`.
The most basic example of this function can be seen below. The most basic example of this function can be seen below.
function prompt_name_preview { prompt_name_preview() {
if (( $# > 0 )); then if (( $# > 0 )); then
prompt_preview_theme theme "$@" prompt_preview_theme theme "$@"
else else
@ -93,7 +93,7 @@ a function before you calling it.
The most basic example of this function can be seen below. The most basic example of this function can be seen below.
function prompt_name_precmd { prompt_name_precmd() {
if (( $+functions[git-info] )); then if (( $+functions[git-info] )); then
git-info git-info
fi fi

@ -37,7 +37,7 @@
# Load dependencies. # Load dependencies.
pmodload 'helper' pmodload 'helper'
function prompt_cloud_precmd { prompt_cloud_precmd() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
@ -47,7 +47,7 @@ function prompt_cloud_precmd {
fi fi
} }
function prompt_cloud_help { prompt_cloud_help() {
cat <<EOT cat <<EOT
This prompt's prefix symbol and colors are customizable: This prompt's prefix symbol and colors are customizable:
@ -61,7 +61,7 @@ and green.
EOT EOT
} }
function prompt_cloud_preview { prompt_cloud_preview() {
if (( $# > 0 )); then if (( $# > 0 )); then
prompt_preview_theme 'cloud' "$@" prompt_preview_theme 'cloud' "$@"
else else
@ -73,7 +73,7 @@ function prompt_cloud_preview {
fi fi
} }
function prompt_cloud_setup { prompt_cloud_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -29,7 +29,7 @@ prompt_damoekri_precmd() {
fi fi
} }
function prompt_damoekri_setup { prompt_damoekri_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -14,28 +14,28 @@
# http://i.imgur.com/rCo3S.png # http://i.imgur.com/rCo3S.png
# #
function +vi-set_novcs_prompt_symbol { +vi-set_novcs_prompt_symbol() {
_prompt_giddie_symbol=')' _prompt_giddie_symbol=')'
} }
function +vi-set_vcs_prompt_symbol { +vi-set_vcs_prompt_symbol() {
_prompt_giddie_symbol='±' _prompt_giddie_symbol='±'
} }
function +vi-git_precmd { +vi-git_precmd() {
# Check for untracked files, since vcs_info does not. # Check for untracked files, since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
hook_com[unstaged]+='%F{green}?%f' hook_com[unstaged]+='%F{green}?%f'
fi fi
} }
function prompt_giddie_precmd { prompt_giddie_precmd() {
# Replace '/home/<user>' with '~'. # Replace '/home/<user>' with '~'.
_prompt_giddie_pwd="${PWD/#$HOME/~}" _prompt_giddie_pwd="${PWD/#$HOME/~}"
vcs_info vcs_info
} }
function prompt_giddie_setup { prompt_giddie_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -14,7 +14,7 @@
# http://i.imgur.com/dCwhynn.png # http://i.imgur.com/dCwhynn.png
# #
function prompt_kylewest_precmd { prompt_kylewest_precmd() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
@ -29,7 +29,7 @@ function prompt_kylewest_precmd {
fi fi
} }
function prompt_kylewest_setup { prompt_kylewest_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -9,18 +9,18 @@
# http://i.imgur.com/zLZNK.png # http://i.imgur.com/zLZNK.png
# #
function +vi-git_status { +vi-git_status() {
# Check for untracked files or updated submodules since vcs_info does not. # Check for untracked files or updated submodules since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
hook_com[unstaged]='%F{red}●%f' hook_com[unstaged]='%F{red}●%f'
fi fi
} }
function prompt_minimal_precmd { prompt_minimal_precmd() {
vcs_info vcs_info
} }
function prompt_minimal_setup { prompt_minimal_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -19,11 +19,11 @@
# http://i.imgur.com/Xe1bu.png # http://i.imgur.com/Xe1bu.png
# #
function prompt_nicoulaj_precmd { prompt_nicoulaj_precmd() {
vcs_info vcs_info
} }
function prompt_nicoulaj_setup { prompt_nicoulaj_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -22,7 +22,7 @@ _prompt_paradox_current_bg='NONE'
_prompt_paradox_segment_separator='' _prompt_paradox_segment_separator=''
_prompt_paradox_start_time=$SECONDS _prompt_paradox_start_time=$SECONDS
function prompt_paradox_start_segment { prompt_paradox_start_segment() {
local bg fg local bg fg
[[ -n "$1" ]] && bg="%K{$1}" || bg="%k" [[ -n "$1" ]] && bg="%K{$1}" || bg="%k"
[[ -n "$2" ]] && fg="%F{$2}" || fg="%f" [[ -n "$2" ]] && fg="%F{$2}" || fg="%f"
@ -35,7 +35,7 @@ function prompt_paradox_start_segment {
[[ -n "$3" ]] && print -n "$3" [[ -n "$3" ]] && print -n "$3"
} }
function prompt_paradox_end_segment { prompt_paradox_end_segment() {
if [[ -n "$_prompt_paradox_current_bg" ]]; then if [[ -n "$_prompt_paradox_current_bg" ]]; then
print -n " %k%F{$_prompt_paradox_current_bg}$_prompt_paradox_segment_separator" print -n " %k%F{$_prompt_paradox_current_bg}$_prompt_paradox_segment_separator"
else else
@ -45,7 +45,7 @@ function prompt_paradox_end_segment {
_prompt_paradox_current_bg='' _prompt_paradox_current_bg=''
} }
function prompt_paradox_build_prompt { prompt_paradox_build_prompt() {
prompt_paradox_start_segment black default '%(?::%F{red}✘ )%(!:%F{yellow}⚡ :)%(1j:%F{cyan}⚙ :)%F{blue}%n%F{red}@%F{green}%m%f' prompt_paradox_start_segment black default '%(?::%F{red}✘ )%(!:%F{yellow}⚡ :)%(1j:%F{cyan}⚙ :)%F{blue}%n%F{red}@%F{green}%m%f'
prompt_paradox_start_segment blue black '$_prompt_paradox_pwd' prompt_paradox_start_segment blue black '$_prompt_paradox_pwd'
@ -79,7 +79,7 @@ prompt_paradox_print_elapsed_time() {
fi fi
} }
function prompt_paradox_precmd { prompt_paradox_precmd() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
@ -100,11 +100,11 @@ function prompt_paradox_precmd {
prompt_paradox_print_elapsed_time prompt_paradox_print_elapsed_time
} }
function prompt_paradox_preexec { prompt_paradox_preexec() {
_prompt_paradox_start_time="$SECONDS" _prompt_paradox_start_time="$SECONDS"
} }
function prompt_paradox_setup { prompt_paradox_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -10,7 +10,7 @@
# http://i.imgur.com/LhgmW.png # http://i.imgur.com/LhgmW.png
# #
function prompt_peepcode_precmd { prompt_peepcode_precmd() {
# Get Git repository information. # Get Git repository information.
if (( $+functions[git-info] )); then if (( $+functions[git-info] )); then
git-info git-info
@ -22,7 +22,7 @@ function prompt_peepcode_precmd {
fi fi
} }
function prompt_peepcode_setup { prompt_peepcode_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)
@ -56,7 +56,7 @@ RPROMPT='${ruby_info[version]}${git_info[rprompt]}'
} }
function prompt_peepcode_help { prompt_peepcode_help() {
cat <<EOH cat <<EOH
This prompt's last command exit status symbol is customizable: This prompt's last command exit status symbol is customizable:
@ -66,7 +66,7 @@ If this option is not provided, the symbol defaults to ☻.
EOH EOH
} }
function prompt_peepcode_preview { prompt_peepcode_preview() {
local +h PROMPT='%# ' local +h PROMPT='%# '
local +h RPROMPT='' local +h RPROMPT=''
local +h SPROMPT='' local +h SPROMPT=''

@ -13,7 +13,7 @@
# http://i.imgur.com/gLgVp6Y.png # http://i.imgur.com/gLgVp6Y.png
# #
function prompt_skwp_precmd { prompt_skwp_precmd() {
# Get Git repository information. # Get Git repository information.
if (( $+functions[git-info] )); then if (( $+functions[git-info] )); then
git-info git-info
@ -25,7 +25,7 @@ function prompt_skwp_precmd {
fi fi
} }
function prompt_skwp_setup { prompt_skwp_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -15,7 +15,7 @@
# Load dependencies. # Load dependencies.
pmodload 'helper' pmodload 'helper'
function prompt_smiley_precmd { prompt_smiley_precmd() {
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
# Get Git repository information. # Get Git repository information.
@ -34,7 +34,7 @@ function prompt_smiley_precmd {
fi fi
} }
function prompt_smiley_setup { prompt_smiley_setup() {
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(percent subst) prompt_opts=(percent subst)

@ -50,7 +50,7 @@ prompt_sorin_git_info() {
fi fi
} }
function prompt_sorin_precmd_async { prompt_sorin_precmd_async() {
# Get Git repository information. # Get Git repository information.
if (( $+functions[git-info] )); then if (( $+functions[git-info] )); then
git-info git-info
@ -77,7 +77,7 @@ function prompt_sorin_precmd_async {
kill -WINCH $$ kill -WINCH $$
} }
function prompt_sorin_precmd { prompt_sorin_precmd() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
@ -98,7 +98,7 @@ function prompt_sorin_precmd {
_prompt_sorin_precmd_async_pid=$! _prompt_sorin_precmd_async_pid=$!
} }
function prompt_sorin_setup { prompt_sorin_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)
@ -141,7 +141,7 @@ function prompt_sorin_setup {
SPROMPT='zsh: correct %F{1}%R%f to %F{2}%r%f [nyae]? ' SPROMPT='zsh: correct %F{1}%R%f to %F{2}%r%f [nyae]? '
} }
function prompt_sorin_preview { prompt_sorin_preview() {
local +h PROMPT='' local +h PROMPT=''
local +h RPROMPT='' local +h RPROMPT=''
local +h SPROMPT='' local +h SPROMPT=''

@ -12,7 +12,7 @@
# http://i.imgur.com/HyRvv.png # http://i.imgur.com/HyRvv.png
# #
function prompt_steeef_precmd { prompt_steeef_precmd() {
# Check for untracked files or updated submodules since vcs_info does not. # Check for untracked files or updated submodules since vcs_info does not.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c${_prompt_steeef_colors[4]}●%f)" branch_format="(${_prompt_steeef_colors[1]}%b%f%u%c${_prompt_steeef_colors[4]}●%f)"
@ -29,7 +29,7 @@ function prompt_steeef_precmd {
fi fi
} }
function prompt_steeef_setup { prompt_steeef_setup() {
setopt LOCAL_OPTIONS setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst) prompt_opts=(cr percent subst)

@ -34,7 +34,7 @@ if (( ! $+commands[python] && ! $+commands[pyenv] )); then
return 1 return 1
fi fi
function _python-workon-cwd { _python-workon-cwd() {
# Check if this is a Git repo # Check if this is a Git repo
local GIT_REPO_ROOT="" local GIT_REPO_ROOT=""
local GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2> /dev/null)" local GIT_TOPLEVEL="$(git rev-parse --show-toplevel 2> /dev/null)"

@ -12,7 +12,7 @@ if [[ "$TERM" == (dumb|linux|*bsd*|eterm*) ]]; then
fi fi
# Sets the terminal window title. # Sets the terminal window title.
function set-window-title { set-window-title() {
local title_format{,ted} local title_format{,ted}
zstyle -s ':prezto:module:terminal:window-title' format 'title_format' || title_format="%s" zstyle -s ':prezto:module:terminal:window-title' format 'title_format' || title_format="%s"
zformat -f title_formatted "$title_format" "s:$argv" zformat -f title_formatted "$title_format" "s:$argv"
@ -20,7 +20,7 @@ function set-window-title {
} }
# Sets the terminal tab title. # Sets the terminal tab title.
function set-tab-title { set-tab-title() {
local title_format{,ted} local title_format{,ted}
zstyle -s ':prezto:module:terminal:tab-title' format 'title_format' || title_format="%s" zstyle -s ':prezto:module:terminal:tab-title' format 'title_format' || title_format="%s"
zformat -f title_formatted "$title_format" "s:$argv" zformat -f title_formatted "$title_format" "s:$argv"
@ -28,7 +28,7 @@ function set-tab-title {
} }
# Sets the terminal multiplexer tab title. # Sets the terminal multiplexer tab title.
function set-multiplexer-title { set-multiplexer-title() {
local title_format{,ted} local title_format{,ted}
zstyle -s ':prezto:module:terminal:multiplexer-title' format 'title_format' || title_format="%s" zstyle -s ':prezto:module:terminal:multiplexer-title' format 'title_format' || title_format="%s"
zformat -f title_formatted "$title_format" "s:$argv" zformat -f title_formatted "$title_format" "s:$argv"
@ -36,7 +36,7 @@ function set-multiplexer-title {
} }
# Sets the tab and window titles with a given command. # Sets the tab and window titles with a given command.
function _terminal-set-titles-with-command { _terminal-set-titles-with-command() {
emulate -L zsh emulate -L zsh
setopt EXTENDED_GLOB setopt EXTENDED_GLOB
@ -69,7 +69,7 @@ function _terminal-set-titles-with-command {
} }
# Sets the tab and window titles with a given path. # Sets the tab and window titles with a given path.
function _terminal-set-titles-with-path { _terminal-set-titles-with-path() {
emulate -L zsh emulate -L zsh
setopt EXTENDED_GLOB setopt EXTENDED_GLOB
@ -94,7 +94,7 @@ if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \
then then
# Sets the Terminal.app current working directory before the prompt is # Sets the Terminal.app current working directory before the prompt is
# displayed. # displayed.
function _terminal-set-terminal-app-proxy-icon { _terminal-set-terminal-app-proxy-icon() {
printf '\e]7;%s\a' "file://${HOST}${PWD// /%20}" printf '\e]7;%s\a' "file://${HOST}${PWD// /%20}"
} }
add-zsh-hook precmd _terminal-set-terminal-app-proxy-icon add-zsh-hook precmd _terminal-set-terminal-app-proxy-icon
@ -103,7 +103,7 @@ then
# multiplexer or remote connection is started since it can no longer be # multiplexer or remote connection is started since it can no longer be
# updated, and it becomes confusing when the directory displayed in the title # updated, and it becomes confusing when the directory displayed in the title
# bar is no longer synchronized with real current working directory. # bar is no longer synchronized with real current working directory.
function _terminal-unset-terminal-app-proxy-icon { _terminal-unset-terminal-app-proxy-icon() {
if [[ "${2[(w)1]:t}" == (screen|tmux|dvtm|ssh|mosh) ]]; then if [[ "${2[(w)1]:t}" == (screen|tmux|dvtm|ssh|mosh) ]]; then
print '\e]7;\a' print '\e]7;\a'
fi fi

@ -5,7 +5,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
function diff { diff() {
if zstyle -t ':prezto:module:utility:diff' color; then if zstyle -t ':prezto:module:utility:diff' color; then
if (( $+commands[colordiff] )); then if (( $+commands[colordiff] )); then
command colordiff "$@" command colordiff "$@"

@ -6,7 +6,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
function dut { dut() {
(( $# == 0 )) && set -- * (( $# == 0 )) && set -- *
if grep -q -i 'GNU' < <(du --version 2>&1); then if grep -q -i 'GNU' < <(du --version 2>&1); then

@ -5,7 +5,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
function make { make() {
if zstyle -t ':prezto:module:utility:make' color; then if zstyle -t ':prezto:module:utility:make' color; then
if (( $+commands[colormake] )); then if (( $+commands[colormake] )); then
colormake "$@" colormake "$@"

@ -5,7 +5,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com> # Sorin Ionescu <sorin.ionescu@gmail.com>
# #
function wdiff { wdiff() {
if zstyle -t ':prezto:module:utility:wdiff' color; then if zstyle -t ':prezto:module:utility:wdiff' color; then
if (( $+commands[wdiff] )); then if (( $+commands[wdiff] )); then
command wdiff \ command wdiff \

@ -48,7 +48,7 @@ alias scp='noglob rsync_scp_wrap scp'
# globbing for remote paths. The wrap function globs args starting in / and ./ # globbing for remote paths. The wrap function globs args starting in / and ./
# and doesn't glob paths with : in it as these are interpreted as remote paths # and doesn't glob paths with : in it as these are interpreted as remote paths
# by these programs unless the path starts with / or ./ # by these programs unless the path starts with / or ./
function rsync_scp_wrap { rsync_scp_wrap() {
local args=( ) local args=( )
local cmd="$1" local cmd="$1"
shift shift
@ -190,36 +190,36 @@ fi
# #
# Makes a directory and changes to it. # Makes a directory and changes to it.
function mkdcd { mkdcd() {
[[ -n "$1" ]] && mkdir -p "$1" && builtin cd "$1" [[ -n "$1" ]] && mkdir -p "$1" && builtin cd "$1"
} }
# Changes to a directory and lists its contents. # Changes to a directory and lists its contents.
function cdls { cdls() {
builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}" builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}"
} }
# Pushes an entry onto the directory stack and lists its contents. # Pushes an entry onto the directory stack and lists its contents.
function pushdls { pushdls() {
builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}" builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}"
} }
# Pops an entry off the directory stack and lists its contents. # Pops an entry off the directory stack and lists its contents.
function popdls { popdls() {
builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}" builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}"
} }
# Prints columns 1 2 3 ... n. # Prints columns 1 2 3 ... n.
function slit { slit() {
awk "{ print ${(j:,:):-\$${^@}} }" awk "{ print ${(j:,:):-\$${^@}} }"
} }
# Finds files and executes a command on them. # Finds files and executes a command on them.
function find-exec { find-exec() {
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \; find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
} }
# Displays user owned processes status. # Displays user owned processes status.
function psu { psu() {
ps -U "${1:-$LOGNAME}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}" ps -U "${1:-$LOGNAME}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}"
} }

Loading…
Cancel
Save