nushell fzf

This commit is contained in:
Sascha Koenig 2025-05-19 21:03:09 +02:00
parent 22cbc7c5a2
commit 72ceffc61d
8 changed files with 55 additions and 43 deletions

View File

@ -1,7 +1,7 @@
{pkgs, ...}: { {pkgs, ...}: {
imports = [ imports = [
./fish.nix ./fish.nix
./skim.nix ./fzf.nix
./nitch.nix ./nitch.nix
./nushell.nix ./nushell.nix
./secrets.nix ./secrets.nix

40
home/features/cli/fzf.nix Normal file
View File

@ -0,0 +1,40 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.features.cli.fzf;
in {
options.features.cli.fzf.enable = mkEnableOption "enable fuzzy finder";
config = mkIf cfg.enable {
programs.fzf = {
enable = true;
enableFishIntegration = true;
colors = {
"fg" = "#f8f8f2";
"bg" = "#282a36";
"hl" = "#bd93f9";
"fg+" = "#f8f8f2";
"bg+" = "#44475a";
"hl+" = "#bd93f9";
"info" = "#ffb86c";
"prompt" = "#50fa7b";
"pointer" = "#ff79c6";
"marker" = "#ff79c6";
"spinner" = "#ffb86c";
"header" = "#6272a4";
};
defaultOptions = [
"--preview='bat --color=always -n {}'"
"--bind 'ctrl-/:toggle-preview'"
"--header 'Press CTRL-Y to copy command into clipboard'"
"--bind 'ctrl-/:toggle-preview'"
"--bind 'ctrl-y:execute-silent(echo -n {2..} | wl-copy)+abort'"
];
defaultCommand = "fd --type f --exclude .git --follow --hidden";
changeDirWidgetCommand = "fd --type d --exclude .git --follow --hidden";
};
};
}

View File

@ -22,13 +22,6 @@ in {
$env.VISUAL = "zed" $env.VISUAL = "zed"
$env.XDG_DATA_HOME = $"($env.HOME)/.local/share" $env.XDG_DATA_HOME = $"($env.HOME)/.local/share"
$env.FZF_DEFAULT_COMMAND = "fd --type f --exclude .git --follow --hidden" $env.FZF_DEFAULT_COMMAND = "fd --type f --exclude .git --follow --hidden"
$env.FZF_DEFAULT_OPTS = "
--preview='bat --color=always -n {}'
--preview-window up:3:hidden:wrap
--bind 'ctrl-/:toggle-preview'
--bind 'ctrl-y:execute-silent(echo -n {2..} | wl-copy)+abort'
--color header:bold
--header 'Press CTRL-Y to copy command into clipboard'"
$env.FLAKE = $"($env.HOME)/p/nixos/nixos-config" $env.FLAKE = $"($env.HOME)/p/nixos/nixos-config"
source /run/agenix/${config.home.username}-secrets source /run/agenix/${config.home.username}-secrets
''; '';
@ -73,12 +66,14 @@ in {
def history_fuzzy [] { def history_fuzzy [] {
let selected = ( let selected = (
history history
| uniq | reverse
| get command | get command
| sk --height 40% --layout=reverse --color=fg:#f8f8f2,bg:#282a36,current_bg:#ff79c6,current_fg:#bd93f9,info:#ffb86c,marker:#6272a4,pointer:#50fa7b,spinner:#50fa7b | uniq
| to text
| ^fzf
) )
if ($selected | is-not-empty) { if ($selected | is-not-empty) {
^nu -c ($selected) commandline edit ($selected)
} else { } else {
null null
} }
@ -86,7 +81,7 @@ in {
def --env dir_fuzzy [] { def --env dir_fuzzy [] {
let selected = ( let selected = (
fd --type directory fd --type directory
| ^sk --preview 'eza --tree --no-permissions --no-filesize --no-user --no-time --only-dirs {}' --height 40% --layout=reverse --color=fg:#f8f8f2,bg:#282a36,current_bg:#ff79c6,current_fg:#bd93f9,info:#ffb86c,marker:#6272a4,pointer:#50fa7b,spinner:#50fa7b | ^fzf
) )
cd $selected cd $selected
} }
@ -95,11 +90,8 @@ in {
let selected = ( let selected = (
^fd --type file --no-hidden -X rg -l --files-with-matches . ^fd --type file --no-hidden -X rg -l --files-with-matches .
| lines | lines
| sk --format { $in } | to text
--height 40% | ^fzf
--layout=reverse
--preview { open $in | bat --color=always --line-range :50 }
--color=fg:#f8f8f2,bg:#282a36,current_bg:#ff79c6,current_fg:#bd93f9,info:#ffb86c,marker:#6272a4,pointer:#50fa7b,spinner:##50fa7b
) )
if ($selected | is-not-empty) { if ($selected | is-not-empty) {
^$env.EDITOR $selected ^$env.EDITOR $selected

View File

@ -1,23 +0,0 @@
{
config,
lib,
...
}:
with lib; let
cfg = config.features.cli.skim;
in {
options.features.cli.skim.enable = mkEnableOption "enable skim fuzzy finder";
config = mkIf cfg.enable {
programs.skim = {
enable = true;
enableFishIntegration = true;
defaultOptions = [
"--preview='bat --color=always -n {}'"
"--bind 'ctrl-/:toggle-preview'"
];
defaultCommand = "fd --type f --exclude .git --follow --hidden";
changeDirWidgetCommand = "fd --type d --exclude .git --follow --hidden";
};
};
}

View File

@ -50,7 +50,7 @@ in {
cli = { cli = {
fish.enable = true; fish.enable = true;
nushell.enable = true; nushell.enable = true;
skim.enable = true; fzf.enable = true;
nitch.enable = true; nitch.enable = true;
secrets.enable = true; secrets.enable = true;
starship.enable = true; starship.enable = true;

View File

@ -48,7 +48,7 @@ in {
features = { features = {
cli = { cli = {
nushell.enable = true; nushell.enable = true;
skim.enable = true; fzf.enable = true;
nitch.enable = true; nitch.enable = true;
secrets.enable = true; secrets.enable = true;
starship.enable = true; starship.enable = true;

View File

@ -1,6 +1,6 @@
{pkgs, ...}: { {pkgs, ...}: {
services.udev.extraRules = '' services.udev.extraRules = ''
SUBSYSTEM=="usb", MODE="0666 SUBSYSTEM=="usb", MODE="0666"
''; '';
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
zsa-udev-rules zsa-udev-rules

View File

@ -1,4 +1,7 @@
{pkgs, ...}: { {pkgs, ...}: {
services.udev.extraRules = ''
SUBSYSTEM=="usb", MODE="0666"
'';
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
zsa-udev-rules zsa-udev-rules
]; ];