mirror of
https://github.com/nmasur/dotfiles
synced 2025-07-06 19:00:14 +00:00
fish functions and user key bindings
This commit is contained in:
@ -36,45 +36,60 @@ in
|
||||
};
|
||||
functions = {
|
||||
nix-shell-run = {
|
||||
body = ''
|
||||
set program $argv[1]
|
||||
if test (count $argv) -ge 2
|
||||
commandline -r "nix run nixpkgs#$program -- $argv[2..-1]"
|
||||
else
|
||||
commandline -r "nix run nixpkgs#$program"
|
||||
end
|
||||
commandline -f execute
|
||||
'';
|
||||
body = # fish
|
||||
''
|
||||
set program $argv[1]
|
||||
if test (count $argv) -ge 2
|
||||
commandline -r "nix run nixpkgs#$program -- $argv[2..-1]"
|
||||
else
|
||||
commandline -r "nix run nixpkgs#$program"
|
||||
end
|
||||
commandline -f execute
|
||||
'';
|
||||
};
|
||||
nix-fzf = {
|
||||
body = ''
|
||||
commandline -i (nix-instantiate --eval --json \
|
||||
-E 'builtins.attrNames (import <nixpkgs> {})' \
|
||||
| jq '.[]' -r | fzf)
|
||||
commandline -f repaint
|
||||
'';
|
||||
body = # fish
|
||||
''
|
||||
commandline -i (nix-instantiate --eval --json \
|
||||
-E 'builtins.attrNames (import <nixpkgs> {})' \
|
||||
| ${lib.getExe pkgs.jq} '.[]' -r | ${lib.getExe pkgs.fzf})
|
||||
commandline -f repaint
|
||||
'';
|
||||
};
|
||||
rebuild-nixos = {
|
||||
body = ''
|
||||
git -C ${config.dotfilesPath} add --intent-to-add --all
|
||||
echo "doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName}"
|
||||
'';
|
||||
body = # fish
|
||||
''
|
||||
git -C ${config.dotfilesPath} add --intent-to-add --all
|
||||
echo "doas nixos-rebuild switch --flake ${config.dotfilesPath}#${config.networking.hostName}"
|
||||
'';
|
||||
};
|
||||
rebuild-nixos-offline = {
|
||||
body = ''
|
||||
git -C ${config.dotfilesPath} add --intent-to-add --all
|
||||
echo "doas nixos-rebuild switch --option substitute false --flake ${config.dotfilesPath}#${config.networking.hostName}"
|
||||
'';
|
||||
body = # fish
|
||||
''
|
||||
git -C ${config.dotfilesPath} add --intent-to-add --all
|
||||
echo "doas nixos-rebuild switch --option substitute false --flake ${config.dotfilesPath}#${config.networking.hostName}"
|
||||
'';
|
||||
};
|
||||
rebuild-home = {
|
||||
body = ''
|
||||
git -C ${config.dotfilesPath} add --intent-to-add --all
|
||||
echo "${pkgs.home-manager}/bin/home-manager switch --flake ${config.dotfilesPath}#${config.networking.hostName}";
|
||||
'';
|
||||
body = # fish
|
||||
''
|
||||
git -C ${config.dotfilesPath} add --intent-to-add --all
|
||||
echo "${lib.getExe pkgs.home-manager} switch --flake ${config.dotfilesPath}#${config.networking.hostName}";
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config.nmasur.presets.programs.fish.fish_user_key_bindings = # fish
|
||||
''
|
||||
# Ctrl-n
|
||||
bind -M insert \cn 'commandline -r "nix shell nixpkgs#"'
|
||||
bind -M default \cn 'commandline -r "nix shell nixpkgs#"'
|
||||
# Ctrl-Shift-n (defined by terminal)
|
||||
bind -M insert \x11F nix-fzf
|
||||
bind -M default \x11F nix-fzf
|
||||
'';
|
||||
|
||||
# Provides "command-not-found" options
|
||||
programs.nix-index = {
|
||||
enable = true;
|
||||
|
Reference in New Issue
Block a user