feat(base): improve fzf wrappers

nixos
Moritz Böhme 2023-07-15 12:46:53 +02:00
parent 4dbec7bade
commit 795d6ececd
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
3 changed files with 30 additions and 27 deletions

View File

@ -14,6 +14,18 @@ let
''; '';
}; };
nom-system-command = command: "${nom-system}/bin/nom-system && ${command}"; nom-system-command = command: "${nom-system}/bin/nom-system && ${command}";
f = pkgs.writeFishApplication {
name = "f";
runtimeInputs = with pkgs; [ fzf bat ];
text = ''
#!/usr/bin/env fish
fzf --query "$argv" --multi --bind "enter:become($EDITOR {+})" --preview "bat --color=always --style=header,grid --line-range :500 {+}"
'';
completions = ''
complete -c f
'';
};
in in
{ {
users.users.moritz = { users.users.moritz = {
@ -45,8 +57,6 @@ in
mv = "mv -i"; mv = "mv -i";
cd = "z"; cd = "z";
f = ''fzf --multi --bind "enter:become($EDITOR {+})" --preview "bat --color=always --style=header,grid --line-range :500 {+}"'';
nixos-switch = nom-system-command "sudo nixos-rebuild switch --flake ~/.dotfiles"; nixos-switch = nom-system-command "sudo nixos-rebuild switch --flake ~/.dotfiles";
nixos-boot = nom-system-command "sudo nixos-rebuild boot --flake ~/.dotfiles"; nixos-boot = nom-system-command "sudo nixos-rebuild boot --flake ~/.dotfiles";
nixos-update = "pushd ~/.dotfiles && nix flake update && popd"; nixos-update = "pushd ~/.dotfiles && nix flake update && popd";
@ -118,6 +128,7 @@ in
viu viu
wget wget
vim vim
f
]; ];
fonts.fonts = with pkgs; [ fonts.fonts = with pkgs; [

View File

@ -4,30 +4,6 @@ with lib;
let let
cfg = config.my.programs.tmux; cfg = config.my.programs.tmux;
fzf1 = pkgs.writeShellApplication {
name = "fzf1";
runtimeInputs = with pkgs; [ coreutils fzf ];
text = ''
#!/usr/bin/env bash
options=$(fzf --filter "''$*" < /dev/stdin)
if [[ -z $options ]]; then
exit 1
elif [[ $(wc -l <<< "$options") -eq 1 ]]; then
selected="$options"
else
selected=$(echo "$options" | fzf --query="$*")
fi
if [[ -z $selected ]]; then
exit 0
fi
echo "$selected"
'';
};
tmux-switch = pkgs.writeShellApplication { tmux-switch = pkgs.writeShellApplication {
name = "tmux-switch"; name = "tmux-switch";
runtimeInputs = with pkgs; [ tmux ]; runtimeInputs = with pkgs; [ tmux ];

View File

@ -1,6 +1,6 @@
{ inputs, lib, ... }: { inputs, lib, ... }:
_: prev: final: prev:
{ {
agenix = inputs.agenix.packages.${prev.system}.default; agenix = inputs.agenix.packages.${prev.system}.default;
hyprpaper = inputs.hyprpaper.packages.${prev.system}.default; hyprpaper = inputs.hyprpaper.packages.${prev.system}.default;
@ -10,4 +10,20 @@ _: prev:
src = inputs.rofi-wayland; src = inputs.rofi-wayland;
version = lib.my.mkVersionInput inputs.rofi-wayland; version = lib.my.mkVersionInput inputs.rofi-wayland;
}); });
fzf1 = final.writeShellApplication {
name = "fzf1";
runtimeInputs = with final; [ coreutils fzf fd ];
text = ''
#!/usr/bin/env bash
selected=$(fzf --query="$*" -1 < /dev/stdin)
if [[ -z $selected ]]; then
exit 0
fi
echo "$selected"
'';
};
} }