Browse Source

[Fix #60] Do not use parentheses in function names

master
Sorin Ionescu 13 years ago
parent
commit
6a9a4ea8d6
  1. 4
      alias.zsh
  2. 2
      functions/duh
  3. 10
      helper.zsh
  4. 6
      keyboard.zsh
  5. 4
      plugins/git/alias.zsh
  6. 8
      plugins/git/functions/git-info
  7. 2
      plugins/git/hub.zsh
  8. 6
      plugins/gnu-utils/init.zsh
  9. 2
      plugins/gpg-agent/init.zsh
  10. 27
      plugins/history-substring-search/history-substring-search.zsh
  11. 2
      plugins/osx/functions/manb
  12. 2
      plugins/osx/functions/manp
  13. 4
      plugins/osx/init.zsh
  14. 2
      plugins/rails/init.zsh
  15. 2
      plugins/ssh-agent/init.zsh
  16. 2
      plugins/z/init.zsh
  17. 12
      terminal.zsh
  18. 4
      themes/minimal/prompt_minimal_setup
  19. 4
      themes/nicoulaj/prompt_nicoulaj_setup
  20. 4
      themes/sorin/prompt_sorin_setup
  21. 10
      themes/steeef/prompt_steeef_setup
  22. 14
      utility.zsh

4
alias.zsh

@ -99,7 +99,7 @@ fi @@ -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 @@ -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 \

2
functions/duh

@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
function duh() {
function duh {
(( $# == 0 )) && set -- *
if [[ "$OSTYPE" == linux* ]]; then
du -khsc "$@" | sort -h -r

10
helper.zsh

@ -6,17 +6,17 @@ @@ -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=( @@ -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() { @@ -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\"

6
keyboard.zsh

@ -79,7 +79,7 @@ zle -N zle-line-finish @@ -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() { @@ -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() { @@ -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 ))

4
plugins/git/alias.zsh

@ -86,7 +86,7 @@ alias giu='git add --update' @@ -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' @@ -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

8
plugins/git/functions/git-info

@ -6,7 +6,7 @@ @@ -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() { @@ -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() { @@ -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 @@ -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

2
plugins/git/hub.zsh

@ -7,7 +7,7 @@ @@ -7,7 +7,7 @@
#
if (( $+commands[hub] )); then
function git() {
function git {
hub "$@"
}
fi

6
plugins/gnu-utils/init.zsh

@ -6,7 +6,7 @@ @@ -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 @@ -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 @@ -55,7 +55,7 @@ if (( $+commands[gdircolors] )); then
fi
}
function rehash() {
function rehash {
hash -r "$@"
}

2
plugins/gpg-agent/init.zsh

@ -12,7 +12,7 @@ fi @@ -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

27
plugins/history-substring-search/history-substring-search.zsh

@ -49,7 +49,7 @@ HISTORY_SUBSTRING_SEARCH_GLOBBING_FLAGS='i' @@ -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() { @@ -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 @@ -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 @@ -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 @@ -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 @@ -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() { @@ -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() { @@ -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() { @@ -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() { @@ -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() { @@ -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() { @@ -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() { @@ -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
#

2
plugins/osx/functions/manb

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

2
plugins/osx/functions/manp

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

4
plugins/osx/init.zsh

@ -12,12 +12,12 @@ alias cdf='cd "$(pfd)"' @@ -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' \

2
plugins/rails/init.zsh

@ -20,7 +20,7 @@ alias rsd='_rails-command server --debugger' @@ -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

2
plugins/ssh-agent/init.zsh

@ -27,7 +27,7 @@ fi @@ -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.

2
plugins/z/init.zsh

@ -16,7 +16,7 @@ fi @@ -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

12
terminal.zsh

@ -19,28 +19,28 @@ else @@ -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() { @@ -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() { @@ -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

4
themes/minimal/prompt_minimal_setup

@ -13,11 +13,11 @@ function +vi-git-status() { @@ -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)

4
themes/nicoulaj/prompt_nicoulaj_setup

@ -16,11 +16,11 @@ @@ -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)

4
themes/sorin/prompt_sorin_setup

@ -8,7 +8,7 @@ @@ -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 () { @@ -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)

10
themes/steeef/prompt_steeef_setup

@ -9,13 +9,13 @@ @@ -9,13 +9,13 @@
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
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() { @@ -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() { @@ -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)

14
utility.zsh

@ -14,42 +14,42 @@ alias history-stat="history | awk '{print \$2}' | sort | uniq -c | sort -n -r | @@ -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}" '{}' \;
}

Loading…
Cancel
Save