Fish 鱼壳自动清洗机

Fish 鱼壳自动清洗机,fish,Fish,我的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 er

我的
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
这很有效。但是,我也希望在同一个pwd中,但没有命令的情况下,当我按下enter键时触发这个


我找不到方法检查是否按下了enter键,但没有命令更改[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\u提示符事件函数中测试
$\u empty\u命令。请注意,[ctrl-j]也会调用execute命令,因此您可能也应该
bind\cj
到相同的代码。但这是可选的,除非您有一个不寻常的终端配置。

谢谢您,Kurtis!很有魅力