From 6a9a4ea8d683cf50e76da1c788ef167e20aff7d2 Mon Sep 17 00:00:00 2001 From: Sorin Ionescu Date: Fri, 23 Mar 2012 14:57:51 -0400 Subject: [PATCH] [Fix #60] Do not use parentheses in function names --- alias.zsh | 4 +-- functions/duh | 2 +- helper.zsh | 10 +++---- keyboard.zsh | 6 ++--- plugins/git/alias.zsh | 4 +-- plugins/git/functions/git-info | 8 +++--- plugins/git/hub.zsh | 2 +- plugins/gnu-utils/init.zsh | 6 ++--- plugins/gpg-agent/init.zsh | 2 +- .../history-substring-search.zsh | 27 +++++++++---------- plugins/osx/functions/manb | 2 +- plugins/osx/functions/manp | 2 +- plugins/osx/init.zsh | 4 +-- plugins/rails/init.zsh | 2 +- plugins/ssh-agent/init.zsh | 2 +- plugins/z/init.zsh | 2 +- terminal.zsh | 12 ++++----- themes/minimal/prompt_minimal_setup | 4 +-- themes/nicoulaj/prompt_nicoulaj_setup | 4 +-- themes/sorin/prompt_sorin_setup | 4 +-- themes/steeef/prompt_steeef_setup | 10 +++---- utility.zsh | 14 +++++----- 22 files changed, 66 insertions(+), 67 deletions(-) diff --git a/alias.zsh b/alias.zsh index 46683e8..4f5a170 100644 --- a/alias.zsh +++ b/alias.zsh @@ -99,7 +99,7 @@ fi # Diff/Make if zstyle -t ':omz:alias:diff' color; then - function diff() { + function diff { if (( $+commands[colordiff] )); then "$commands[diff]" --unified "$@" | colordiff --difftype diffu elif (( $+commands[git] )); then @@ -109,7 +109,7 @@ if zstyle -t ':omz:alias:diff' color; then fi } - function wdiff() { + function wdiff { if (( $+commands[wdiff] )); then "$commands[wdiff]" \ --avoid-wraps \ diff --git a/functions/duh b/functions/duh index 10439f1..69eb2ca 100644 --- a/functions/duh +++ b/functions/duh @@ -6,7 +6,7 @@ # Sorin Ionescu # -function duh() { +function duh { (( $# == 0 )) && set -- * if [[ "$OSTYPE" == linux* ]]; then du -khsc "$@" | sort -h -r diff --git a/helper.zsh b/helper.zsh index af0e3db..8478d78 100644 --- a/helper.zsh +++ b/helper.zsh @@ -6,17 +6,17 @@ # # Checks if a file can be autoloaded by trying to load it in a subshell. -function autoloadable() { +function autoloadable { ( unfunction $1 ; autoload -U +X $1 ) &> /dev/null } # Checks boolean variable for "true" (case insensitive "1", "y", "yes", "t", "true", "o", and "on"). -function is-true() { +function 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() { +function coalesce { for arg in $argv; do print "$arg" return 0 @@ -33,7 +33,7 @@ TRAP_SIGNALS=( ) # Adds a function to a list to be called when a trap is triggered. -function add-zsh-trap() { +function add-zsh-trap { if (( $# < 2 )); then print "usage: $0 type function" >&2 return 1 @@ -52,7 +52,7 @@ function add-zsh-trap() { if (( ! $+functions[TRAP${1}] )); then eval " - function TRAP${1}() { + function TRAP${1} { for trap_function in \"\$TRAP${1}_FUNCTIONS[@]\"; do if (( \$+functions[\$trap_function] )); then \"\$trap_function\" \"\$1\" diff --git a/keyboard.zsh b/keyboard.zsh index 38ce767..0c62a66 100644 --- a/keyboard.zsh +++ b/keyboard.zsh @@ -79,7 +79,7 @@ zle -N zle-line-finish zle -N zle-keymap-select # Expands .... to ../.. -function expand-dot-to-parent-directory-path() { +function expand-dot-to-parent-directory-path { if [[ $LBUFFER = *.. ]]; then LBUFFER+='/..' else @@ -89,7 +89,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() { +function expand-or-complete-with-indicator { local indicator zstyle -s ':omz:completion' indicator 'indicator' print -Pn "$indicator" @@ -99,7 +99,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() { +function prepend-sudo { if [[ "$BUFFER" != su(do|)\ * ]]; then BUFFER="sudo $BUFFER" (( CURSOR += 5 )) diff --git a/plugins/git/alias.zsh b/plugins/git/alias.zsh index 5a9be8d..c30c937 100644 --- a/plugins/git/alias.zsh +++ b/plugins/git/alias.zsh @@ -86,7 +86,7 @@ alias giu='git add --update' compdef _git giu=git-add alias gid='git diff --no-ext-diff --cached' compdef _git gid=git-diff -function giD() { git diff --no-ext-diff --cached --ignore-all-space "$@" | view - } +function giD { git diff --no-ext-diff --cached --ignore-all-space "$@" | view - } compdef _git giD=git-diff alias gir='git reset' compdef _git gir=git-reset @@ -235,7 +235,7 @@ alias gwS='git status' compdef _git gwS=git-status alias gwd='git diff --no-ext-diff' compdef _git gwd=git-diff -function gwD() { git diff --no-ext-diff --ignore-all-space "$@" | view - } +function gwD { git diff --no-ext-diff --ignore-all-space "$@" | view - } compdef _git gwD=git-diff alias gwr='git reset --soft' compdef _git gwr=git-reset diff --git a/plugins/git/functions/git-info b/plugins/git/functions/git-info index eb0796d..b32ead7 100644 --- a/plugins/git/functions/git-info +++ b/plugins/git/functions/git-info @@ -6,7 +6,7 @@ # # Gets the path to the Git directory. -function _git-dir() { +function _git-dir { local git_root="$(git-root)" local git_dir_or_file="${git_root}/.git" local git_dir @@ -31,7 +31,7 @@ function _git-dir() { # Gets the Git special action (am, merge, rebase, etc.). # Borrowed from vcs_info and edited. -function _git-action() { +function _git-action { local action='' local action_dir local git_dir="$(_git-dir)" @@ -90,7 +90,7 @@ function _git-action() { } # Turns off git-info for the current repository. -function _git-info-abort() { +function _git-info-abort { if ! is-true "$_git_info_executing"; then return 1 fi @@ -115,7 +115,7 @@ EOF add-zsh-trap INT _git-info-abort # Gets the Git status information. -function git-info() { +function git-info { # Extended globbing is needed to parse repository status. setopt LOCAL_OPTIONS setopt EXTENDED_GLOB diff --git a/plugins/git/hub.zsh b/plugins/git/hub.zsh index 8ff4059..161fc2a 100644 --- a/plugins/git/hub.zsh +++ b/plugins/git/hub.zsh @@ -7,7 +7,7 @@ # if (( $+commands[hub] )); then - function git() { + function git { hub "$@" } fi diff --git a/plugins/gnu-utils/init.zsh b/plugins/gnu-utils/init.zsh index e1318d7..7bc3a88 100644 --- a/plugins/gnu-utils/init.zsh +++ b/plugins/gnu-utils/init.zsh @@ -6,7 +6,7 @@ # if (( $+commands[gdircolors] )); then - function __gnu_utils() { + function __gnu_utils { emulate -L zsh local gcmds local gcmd @@ -46,7 +46,7 @@ if (( $+commands[gdircolors] )); then } __gnu_utils; - function hash() { + function hash { if (( $+argv[(er)-r] )) || (( $+argv[(er)-f] )); then builtin hash "$@" __gnu_utils @@ -55,7 +55,7 @@ if (( $+commands[gdircolors] )); then fi } - function rehash() { + function rehash { hash -r "$@" } diff --git a/plugins/gpg-agent/init.zsh b/plugins/gpg-agent/init.zsh index df98b19..132aa7f 100644 --- a/plugins/gpg-agent/init.zsh +++ b/plugins/gpg-agent/init.zsh @@ -12,7 +12,7 @@ fi _gpg_env="$HOME/.gnupg/gpg-agent.env" -function _gpg-agent-start() { +function _gpg-agent-start { gpg-agent --daemon --enable-ssh-support --write-env-file "${_gpg_env}" > /dev/null chmod 600 "${_gpg_env}" source "${_gpg_env}" > /dev/null diff --git a/plugins/history-substring-search/history-substring-search.zsh b/plugins/history-substring-search/history-substring-search.zsh index affe9de..14bffb8 100644 --- a/plugins/history-substring-search/history-substring-search.zsh +++ b/plugins/history-substring-search/history-substring-search.zsh @@ -49,7 +49,7 @@ HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' # the main ZLE widgets #----------------------------------------------------------------------------- -function history-substring-search-up() { +function history-substring-search-up { _history-substring-search-begin _history-substring-search-up-history || @@ -59,7 +59,7 @@ function history-substring-search-up() { _history-substring-search-end } -function history-substring-search-down() { +function history-substring-search-down { _history-substring-search-begin _history-substring-search-down-history || @@ -93,7 +93,7 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then # simply removes any existing highlights when the # user inserts printable characters into $BUFFER. # - function _zsh_highlight() { + function _zsh_highlight { if [[ $KEYS == [[:print:]] ]]; then region_highlight=() fi @@ -136,8 +136,7 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then # #--------------8<-------------------8<-------------------8<----------------- # Rebind all ZLE widgets to make them invoke _zsh_highlights. - _zsh_highlight_bind_widgets() - { + function _zsh_highlight_bind_widgets { # Load Zsh module zsh/zleparameter, needed to override user defined widgets. zmodload zsh/zleparameter 2>/dev/null || { print 'history-substring-search: failed loading: zsh/zleparameter' >&2 @@ -163,7 +162,7 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; # Builtin widget: override and make it call the builtin ".widget". - builtin) eval "_zsh_highlight_widget_$cur_widget() { builtin zle .$cur_widget -- \"\$@\" && _zsh_highlight }; \ + builtin) eval "function _zsh_highlight_widget_$cur_widget { builtin zle .$cur_widget -- \"\$@\" && _zsh_highlight }; \ zle -N $cur_widget _zsh_highlight_widget_$cur_widget";; # Default: unhandled case. @@ -176,7 +175,7 @@ if [[ $+functions[_zsh_highlight] -eq 0 ]]; then _zsh_highlight_bind_widgets fi -function _history-substring-search-begin() { +function _history-substring-search-begin { setopt LOCAL_OPTIONS EXTENDED_GLOB _history_substring_search_move_cursor_eol=false @@ -244,7 +243,7 @@ function _history-substring-search-begin() { fi } -function _history-substring-search-end() { +function _history-substring-search-end { setopt LOCAL_OPTIONS EXTENDED_GLOB _history_substring_search_result=$BUFFER @@ -278,7 +277,7 @@ function _history-substring-search-end() { true } -function _history-substring-search-up-buffer() { +function _history-substring-search-up-buffer { # # Check if the UP arrow was pressed to move the cursor within a multi-line # buffer. This amounts to three tests: @@ -307,7 +306,7 @@ function _history-substring-search-up-buffer() { false } -function _history-substring-search-down-buffer() { +function _history-substring-search-down-buffer { # # Check if the DOWN arrow was pressed to move the cursor within a multi-line # buffer. This amounts to three tests: @@ -336,7 +335,7 @@ function _history-substring-search-down-buffer() { false } -function _history-substring-search-up-history() { +function _history-substring-search-up-history { # # Behave like up in Zsh, except clear the $BUFFER # when beginning of history is reached like in Fish. @@ -358,7 +357,7 @@ function _history-substring-search-up-history() { false } -function _history-substring-search-down-history() { +function _history-substring-search-down-history { # # Behave like down-history in Zsh, except clear the # $BUFFER when end of history is reached like in Fish. @@ -381,7 +380,7 @@ function _history-substring-search-down-history() { false } -function _history-substring-search-up-search() { +function _history-substring-search-up-search { _history_substring_search_move_cursor_eol=true # @@ -460,7 +459,7 @@ function _history-substring-search-up-search() { fi } -function _history-substring-search-down-search() { +function _history-substring-search-down-search { _history_substring_search_move_cursor_eol=true # diff --git a/plugins/osx/functions/manb b/plugins/osx/functions/manb index f837739..1268012 100644 --- a/plugins/osx/functions/manb +++ b/plugins/osx/functions/manb @@ -5,7 +5,7 @@ # Sorin Ionescu # -function manb() { +function manb { local page if (( $# > 0 )); then for page in "$@"; do diff --git a/plugins/osx/functions/manp b/plugins/osx/functions/manp index 87da47a..b2f6758 100644 --- a/plugins/osx/functions/manp +++ b/plugins/osx/functions/manp @@ -5,7 +5,7 @@ # Sorin Ionescu # -function manp() { +function manp { local page if (( $# > 0 )); then for page in "$@"; do diff --git a/plugins/osx/init.zsh b/plugins/osx/init.zsh index 83d5b17..83c4e67 100644 --- a/plugins/osx/init.zsh +++ b/plugins/osx/init.zsh @@ -12,12 +12,12 @@ alias cdf='cd "$(pfd)"' alias pushdf='pushd "$(pfd)"' # Open files in Quick Look. -function ql() { +function ql { (( $# > 0 )) && qlmanage -p "$@" &> /dev/null } # Delete .DS_Store and __MACOSX directories. -function rm-osx-cruft() { +function rm-osx-cruft { find "${@:-$PWD}" \( \ -type f -name '.DS_Store' -o \ -type d -name '__MACOSX' \ diff --git a/plugins/rails/init.zsh b/plugins/rails/init.zsh index 53bbda6..a004d6d 100644 --- a/plugins/rails/init.zsh +++ b/plugins/rails/init.zsh @@ -20,7 +20,7 @@ alias rsd='_rails-command server --debugger' alias devlog='tail -f log/development.log' # Functions -function _rails-command() { +function _rails-command { if [[ -e "script/server" ]]; then ruby script/"$@" else diff --git a/plugins/ssh-agent/init.zsh b/plugins/ssh-agent/init.zsh index 9d67ffa..5cc43e7 100644 --- a/plugins/ssh-agent/init.zsh +++ b/plugins/ssh-agent/init.zsh @@ -27,7 +27,7 @@ fi _ssh_agent_env="${HOME}/.ssh/environment-${HOST}" _ssh_agent_forwarding= -function _ssh-agent-start() { +function _ssh-agent-start { local -a identities # Start ssh-agent and setup the environment. diff --git a/plugins/z/init.zsh b/plugins/z/init.zsh index e08e16a..b3d1e28 100644 --- a/plugins/z/init.zsh +++ b/plugins/z/init.zsh @@ -16,7 +16,7 @@ fi if (( $+functions[_z] )); then alias z='nocorrect _z 2>&1' alias j='z' - function z-precmd () { + function z-precmd { z --add "$(pwd -P)" } autoload -Uz add-zsh-hook diff --git a/terminal.zsh b/terminal.zsh index e709577..a83fa98 100644 --- a/terminal.zsh +++ b/terminal.zsh @@ -19,28 +19,28 @@ else fi # Sets the GNU Screen title. -function set-screen-title() { +function set-screen-title { if [[ "$TERM" == screen* ]]; then printf "\ek%s\e\\" ${(V)argv} fi } # Sets the terminal window title. -function set-window-title() { +function set-window-title { if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then printf "\e]2;%s\a" ${(V)argv} fi } # Sets the terminal tab title. -function set-tab-title() { +function set-tab-title { if [[ "$TERM" == ((x|a|ml|dt|E)term*|(u|)rxvt*) ]]; then printf "\e]1;%s\a" ${(V)argv} fi } # Sets the tab and window titles with the command name. -function set-title-by-command() { +function set-title-by-command { emulate -L zsh setopt LOCAL_OPTIONS EXTENDED_GLOB @@ -77,7 +77,7 @@ function set-title-by-command() { autoload -Uz add-zsh-hook # Sets the tab and window titles before the prompt is displayed. -function set-title-precmd() { +function set-title-precmd { if [[ "$TERM_PROGRAM" != "Apple_Terminal" ]] && zstyle -t ':omz:terminal' auto-title; then set-window-title "${(%):-%~}" for kind in tab screen; do @@ -92,7 +92,7 @@ function set-title-precmd() { add-zsh-hook precmd set-title-precmd # Sets the tab and window titles before command execution. -function set-title-preexec() { +function set-title-preexec { if zstyle -t ':omz:terminal' auto-title; then set-title-by-command "$2" fi diff --git a/themes/minimal/prompt_minimal_setup b/themes/minimal/prompt_minimal_setup index fbd60f2..4cd791c 100644 --- a/themes/minimal/prompt_minimal_setup +++ b/themes/minimal/prompt_minimal_setup @@ -13,11 +13,11 @@ function +vi-git-status() { fi } -function prompt_minimal_precmd () { +function prompt_minimal_precmd { vcs_info } -function prompt_minimal_setup() { +function prompt_minimal_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS prompt_opts=(cr percent subst) diff --git a/themes/nicoulaj/prompt_nicoulaj_setup b/themes/nicoulaj/prompt_nicoulaj_setup index 2d7d936..3b36c84 100644 --- a/themes/nicoulaj/prompt_nicoulaj_setup +++ b/themes/nicoulaj/prompt_nicoulaj_setup @@ -16,11 +16,11 @@ # - Shows if logged in as root or not. # -function prompt_nicoulaj_precmd() { +function prompt_nicoulaj_precmd { vcs_info } -function prompt_nicoulaj_setup() { +function prompt_nicoulaj_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS prompt_opts=(cr percent subst) diff --git a/themes/sorin/prompt_sorin_setup b/themes/sorin/prompt_sorin_setup index 68c73e1..8068816 100644 --- a/themes/sorin/prompt_sorin_setup +++ b/themes/sorin/prompt_sorin_setup @@ -8,7 +8,7 @@ # http://i.imgur.com/aipDQ.png # -function prompt_sorin_precmd () { +function prompt_sorin_precmd { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS @@ -17,7 +17,7 @@ function prompt_sorin_precmd () { fi } -function prompt_sorin_setup() { +function prompt_sorin_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS prompt_opts=(cr percent subst) diff --git a/themes/steeef/prompt_steeef_setup b/themes/steeef/prompt_steeef_setup index 9d52842..541c7ce 100644 --- a/themes/steeef/prompt_steeef_setup +++ b/themes/steeef/prompt_steeef_setup @@ -9,13 +9,13 @@ # Sorin Ionescu # -function virtualenv_info() { +function virtualenv_info { if [[ -n "$VIRTUAL_ENV" ]]; then print "(${VIRTUAL_ENV:t}) " fi } -function prompt_steeef_precmd() { +function prompt_steeef_precmd { if [[ -n "$__PROMPT_STEEEF_VCS_UPDATE" ]] ; then # Check for untracked files or updated submodules since vcs_info doesn't. if [[ ! -z $(git ls-files --other --exclude-standard 2> /dev/null) ]]; then @@ -31,7 +31,7 @@ function prompt_steeef_precmd() { fi } -function prompt_steeef_preexec() { +function prompt_steeef_preexec { case "$(history $HISTCMD)" in (*git*) __PROMPT_STEEEF_VCS_UPDATE=1 @@ -42,11 +42,11 @@ function prompt_steeef_preexec() { esac } -function prompt_steeef_chpwd() { +function prompt_steeef_chpwd { __PROMPT_STEEEF_VCS_UPDATE=1 } -function prompt_steeef_setup() { +function prompt_steeef_setup { setopt LOCAL_OPTIONS unsetopt XTRACE KSH_ARRAYS prompt_opts=(cr percent subst) diff --git a/utility.zsh b/utility.zsh index 50a7654..51dce06 100644 --- a/utility.zsh +++ b/utility.zsh @@ -14,42 +14,42 @@ alias history-stat="history | awk '{print \$2}' | sort | uniq -c | sort -n -r | alias http-serve='python -m SimpleHTTPServer' # Makes a directory and changes to it. -function mkdcd() { +function mkdcd { [[ -n "$1" ]] && mkdir -p "$1" && cd "$1" } compdef _mkdir mkdcd # Changes to a directory and lists its contents. -function cdll() { +function cdll { builtin cd "$1" && ll } compdef _cd cdll # Pushes an entry onto the directory stack and lists its contents. -function pushdll() { +function pushdll { builtin pushd "$1" && ll } compdef _cd pushdll # Pops an entry off the directory stack and lists its contents. -function popdll() { +function popdll { builtin popd "$1" && ll } compdef _cd popdll # Prints columns 1 2 3 ... n. -function slit() { +function slit { awk "{ print $(for n; do print -n "\$$n,"; done | sed 's/,$//') }" } # Displays user owned process status. -function pmine() { +function pmine { ps "$@" -U "$USER" -o pid,%cpu,%mem,command } compdef _ps pmine # Finds files and executes a command on them. -function find-exec() { +function find-exec { find . -type f -iname "*${1:-}*" -exec "${2:-file}" '{}' \; }