如何在 Bash 中屏蔽股票命令

dot*_*hen 4 command-line bash paths

我有一个经常从 CLI 运行的函数,所以我给它起了一个简称t

$ which t
/home/dotancohen/.bin/t

$ cat `which t`
#!/bin/bash
ctags-exuberant -f php.tags --languages=PHP -R

$ ls -lh /home/dotancohen/.bin/t
-rwxr-xr-x 1 dotancohen dotancohen 316 Jan  3 16:58 /home/dotancohen/.bin/t

$ echo $PATH
/home/dotancohen/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/home/dotancohen/.rvm/bin
Run Code Online (Sandbox Code Playgroud)

但是,当我尝试运行该程序时,我收到一条消息,提示我应该安装另一个也使用该名称的应用程序t

$ t
The program 'task' is currently not installed. To run 'task' please ask your administrator to install the package 'taskwarrior'
Run Code Online (Sandbox Code Playgroud)

/home/dotancohen/.bin/t当我进入时如何让 Bash 运行t

hee*_*ayl 8

这是因为您已t定义为别名(或函数),您可以使用type内置函数找到它:

type -a t
Run Code Online (Sandbox Code Playgroud)

别名、函数(和其他 shell 内置函数)优先于外部可执行文件。

要从您的 运行可执行文件t,请PATH执行以下操作:

't'
Run Code Online (Sandbox Code Playgroud)

或者

"t"
Run Code Online (Sandbox Code Playgroud)

或者

\t
Run Code Online (Sandbox Code Playgroud)

请注意, justt不是文件的好名称。