feat(base): improve fzf wrappers
This commit is contained in:
parent
4dbec7bade
commit
795d6ececd
3 changed files with 30 additions and 27 deletions
|
@ -14,6 +14,18 @@ let
|
|||
'';
|
||||
};
|
||||
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
|
||||
{
|
||||
users.users.moritz = {
|
||||
|
@ -45,8 +57,6 @@ in
|
|||
mv = "mv -i";
|
||||
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-boot = nom-system-command "sudo nixos-rebuild boot --flake ~/.dotfiles";
|
||||
nixos-update = "pushd ~/.dotfiles && nix flake update && popd";
|
||||
|
@ -118,6 +128,7 @@ in
|
|||
viu
|
||||
wget
|
||||
vim
|
||||
f
|
||||
];
|
||||
|
||||
fonts.fonts = with pkgs; [
|
||||
|
|
|
@ -4,30 +4,6 @@ with lib;
|
|||
let
|
||||
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 {
|
||||
name = "tmux-switch";
|
||||
runtimeInputs = with pkgs; [ tmux ];
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{ inputs, lib, ... }:
|
||||
|
||||
_: prev:
|
||||
final: prev:
|
||||
{
|
||||
agenix = inputs.agenix.packages.${prev.system}.default;
|
||||
hyprpaper = inputs.hyprpaper.packages.${prev.system}.default;
|
||||
|
@ -10,4 +10,20 @@ _: prev:
|
|||
src = 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"
|
||||
'';
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue