From d47afbf174e408655301010c3ac987fe8714698f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Av=C3=A9?= Date: Sat, 14 Sep 2024 17:37:13 +0200 Subject: [PATCH] Update FZGO scripts --- flake.lock | 26 +++++++++++++------------- home/zsh/files/functions.zsh | 23 +++++++++++++---------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/flake.lock b/flake.lock index 39cb1ce..d707564 100644 --- a/flake.lock +++ b/flake.lock @@ -99,11 +99,11 @@ ] }, "locked": { - "lastModified": 1726214280, - "narHash": "sha256-LqeIwfMuvAXV3DPZpd6BgOk/YfcJJyu5eredE/tEsJE=", + "lastModified": 1726308872, + "narHash": "sha256-d4vwO5N4RsLnCY7k5tY9xbdYDWQsY3RDMeUoIa4ms2A=", "owner": "nix-community", "repo": "home-manager", - "rev": "433e686675ba24176fe3383916a4bd1c9799c676", + "rev": "6c1a461a444e6ccb3f3e42bb627b510c3a722a57", "type": "github" }, "original": { @@ -153,11 +153,11 @@ "xdph": "xdph" }, "locked": { - "lastModified": 1726159284, - "narHash": "sha256-6xatk6CPY1F6xHF1gLGz7QExftEhV8Q5fI4BqVBVF3U=", + "lastModified": 1726246604, + "narHash": "sha256-cScS34F71HzhIUeMScfKrT7iSZA0tr8pGIjOqHF+ue8=", "ref": "refs/heads/main", - "rev": "118be4dea048df88fd21b84580fe62950c868c8f", - "revCount": 5215, + "rev": "d35e70a8c6599bb058cf86eb87c783ce1cf72471", + "revCount": 5218, "submodules": true, "type": "git", "url": "https://github.com/hyprwm/Hyprland" @@ -339,11 +339,11 @@ }, "nixpkgs_4": { "locked": { - "lastModified": 1725983898, - "narHash": "sha256-4b3A9zPpxAxLnkF9MawJNHDtOOl6ruL0r6Og1TEDGCE=", + "lastModified": 1726062873, + "narHash": "sha256-IiA3jfbR7K/B5+9byVi9BZGWTD4VSbWe8VLpp9B/iYk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1355a0cbfeac61d785b7183c0caaec1f97361b43", + "rev": "4f807e8940284ad7925ebd0a0993d2a1791acb2f", "type": "github" }, "original": { @@ -355,11 +355,11 @@ }, "nur": { "locked": { - "lastModified": 1726217085, - "narHash": "sha256-EsQyLlP5EYmNtqNKSqbaM5wsEbdwK0K1IIf1IzaEcgc=", + "lastModified": 1726321580, + "narHash": "sha256-nJDp7hN8VAkO62b72d4PGEe9tIl9bn1dn8yIkr9FeCU=", "owner": "nix-community", "repo": "NUR", - "rev": "1f7e95b366b101ffd752e196d18a313d05878dac", + "rev": "49761a5e726649905d015b3b41295ea7fe3d0d71", "type": "github" }, "original": { diff --git a/home/zsh/files/functions.zsh b/home/zsh/files/functions.zsh index 78ac611..f055cc2 100644 --- a/home/zsh/files/functions.zsh +++ b/home/zsh/files/functions.zsh @@ -19,28 +19,31 @@ function find_local() { function find_global() { file_type=$1 - FZY_CACHE=~/.cache/fzy_paths_$file_type - if [ -f $FZY_CACHE ]; then - if [ $(stat -c %Y $FZY_CACHE) -lt $(date +%s -d '-1 day') ]; then - rm $FZY_CACHE + mkdir -p ~/.cache/fzgo_paths + FZGO_CACHE=~/.cache/fzgo_paths/$file_type + FZGO_RECENTS=~/.cache/fzgo_paths/recents_$file_type + if [ -f $FZGO_CACHE ]; then + if [ $(stat -c %Y $FZGO_CACHE) -lt $(date +%s -d '-1 day') ]; then + rm $FZGO_CACHE fi fi - if [ ! -f $FZY_CACHE ]; then + if [ ! -f $FZGO_CACHE ]; then PATHS="" for i in "$LOCAL_SEARCH_DIRS[@]"; do - if [ -d $i ]; then + if [ -d "$i" ]; then PATHS="$PATHS\n$i\n$(fd . $i -t $file_type)" fi done for i in "$REMOTE_SEARCH_DIRS[@]"; do - if [ -d $i ]; then + if [ -d "$i" ]; then PATHS="$PATHS\n$i\n$(ssh mallorea fd . \"$i\" -t $file_type -d 8)" fi done - echo "$PATHS" > $FZY_CACHE + echo "$PATHS" > $FZGO_CACHE fi - file="$(fzgo < $FZY_CACHE)" - echo "$file" | cat - $FZY_CACHE | awk '!x[$0]++' > /tmp/fzy_paths_$file_type && mv /tmp/fzy_paths_$file_type $FZY_CACHE + touch $FZGO_RECENTS + file="$(cat $FZGO_RECENTS $FZGO_CACHE | awk '!x[$0]++' | fzgo)" + echo "$file" | cat - $FZGO_RECENTS | awk '!x[$0]++' > /tmp/fzgo_paths_recents_$file_type && mv /tmp/fzgo_paths_recents_$file_type $FZGO_RECENTS echo "$file" }