From 2a8277a1acb1497ff14f95156cf77ba2ea489495 Mon Sep 17 00:00:00 2001 From: atropos Date: Thu, 11 Apr 2024 08:15:05 +0100 Subject: [PATCH] frg function and clean up --- devenv.nix | 4 ++-- lib/common/desktop/default.nix | 6 ++---- lib/pkgs/zsh/default.nix | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/devenv.nix b/devenv.nix index aa2a95a..7173fe5 100644 --- a/devenv.nix +++ b/devenv.nix @@ -55,7 +55,7 @@ }; apply = { exec = '' - build && sudo nixos-rebuild switch || exit 1 + build && sudo nixos-rebuild switch --fast || exit 1 ''; description = "Rebuild the system"; }; @@ -73,7 +73,7 @@ }; update = { exec = '' - sudo nix-channel --update && nix flake update && git add . && git commit -m "Update flake.lock" && rebuild + sudo nix-channel --update && nix flake update && git add . && git commit -m "Update flake.lock" && apply ''; description = "Update the system"; }; diff --git a/lib/common/desktop/default.nix b/lib/common/desktop/default.nix index 7ddfa43..8f137e4 100644 --- a/lib/common/desktop/default.nix +++ b/lib/common/desktop/default.nix @@ -69,6 +69,7 @@ in { environment.sessionVariables = { # To Globally replace gcc stuff use this env var but it will do damage to othre stuff so ideally use nix-ld approach # LD_LIBRARY_PATH = lib.mkForce "${pkgs.stdenv.cc.cc.lib}/lib"; + FZF_BASE = "${pkgs.fzf}/bin/fzf"; # For direnv to not show the log DIRENV_LOG_FORMAT = ""; @@ -352,9 +353,6 @@ in { # connect to k8s external secret source doppler - # password manager - bitwarden - # dns resolving tool (for testing) dig @@ -377,7 +375,7 @@ in { # database client dbeaver - # debbuger for golang + # debuger for golang delve # Cllium eBPF client tool for kubernetes cluster diff --git a/lib/pkgs/zsh/default.nix b/lib/pkgs/zsh/default.nix index 8d12f3b..c5b696b 100644 --- a/lib/pkgs/zsh/default.nix +++ b/lib/pkgs/zsh/default.nix @@ -32,7 +32,6 @@ in { plugins = [ "git" "extract" - "fzf" # WARN: This is temporary solution until atuin works again. "kubectl" "docker-compose" ]; @@ -144,7 +143,23 @@ in { git rebase -i HEAD~$1 } + # Found this cool function here: https://news.ycombinator.com/item?id=38471822 + function frg { + result=$(rg --ignore-case --color=always --line-number --no-heading "$@" | + fzf --ansi \ + --color 'hl:-1:underline,hl+:-1:underline:reverse' \ + --delimiter ':' \ + --preview "bat --color=always {1} --theme='Solarized (light)' --highlight-line {2}" \ + --preview-window 'up,60%,border-bottom,+{2}+3/3,~3') + file=''${result%%:*} + linenumber=$(echo "''${result}" | cut -d: -f2) + if [[ -n "$file" ]]; then + $EDITOR +"''${linenumber}" "$file" + fi + } + eval "$(zoxide init zsh)" + eval "$(fzf --zsh)" ''; }; };