分页: 1 / 2
zsh的小hook,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-20 0:11
由 riptide2012
每次./太烦人实在受不了,又正好看到zsh的hook函数,就有了这个,效果很赞
喜欢的自己抱走...
代码: 全选
export PATH=$HOME/curd:$PATH
function chpwd(){
rm -f "$HOME/curd"
ln -sf "$(pwd -P)" "$HOME/curd"
hash -r
}
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-20 0:13
由 枫叶饭团
说实话,./我至少有一月个没用过了
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-20 7:59
由 YeLee
代码: 全选
export PATH=$PATH:.
我一直以为是这样的。

Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-20 8:11
由 riptide2012
YeLee 写了:代码: 全选
export PATH=$PATH:.
我一直以为是这样的。

尼玛,这样也行阿
经典了
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 7:03
由 aerofox
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 13:47
由 riptide2012
aerofox 写了:这样也行:
少了后面那个点。
没试出来...
那个点可以理解为展开成当前目录,这个什么都不加算什么意思呢?
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 14:01
由 lilydjwg
如果你是一台公共电脑上的 root,那我就去 /tmp 目录放个 ls 好了。
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 14:03
由 YeLee
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 16:56
由 riptide2012
lilydjwg 写了:如果你是一台公共电脑上的 root,那我就去 /tmp 目录放个 ls 好了。
跟不上思路了

Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 16:57
由 枫叶饭团
不能这么邪恶
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 19:12
由 lilydjwg
好吧,*BSD 也算。
多人使用同一类 Unix 系统的电脑很常见啊,当然是开 ssh 连上去的。我可没说特指桌面用户的电脑。
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 21:56
由 aerofox
riptide2012 写了:aerofox 写了:这样也行:
少了后面那个点。
没试出来...
那个点可以理解为展开成当前目录,这个什么都不加算什么意思呢?
PATH
The search path for commands. It is a colon-separated list of directories in which the shell looks for commands (see COMMAND EXECUTION below). A zero-length (null) directory name in the value of PATH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon. The default path is system-dependent, and is set by the administrator who installs bash. A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''.
上面的内容摘自bash的帮助,zsh的帮助太长了,懒得找,不过恰好也是支持这种方式的。
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-21 22:55
由 riptide2012
aerofox 写了:riptide2012 写了:aerofox 写了:这样也行:
少了后面那个点。
没试出来...
那个点可以理解为展开成当前目录,这个什么都不加算什么意思呢?
PATH
The search path for commands. It is a colon-separated list of directories in which the shell looks for commands (see COMMAND EXECUTION below). A zero-length (null) directory name in the value of PATH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon. The default path is system-dependent, and is set by the administrator who installs bash. A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin''.
上面的内容摘自bash的帮助,zsh的帮助太长了,懒得找,不过恰好也是支持这种方式的。
我到干净的bash和zsh试了下,的确都是可以的。看来这笔账要算到oh-my-zsh上面了...

Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-27 14:06
由 tusooa
lilydjwg 写了:如果你是一台公共电脑上的 root,那我就去 /tmp 目录放个 ls 好了。
注意。.在PATH的最后。
Re: zsh的小hack,执行当前目录的可执行文件,不用输入./
发表于 : 2012-08-27 16:05
由 lilydjwg
tusooa 写了:lilydjwg 写了:如果你是一台公共电脑上的 root,那我就去 /tmp 目录放个 ls 好了。
注意。.在PATH的最后。
哦,那问题不大= =