1
0
Fork 0

convert from ksh to POSIX function syntax

pull/1008/head
Matt Hamilton 9 years ago
parent f2a826e963
commit cd143e234d

@ -22,7 +22,7 @@ unset min_zsh_version
#
# Loads Prezto modules.
function pmodload {
pmodload() {
local -a pmodules
local pmodule
local pfunction_glob='^([_.]*|prompt_*_setup|README*)(-.N:t)'

@ -81,7 +81,7 @@ zle -N edit-command-line
# Exposes information about the Zsh Line Editor via the $editor_info associative
# array.
function editor-info {
editor-info() {
# Clean up previous $editor_info.
unset editor_info
typeset -gA editor_info
@ -110,13 +110,13 @@ function editor-info {
zle -N editor-info
# Updates editor information when the keymap changes.
function zle-keymap-select {
zle-keymap-select() {
zle editor-info
}
zle -N zle-keymap-select
# 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
# values to be valid.
if (( $+terminfo[smkx] )); then
@ -130,7 +130,7 @@ function zle-line-init {
zle -N zle-line-init
# 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
# values to be valid.
if (( $+terminfo[rmkx] )); then
@ -144,14 +144,14 @@ function zle-line-finish {
zle -N zle-line-finish
# Toggles emacs overwrite mode and updates editor information.
function overwrite-mode {
overwrite-mode() {
zle .overwrite-mode
zle editor-info
}
zle -N overwrite-mode
# Enters vi insert mode and updates editor information.
function vi-insert {
vi-insert() {
zle .vi-insert
zle editor-info
}
@ -159,21 +159,21 @@ zle -N vi-insert
# Moves to the first non-blank character then enters vi insert mode and updates
# editor information.
function vi-insert-bol {
vi-insert-bol() {
zle .vi-insert-bol
zle editor-info
}
zle -N vi-insert-bol
# Enters vi replace mode and updates editor information.
function vi-replace {
vi-replace() {
zle .vi-replace
zle editor-info
}
zle -N vi-replace
# Expands .... to ../..
function expand-dot-to-parent-directory-path {
expand-dot-to-parent-directory-path() {
if [[ $LBUFFER = *.. ]]; then
LBUFFER+='/..'
else
@ -183,7 +183,7 @@ function expand-dot-to-parent-directory-path {
zle -N expand-dot-to-parent-directory-path
# Displays an indicator when completing.
function expand-or-complete-with-indicator {
expand-or-complete-with-indicator() {
local indicator
zstyle -s ':prezto:module:editor:info:completing' format 'indicator'
print -Pn "$indicator"
@ -193,7 +193,7 @@ function expand-or-complete-with-indicator {
zle -N expand-or-complete-with-indicator
# Inserts 'sudo ' at the beginning of the line.
function prepend-sudo {
prepend-sudo() {
if [[ "$BUFFER" != su(do|)\ * ]]; then
BUFFER="sudo $BUFFER"
(( CURSOR += 5 ))

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

@ -7,7 +7,7 @@
# Gets the Git special action (am, bisect, cherry, merge, rebase).
# Borrowed from vcs_info and edited.
function _git-action {
_git-action() {
local action_dir
local git_dir="$(git-dir)"
local apply_formatted
@ -90,7 +90,7 @@ function _git-action {
}
# Gets the Git status information.
function git-info {
git-info() {
# Extended globbing is needed to parse repository status.
setopt LOCAL_OPTIONS
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}"
if (( ${+commands[${_gnu_utility_pcmd}]} )); then
eval "
function ${_gnu_utility_cmd} {
${_gnu_utility_cmd}() {
'${commands[${_gnu_utility_pcmd}]}' \"\$@\"
}
"

@ -37,7 +37,7 @@ if grep 'enable-ssh-support' "$_gpg_agent_conf" &> /dev/null; then
pmodload 'ssh'
# 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
}
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.
function add-zsh-trap {
add-zsh-trap() {
if (( $# < 2 )); then
print "usage: $0 type function" >&2
return 1
@ -26,7 +26,7 @@ function add-zsh-trap {
if (( ! $+functions[TRAP${1}] )); then
eval "
function TRAP${1} {
TRAP${1}() {
for trap_function in \"\$TRAP${1}_FUNCTIONS[@]\"; do
if (( \$+functions[\$trap_function] )); then
\"\$trap_function\" \"\$1\"

@ -6,23 +6,23 @@
#
# 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
}
# Checks if a name is a command, function, or alias.
function is-callable {
is-callable() {
(( $+commands[$1] )) || (( $+functions[$1] )) || (( $+aliases[$1] ))
}
# Checks a boolean variable for "true".
# 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]|)) ]]
}
# Prints the first non-empty string in the arguments array.
function coalesce {
coalesce() {
for arg in $argv; do
print "$arg"
return 0

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

@ -5,7 +5,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
function manp {
manp() {
local page
if (( $# > 0 )); then
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.
function prompt_name_setup {
prompt_name_setup() {
PROMPT='%m%# '
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.
function prompt_name_help {
prompt_name_help() {
cat <<EOH
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.
function prompt_name_preview {
prompt_name_preview() {
if (( $# > 0 )); then
prompt_preview_theme theme "$@"
else
@ -93,7 +93,7 @@ a function before you calling it.
The most basic example of this function can be seen below.
function prompt_name_precmd {
prompt_name_precmd() {
if (( $+functions[git-info] )); then
git-info
fi

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

@ -11,7 +11,7 @@
# Load dependencies.
pmodload 'helper'
function prompt_damoekri_pwd {
prompt_damoekri_pwd() {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
@ -22,7 +22,7 @@ function prompt_damoekri_pwd {
fi
}
function prompt_damoekri_precmd {
prompt_damoekri_precmd() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
@ -40,7 +40,7 @@ function prompt_damoekri_precmd {
fi
}
function prompt_damoekri_setup {
prompt_damoekri_setup() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)

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

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

@ -9,18 +9,18 @@
# 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.
if [[ -n $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then
hook_com[unstaged]='%F{red}●%f'
fi
}
function prompt_minimal_precmd {
prompt_minimal_precmd() {
vcs_info
}
function prompt_minimal_setup {
prompt_minimal_setup() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)

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

@ -21,7 +21,7 @@ _prompt_paradox_current_bg='NONE'
_prompt_paradox_segment_separator=''
_prompt_paradox_start_time=$SECONDS
function prompt_paradox_start_segment {
prompt_paradox_start_segment() {
local bg fg
[[ -n "$1" ]] && bg="%K{$1}" || bg="%k"
[[ -n "$2" ]] && fg="%F{$2}" || fg="%f"
@ -34,7 +34,7 @@ function prompt_paradox_start_segment {
[[ -n "$3" ]] && print -n "$3"
}
function prompt_paradox_end_segment {
prompt_paradox_end_segment() {
if [[ -n "$_prompt_paradox_current_bg" ]]; then
print -n " %k%F{$_prompt_paradox_current_bg}$_prompt_paradox_segment_separator"
else
@ -44,7 +44,7 @@ function prompt_paradox_end_segment {
_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 blue black '$_prompt_paradox_pwd'
@ -55,7 +55,7 @@ function prompt_paradox_build_prompt {
prompt_paradox_end_segment
}
function prompt_paradox_pwd {
prompt_paradox_pwd() {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
@ -66,7 +66,7 @@ function prompt_paradox_pwd {
fi
}
function prompt_paradox_print_elapsed_time {
prompt_paradox_print_elapsed_time() {
local end_time=$(( SECONDS - _prompt_paradox_start_time ))
local hours minutes seconds remainder
@ -85,7 +85,7 @@ function prompt_paradox_print_elapsed_time {
fi
}
function prompt_paradox_precmd {
prompt_paradox_precmd() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
@ -101,11 +101,11 @@ function prompt_paradox_precmd {
prompt_paradox_print_elapsed_time
}
function prompt_paradox_preexec {
prompt_paradox_preexec() {
_prompt_paradox_start_time="$SECONDS"
}
function prompt_paradox_setup {
prompt_paradox_setup() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)

@ -10,7 +10,7 @@
# http://i.imgur.com/LhgmW.png
#
function prompt_peepcode_precmd {
prompt_peepcode_precmd() {
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
@ -22,7 +22,7 @@ function prompt_peepcode_precmd {
fi
}
function prompt_peepcode_setup {
prompt_peepcode_setup() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
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
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
}
function prompt_peepcode_preview {
prompt_peepcode_preview() {
local +h PROMPT='%# '
local +h RPROMPT=''
local +h SPROMPT=''

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

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

@ -32,7 +32,7 @@
# Load dependencies.
pmodload 'helper'
function prompt_sorin_pwd {
prompt_sorin_pwd() {
local pwd="${PWD/#$HOME/~}"
if [[ "$pwd" == (#m)[/~] ]]; then
@ -43,7 +43,7 @@ function prompt_sorin_pwd {
fi
}
function prompt_sorin_git_info {
prompt_sorin_git_info() {
if (( _prompt_sorin_precmd_async_pid > 0 )); then
# Append Git status.
if [[ -s "$_prompt_sorin_precmd_async_data" ]]; then
@ -61,7 +61,7 @@ function prompt_sorin_git_info {
fi
}
function prompt_sorin_precmd_async {
prompt_sorin_precmd_async() {
# Get Git repository information.
if (( $+functions[git-info] )); then
git-info
@ -72,7 +72,7 @@ function prompt_sorin_precmd_async {
kill -WINCH $$
}
function prompt_sorin_precmd {
prompt_sorin_precmd() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
@ -93,7 +93,7 @@ function prompt_sorin_precmd {
_prompt_sorin_precmd_async_pid=$!
}
function prompt_sorin_setup {
prompt_sorin_setup() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)
@ -136,7 +136,7 @@ function prompt_sorin_setup {
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 RPROMPT=''
local +h SPROMPT=''

@ -12,7 +12,7 @@
# 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.
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)"
@ -29,7 +29,7 @@ function prompt_steeef_precmd {
fi
}
function prompt_steeef_setup {
prompt_steeef_setup() {
setopt LOCAL_OPTIONS
unsetopt XTRACE KSH_ARRAYS
prompt_opts=(cr percent subst)

@ -11,7 +11,7 @@ if [[ "$TERM" == (dumb|linux|*bsd*|eterm*) ]]; then
fi
# Sets the terminal or terminal multiplexer window title.
function set-window-title {
set-window-title() {
local title_format{,ted}
zstyle -s ':prezto:module:terminal:window-title' format 'title_format' || title_format="%s"
zformat -f title_formatted "$title_format" "s:$argv"
@ -26,7 +26,7 @@ function set-window-title {
}
# Sets the terminal tab title.
function set-tab-title {
set-tab-title() {
local title_format{,ted}
zstyle -s ':prezto:module:terminal:tab-title' format 'title_format' || title_format="%s"
zformat -f title_formatted "$title_format" "s:$argv"
@ -35,7 +35,7 @@ function set-tab-title {
}
# Sets the tab and window titles with a given command.
function _terminal-set-titles-with-command {
_terminal-set-titles-with-command() {
emulate -L zsh
setopt EXTENDED_GLOB
@ -65,7 +65,7 @@ function _terminal-set-titles-with-command {
}
# Sets the tab and window titles with a given path.
function _terminal-set-titles-with-path {
_terminal-set-titles-with-path() {
emulate -L zsh
setopt EXTENDED_GLOB
@ -87,7 +87,7 @@ if [[ "$TERM_PROGRAM" == 'Apple_Terminal' ]] \
then
# Sets the Terminal.app current working directory before the prompt is
# displayed.
function _terminal-set-terminal-app-proxy-icon {
_terminal-set-terminal-app-proxy-icon() {
printf '\e]7;%s\a' "file://${HOST}${PWD// /%20}"
}
add-zsh-hook precmd _terminal-set-terminal-app-proxy-icon
@ -96,7 +96,7 @@ then
# multiplexer or remote connection is started since it can no longer be
# updated, and it becomes confusing when the directory displayed in the title
# 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
print '\e]7;\a'
fi

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

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

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

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

@ -165,36 +165,36 @@ alias http-serve='python -m SimpleHTTPServer'
#
# Makes a directory and changes to it.
function mkdcd {
mkdcd() {
[[ -n "$1" ]] && mkdir -p "$1" && builtin cd "$1"
}
# Changes to a directory and lists its contents.
function cdls {
cdls() {
builtin cd "$argv[-1]" && ls "${(@)argv[1,-2]}"
}
# Pushes an entry onto the directory stack and lists its contents.
function pushdls {
pushdls() {
builtin pushd "$argv[-1]" && ls "${(@)argv[1,-2]}"
}
# Pops an entry off the directory stack and lists its contents.
function popdls {
popdls() {
builtin popd "$argv[-1]" && ls "${(@)argv[1,-2]}"
}
# Prints columns 1 2 3 ... n.
function slit {
slit() {
awk "{ print ${(j:,:):-\$${^@}} }"
}
# Finds files and executes a command on them.
function find-exec {
find-exec() {
find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \;
}
# Displays user owned processes status.
function psu {
psu() {
ps -U "${1:-$LOGNAME}" -o 'pid,%cpu,%mem,command' "${(@)argv[2,-1]}"
}

Loading…
Cancel
Save