Remove function definition (unalias equivalent) [duplicate]

情到浓时终转凉″ 提交于 2019-12-03 02:57:22

问题


I'm currently building a program which adds to the current user's shell depending on the project he's working on, by defining per-project aliases and functions. These aliases and functions may and will certainly have the same name like for instance cdproj, which would cd to the project's root.

I would like to remove previously defined aliases and functions when changing project (before (re)defining aliases and functions for the other project. I know I can remove an alias with unalias in both bash and zsh, but how would I do the same for a function?


回答1:


unset -f my_function

will remove (or unset) the function my_function




回答2:


unfunction my_function in zsh

Perhaps, I'm a bit late in this good old '15, but this feature persists.



来源:https://stackoverflow.com/questions/6807188/remove-function-definition-unalias-equivalent

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!