鱼的 AutoLS shell
AutoLS for fish shell
我的 conf.d
目录中有一个 auto-ls
脚本
function __autols_hook --description "Auto ls" --on-event fish_prompt
if test "$__autols_last" != (pwd)
if test "$HOME" = (pwd)
else
clear; ls;
# Show git information, and if it's not a git repo, throw error
# into /dev/null. Simples
git status 2>/dev/null
end
end
set -g __autols_last (pwd)
end
这个效果很好。但是,我也希望在我按下回车键时触发它,在同一个密码中,但没有命令。
我找不到检查是否按下了回车键但没有命令的方法
更改 [enter] 键的绑定:
bind \cm 'set -l cmd (commandline); test -z "$cmd"; and set -g _empty_command yes; or set -g _empty_command no; commandline -f execute'
现在您可以在 fish_prompt 事件函数中测试 $_empty_command
。请注意,[ctrl-j] 也会调用执行命令,因此您可能也应该 bind \cj
执行相同的代码。但这是可选的,除非你有一个不寻常的终端配置。
我的 conf.d
目录中有一个 auto-ls
脚本
function __autols_hook --description "Auto ls" --on-event fish_prompt
if test "$__autols_last" != (pwd)
if test "$HOME" = (pwd)
else
clear; ls;
# Show git information, and if it's not a git repo, throw error
# into /dev/null. Simples
git status 2>/dev/null
end
end
set -g __autols_last (pwd)
end
这个效果很好。但是,我也希望在我按下回车键时触发它,在同一个密码中,但没有命令。
我找不到检查是否按下了回车键但没有命令的方法
更改 [enter] 键的绑定:
bind \cm 'set -l cmd (commandline); test -z "$cmd"; and set -g _empty_command yes; or set -g _empty_command no; commandline -f execute'
现在您可以在 fish_prompt 事件函数中测试 $_empty_command
。请注意,[ctrl-j] 也会调用执行命令,因此您可能也应该 bind \cj
执行相同的代码。但这是可选的,除非你有一个不寻常的终端配置。