← 返回命令列表

Linux command

unhash 命令

文件

复制后可按需替换文件名、目录或参数。

常用示例

Remove a command

unhash [ls]

Remove an alias

unhash -a [ll]

Example

unhash -f [my_function]

Example

unhash -d [projects]

Example

unhash -s [md]

Example

unhash -m "[tmp_*]"

说明

unhash is a Zsh built-in that removes a named entry from one of the shell's internal hash tables. By default it operates on the command hash table, which caches the full path of recently executed commands. Options select an alternate table (aliases, functions, named directories, or suffix aliases) and the -m flag treats the remaining arguments as patterns matching multiple entries at once. The related built-ins unalias, unfunction, and unsetopt are thin wrappers that call unhash with the appropriate flag preset. Using unhash directly is mainly useful inside scripts and functions where the table being modified is determined dynamically.

参数

-a
Remove regular or global aliases. Equivalent to unalias.
-s
Remove suffix aliases.
-f
Remove shell functions. Equivalent to unfunction.
-d
Remove named directory entries created with hash -d.
-m
Treat each _name_ as a pattern; every matching entry in the selected table is removed. Patterns should be quoted to prevent filename expansion.

FAQ

What is the unhash command used for?

unhash is a Zsh built-in that removes a named entry from one of the shell's internal hash tables. By default it operates on the command hash table, which caches the full path of recently executed commands. Options select an alternate table (aliases, functions, named directories, or suffix aliases) and the -m flag treats the remaining arguments as patterns matching multiple entries at once. The related built-ins unalias, unfunction, and unsetopt are thin wrappers that call unhash with the appropriate flag preset. Using unhash directly is mainly useful inside scripts and functions where the table being modified is determined dynamically.

How do I run a basic unhash example?

Run `unhash [ls]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -a do in unhash?

Remove regular or global aliases. Equivalent to unalias.