forked from mirrors/nixpkgs
Merge pull request #5726 from spwhitt/zsh-command-not-found
command-not-found: Add ZSH Support
This commit is contained in:
commit
b92a62165d
|
@ -54,8 +54,8 @@
|
|||
./misc/version.nix
|
||||
./programs/atop.nix
|
||||
./programs/bash/bash.nix
|
||||
./programs/bash/command-not-found.nix
|
||||
./programs/blcr.nix
|
||||
./programs/command-not-found/command-not-found.nix
|
||||
./programs/dconf.nix
|
||||
./programs/environment.nix
|
||||
./programs/info.nix
|
||||
|
|
|
@ -44,6 +44,26 @@ in
|
|||
}
|
||||
'';
|
||||
|
||||
programs.zsh.interactiveShellInit =
|
||||
''
|
||||
# This function is called whenever a command is not found.
|
||||
command_not_found_handler() {
|
||||
local p=/run/current-system/sw/bin/command-not-found
|
||||
if [ -x $p -a -f /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite ]; then
|
||||
# Run the helper program.
|
||||
$p "$1"
|
||||
|
||||
# Retry the command if we just installed it.
|
||||
if [ $? = 126 ]; then
|
||||
"$@"
|
||||
fi
|
||||
else
|
||||
# Indicate than there was an error so ZSH falls back to its default handler
|
||||
return 127
|
||||
fi
|
||||
}
|
||||
'';
|
||||
|
||||
environment.systemPackages = [ commandNotFound ];
|
||||
|
||||
# TODO: tab completion for uninstalled commands! :-)
|
Loading…
Reference in a new issue