about summary refs log tree commit diff stats
path: root/nix-conf
diff options
context:
space:
mode:
authorDavid Morgan <djm_uk@protonmail.com>2022-12-15 16:24:17 +0000
committerDavid Morgan <djm_uk@protonmail.com>2022-12-15 16:54:06 +0000
commit87ec731549805e2c8beddb2bf14419b6033e2809 (patch)
treedf0d25364b1d0351b605e5246f504069597ec100 /nix-conf
parent1deba07f824d74f5c302a9ed2687dd2c7fde86b3 (diff)
downloaddotfiles-87ec731549805e2c8beddb2bf14419b6033e2809.tar.gz
fzf functions
Diffstat (limited to 'nix-conf')
-rw-r--r--nix-conf/home/includes/zsh.nix21
1 files changed, 20 insertions, 1 deletions
diff --git a/nix-conf/home/includes/zsh.nix b/nix-conf/home/includes/zsh.nix
index 4da8ac1..30feeaf 100644
--- a/nix-conf/home/includes/zsh.nix
+++ b/nix-conf/home/includes/zsh.nix
@@ -138,7 +138,7 @@
       stty -ixon
 
       function generate () { gopass generate -s -p $1 $((RANDOM % 14 + 45)) }
-      function fcd { cd $(fd -L --max-depth=''${1:-1} --type=d 2>/dev/null | fzf-tmux) }
+      function fcd { cd $(fd -L --max-depth=''${1:-4} --type=d 2>/dev/null | fzf-tmux) }
 
       fif() {
         if [ ! "$#" -gt 0  ]; then
@@ -148,6 +148,25 @@
         rg --files-with-matches --no-messages "$1" | fzf $FZF_PREVIEW_WINDOW --preview "rg --ignore-case --pretty --context 10 '$1' {}"
       }
 
+      fe() {
+        IFS=$'\n' files=($(fzf-tmux --query="$1" --multi --select-1 --exit-0))
+        [[ -n "$files" ]] && ''${EDITOR:-vim} "''${files[@]}"
+      }
+
+      ..() {
+        local declare dirs=()
+        get_parent_dirs() {
+          if [[ -d "''${1}" ]]; then dirs+=("$1"); else return; fi
+          if [[ "''${1}" == '/' ]]; then
+            for _dir in "''${dirs[@]}"; do echo $_dir; done
+          else
+            get_parent_dirs $(dirname "$1")
+          fi
+        }
+        local DIR=$(get_parent_dirs $(realpath "$PWD/..") | fzf-tmux)
+        cd "$DIR"
+      }
+
       tre () { command tre "$@" -e && source "/tmp/tre_aliases_$USER" 2>/dev/null; }
 
       function gcd () {