From cd143e234d779c85927e06967fc286acab4db82d Mon Sep 17 00:00:00 2001 From: Matt Hamilton Date: Mon, 2 Nov 2015 04:20:03 -0500 Subject: [PATCH] convert from ksh to POSIX function syntax --- init.zsh | 2 +- modules/editor/init.zsh | 22 +++++++++---------- modules/fasd/init.zsh | 2 +- modules/git/functions/git-info | 4 ++-- modules/gnu-utility/init.zsh | 2 +- modules/gpg/init.zsh | 2 +- modules/helper/functions/add-zsh-trap | 4 ++-- modules/helper/init.zsh | 8 +++---- modules/osx/functions/mand | 2 +- modules/osx/functions/manp | 2 +- modules/prompt/README.md | 8 +++---- modules/prompt/functions/prompt_cloud_setup | 8 +++---- .../prompt/functions/prompt_damoekri_setup | 6 ++--- modules/prompt/functions/prompt_giddie_setup | 10 ++++----- .../prompt/functions/prompt_kylewest_setup | 4 ++-- modules/prompt/functions/prompt_minimal_setup | 6 ++--- .../prompt/functions/prompt_nicoulaj_setup | 4 ++-- modules/prompt/functions/prompt_paradox_setup | 16 +++++++------- .../prompt/functions/prompt_peepcode_setup | 8 +++---- modules/prompt/functions/prompt_skwp_setup | 4 ++-- modules/prompt/functions/prompt_smiley_setup | 4 ++-- modules/prompt/functions/prompt_sorin_setup | 12 +++++----- modules/prompt/functions/prompt_steeef_setup | 4 ++-- modules/terminal/init.zsh | 12 +++++----- modules/utility/functions/diff | 2 +- modules/utility/functions/dut | 2 +- modules/utility/functions/make | 2 +- modules/utility/functions/wdiff | 2 +- modules/utility/init.zsh | 14 ++++++------ 29 files changed, 89 insertions(+), 89 deletions(-) diff --git a/init.zsh b/init.zsh index 6b5254fb..f53a2cf7 100644 --- a/init.zsh +++ b/init.zsh @@ -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)' diff --git a/modules/editor/init.zsh b/modules/editor/init.zsh index 9aa64d64..b9ad48e2 100644 --- a/modules/editor/init.zsh +++ b/modules/editor/init.zsh @@ -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 )) diff --git a/modules/fasd/init.zsh b/modules/fasd/init.zsh index fc214251..a282007d 100644 --- a/modules/fasd/init.zsh +++ b/modules/fasd/init.zsh @@ -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" diff --git a/modules/git/functions/git-info b/modules/git/functions/git-info index 8aaa4c32..db63873c 100644 --- a/modules/git/functions/git-info +++ b/modules/git/functions/git-info @@ -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 diff --git a/modules/gnu-utility/init.zsh b/modules/gnu-utility/init.zsh index 65560324..2481ddc3 100644 --- a/modules/gnu-utility/init.zsh +++ b/modules/gnu-utility/init.zsh @@ -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}]}' \"\$@\" } " diff --git a/modules/gpg/init.zsh b/modules/gpg/init.zsh index a7c6cf76..4accffd9 100644 --- a/modules/gpg/init.zsh +++ b/modules/gpg/init.zsh @@ -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 diff --git a/modules/helper/functions/add-zsh-trap b/modules/helper/functions/add-zsh-trap index 07663e9d..6a306963 100644 --- a/modules/helper/functions/add-zsh-trap +++ b/modules/helper/functions/add-zsh-trap @@ -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\" diff --git a/modules/helper/init.zsh b/modules/helper/init.zsh index 9d792186..ff1242d3 100644 --- a/modules/helper/init.zsh +++ b/modules/helper/init.zsh @@ -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 diff --git a/modules/osx/functions/mand b/modules/osx/functions/mand index 7a9653a1..004dcd1a 100644 --- a/modules/osx/functions/mand +++ b/modules/osx/functions/mand @@ -5,7 +5,7 @@ # Sorin Ionescu # -function mand { +mand() { if (( $# > 0 )); then open "dash://manpages:$1" 2>/dev/null if (( $? != 0 )); then diff --git a/modules/osx/functions/manp b/modules/osx/functions/manp index fcb2a026..06e9aa62 100644 --- a/modules/osx/functions/manp +++ b/modules/osx/functions/manp @@ -5,7 +5,7 @@ # Sorin Ionescu # -function manp { +manp() { local page if (( $# > 0 )); then for page in "$@"; do diff --git a/modules/prompt/README.md b/modules/prompt/README.md index dc024977..8ffdf3d1 100644 --- a/modules/prompt/README.md +++ b/modules/prompt/README.md @@ -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 < 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 diff --git a/modules/prompt/functions/prompt_cloud_setup b/modules/prompt/functions/prompt_cloud_setup index 3b048df1..9479e28d 100644 --- a/modules/prompt/functions/prompt_cloud_setup +++ b/modules/prompt/functions/prompt_cloud_setup @@ -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 < 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) diff --git a/modules/prompt/functions/prompt_damoekri_setup b/modules/prompt/functions/prompt_damoekri_setup index 58c4d352..b2ddff1f 100644 --- a/modules/prompt/functions/prompt_damoekri_setup +++ b/modules/prompt/functions/prompt_damoekri_setup @@ -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) diff --git a/modules/prompt/functions/prompt_giddie_setup b/modules/prompt/functions/prompt_giddie_setup index 5a14ffe0..f3b14157 100644 --- a/modules/prompt/functions/prompt_giddie_setup +++ b/modules/prompt/functions/prompt_giddie_setup @@ -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/' 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) diff --git a/modules/prompt/functions/prompt_kylewest_setup b/modules/prompt/functions/prompt_kylewest_setup index e4ee0c0e..3082989e 100644 --- a/modules/prompt/functions/prompt_kylewest_setup +++ b/modules/prompt/functions/prompt_kylewest_setup @@ -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) diff --git a/modules/prompt/functions/prompt_minimal_setup b/modules/prompt/functions/prompt_minimal_setup index 8c07e70e..a9d23b7a 100644 --- a/modules/prompt/functions/prompt_minimal_setup +++ b/modules/prompt/functions/prompt_minimal_setup @@ -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) diff --git a/modules/prompt/functions/prompt_nicoulaj_setup b/modules/prompt/functions/prompt_nicoulaj_setup index 241c8b6e..b396dc1f 100644 --- a/modules/prompt/functions/prompt_nicoulaj_setup +++ b/modules/prompt/functions/prompt_nicoulaj_setup @@ -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) diff --git a/modules/prompt/functions/prompt_paradox_setup b/modules/prompt/functions/prompt_paradox_setup index 36ae40ec..8024c5d9 100644 --- a/modules/prompt/functions/prompt_paradox_setup +++ b/modules/prompt/functions/prompt_paradox_setup @@ -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) diff --git a/modules/prompt/functions/prompt_peepcode_setup b/modules/prompt/functions/prompt_peepcode_setup index c70fb9a7..cbadcca3 100644 --- a/modules/prompt/functions/prompt_peepcode_setup +++ b/modules/prompt/functions/prompt_peepcode_setup @@ -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 < 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='' diff --git a/modules/prompt/functions/prompt_steeef_setup b/modules/prompt/functions/prompt_steeef_setup index 996331fd..6fa75123 100644 --- a/modules/prompt/functions/prompt_steeef_setup +++ b/modules/prompt/functions/prompt_steeef_setup @@ -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) diff --git a/modules/terminal/init.zsh b/modules/terminal/init.zsh index b0be5023..c6d103c0 100644 --- a/modules/terminal/init.zsh +++ b/modules/terminal/init.zsh @@ -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 diff --git a/modules/utility/functions/diff b/modules/utility/functions/diff index 8347899e..e4d68cf8 100644 --- a/modules/utility/functions/diff +++ b/modules/utility/functions/diff @@ -5,7 +5,7 @@ # Sorin Ionescu # -function diff { +diff() { if zstyle -t ':prezto:module:utility:diff' color; then if (( $+commands[colordiff] )); then command diff --unified "$@" | colordiff --difftype diffu diff --git a/modules/utility/functions/dut b/modules/utility/functions/dut index 65922805..d38ca910 100644 --- a/modules/utility/functions/dut +++ b/modules/utility/functions/dut @@ -6,7 +6,7 @@ # Sorin Ionescu # -function dut { +dut() { (( $# == 0 )) && set -- * if grep -q -i 'GNU' < <(du --version 2>&1); then diff --git a/modules/utility/functions/make b/modules/utility/functions/make index 5ebab057..984442a8 100644 --- a/modules/utility/functions/make +++ b/modules/utility/functions/make @@ -5,7 +5,7 @@ # Sorin Ionescu # -function make { +make() { if zstyle -t ':prezto:module:utility:make' color; then if (( $+commands[colormake] )); then colormake "$@" diff --git a/modules/utility/functions/wdiff b/modules/utility/functions/wdiff index c93ead1c..5e6c17e1 100644 --- a/modules/utility/functions/wdiff +++ b/modules/utility/functions/wdiff @@ -5,7 +5,7 @@ # Sorin Ionescu # -function wdiff { +wdiff() { if zstyle -t ':prezto:module:utility:wdiff' color; then if (( $+commands[wdiff] )); then command wdiff \ diff --git a/modules/utility/init.zsh b/modules/utility/init.zsh index fd7aaf6e..11cc3899 100644 --- a/modules/utility/init.zsh +++ b/modules/utility/init.zsh @@ -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]}" }