Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove a Z shell precmd function?

Tags:

zsh

ubuntu

I have a few functions in my Z shell precmd function list.

I can see them with

echo $precmd_functions

In this list I can see a function called _ntfy_precmd

How can I remove it from the function list?

(This function was added after installing https://github.com/dschep/ntfy)

like image 771
Eyal Levin Avatar asked Feb 08 '17 09:02

Eyal Levin


1 Answers

Just as with adding functions to precmd you have two choices:

  1. Directly manipulate the precmd_functions array:

    precmd_functions=(${precmd_functions:#_ntfy_precmd})
    

    The ${name:#pattern} parameter expansion, when used on an array, removes all elements matching pattern from the expansion of name.

  2. Use the add-zsh-hook utility to remove functions from the hook functions lists:

    add-zsh-hook -d precmd _ntfy_precmd
    

    If zsh tells you that there is no add-zsh-hook command, you can load it with

    autoload -Uz add-zsh-hook
    

BTW: You can list the functions with add-zsh-hook -L [HOOK], too.

like image 165
Adaephon Avatar answered Nov 15 '22 04:11

Adaephon