From 0c67a2e2127f51c8daf7120afc8fb9365a0a8a99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Eug=C3=AAnio?= Date: Tue, 9 Aug 2022 09:23:07 -0300 Subject: [PATCH] enable fzf --- scripts/screenshotsh.nix | 76 ++++++++++++++++++++-------------------- user/gpg.nix | 4 +-- user/home.nix | 23 +++++++++--- 3 files changed, 58 insertions(+), 45 deletions(-) diff --git a/scripts/screenshotsh.nix b/scripts/screenshotsh.nix index 25d0612..d2209f7 100644 --- a/scripts/screenshotsh.nix +++ b/scripts/screenshotsh.nix @@ -1,47 +1,47 @@ { config, pkgs, lib, ... }: pkgs.writeShellScriptBin "screenshotsh" '' - export XCURSOR_SIZE=40 - export XCURSOR_THEME='capitaine-cursors-light' # ${pkgs.capitaine-cursors} + export XCURSOR_SIZE=40 + export XCURSOR_THEME='capitaine-cursors-light' # ${pkgs.capitaine-cursors} - if which xdg-user-dir >/dev/null 2>&1; then - DESTFOLDER="$(${pkgs.capitaine-cursors}/bin/xdg-user-dir PICTURES)" - else - for i in Images Imagens Pictures Fotos ""; do - DESTFOLDER="$HOME/$i" - test -d "$DESTFOLDER" && - break - done - fi + if which xdg-user-dir >/dev/null 2>&1; then + DESTFOLDER="$(${pkgs.capitaine-cursors}/bin/xdg-user-dir PICTURES)" + else + for i in Images Imagens Pictures Fotos ""; do + DESTFOLDER="$HOME/$i" + test -d "$DESTFOLDER" && + break + done + fi - DESTFOLDER="$DESTFOLDER/Screenshots" - mkdir -p "$DESTFOLDER" - DESTFILE="$DESTFOLDER/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')" + DESTFOLDER="$DESTFOLDER/Screenshots" + mkdir -p "$DESTFOLDER" + DESTFILE="$DESTFOLDER/$(date +'%Y-%m-%d-%H%M%S_screenshot.png')" - case $1 in - def) - # Screenshot to file - ${pkgs.grim}/bin/grim "$DESTFILE" - echo "$DESTFILE" - ;; + case $1 in + def) + # Screenshot to file + ${pkgs.grim}/bin/grim "$DESTFILE" + echo "$DESTFILE" + ;; - area) - # Screen area to file - ${pkgs.grim}/bin/grim -g "$(slurp -d -b 30303088)" "$DESTFILE" - echo "$DESTFILE" - ;; - area-clip) - # Screen area to clipboard - ${pkgs.grim}/bin/grim -g "$(slurp -d -b 30303088)" - | ${pkgs.wl-clipboard}/bin/wl-copy - ;; + area) + # Screen area to file + ${pkgs.grim}/bin/grim -g "$(slurp -d -b 30303088)" "$DESTFILE" + echo "$DESTFILE" + ;; + area-clip) + # Screen area to clipboard + ${pkgs.grim}/bin/grim -g "$(slurp -d -b 30303088)" - | ${pkgs.wl-clipboard}/bin/wl-copy + ;; - clip) - # Focused monitor to clipboard - cur_output=$(${pkgs.sway}/bin/swaymsg -t get_outputs | - ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name') + clip) + # Focused monitor to clipboard + cur_output=$(${pkgs.sway}/bin/swaymsg -t get_outputs | + ${pkgs.jq}/bin/jq -r '.[] | select(.focused) | .name') - test -n "$cur_output" && - ${pkgs.grim}/bin/grim -o "$cur_output" - | ${pkgs.wl-clipboard}/bin/wl-copy || - ${pkgs.grim}/bin/grim - | ${pkgs.wl-clipboard}/bin/wl-copy - ;; - esac + test -n "$cur_output" && + ${pkgs.grim}/bin/grim -o "$cur_output" - | ${pkgs.wl-clipboard}/bin/wl-copy || + ${pkgs.grim}/bin/grim - | ${pkgs.wl-clipboard}/bin/wl-copy + ;; + esac '' diff --git a/user/gpg.nix b/user/gpg.nix index 534aaef..54e1077 100644 --- a/user/gpg.nix +++ b/user/gpg.nix @@ -18,9 +18,7 @@ PartOf = [ "graphical-session.target" ]; After = [ "graphical-session.target" ]; }; - Service = { - ExecStart = "${pkgs._gpg-unlock}/bin/_gpg-unlock"; - }; + Service = { ExecStart = "${pkgs._gpg-unlock}/bin/_gpg-unlock"; }; }; }; systemd.user.timers = { diff --git a/user/home.nix b/user/home.nix index a8cc3d1..e150905 100644 --- a/user/home.nix +++ b/user/home.nix @@ -97,6 +97,7 @@ in { interactiveShellInit = '' set -g __accent_color "${accent.color}" alias _fish_prompt_accent "_fish_prompt_color '$__accent_color'" + fzf_key_bindings ''; shellAbbrs = { v = "kak"; @@ -122,11 +123,9 @@ in { }; functions = { fish_greeting = ""; }; }; - programs.zoxide = { - enable = true; - enableFishIntegration = true; - }; + programs.zoxide.enable = true; programs.direnv.enable = true; + programs.fzf.enable = true; home.file = { ".config/fish/conf.d/prompt.fish".source = ./fish_prompt.fish; ".local/share/backgrounds".source = ./backgrounds; @@ -265,6 +264,22 @@ in { home.sessionVariables = { VOLUME_CHANGE_SOUND = "${pkgs.sound-theme-freedesktop}/share/sounds/freedesktop/stereo/audio-volume-change.oga"; + FZF_DEFAULT_OPTS = let + colors = { + "bg+" = color.bg_light; + "hl+" = color.normal.green; + gutter = color.bg; + prompt = accent.color; + pointer = accent.color; + spinner = accent.color; + }; + makeKeyValue = (k: v: "${k}:${v}"); + makeOptList = lib.mapAttrsToList makeKeyValue colors; + makeColorValue = lib.strings.concatStringsSep "," makeOptList; + color_opts = "--color=${makeColorValue}"; + preview_opts = + "--preview '${pkgs.bat}/bin/bat --style=numbers --color=always {}'"; + in "${preview_opts} ${color_opts}"; }; programs.firefox = { enable = true;