From 61ea7daf726a22ebbec70f8c68143091a8b9c859 Mon Sep 17 00:00:00 2001
From: Luca Bilke <bilke@tralios.de>
Date: Tue, 12 Mar 2024 08:49:40 +0100
Subject: [PATCH] zsh keybind changes

---
 .config/zsh/plugins/fzf/bindings.zsh | 60 +++++++++++-----------------
 1 file changed, 24 insertions(+), 36 deletions(-)

diff --git a/.config/zsh/plugins/fzf/bindings.zsh b/.config/zsh/plugins/fzf/bindings.zsh
index cc7c52a7..2cf10b9e 100644
--- a/.config/zsh/plugins/fzf/bindings.zsh
+++ b/.config/zsh/plugins/fzf/bindings.zsh
@@ -1,15 +1,6 @@
-#     ____      ____
-#    / __/___  / __/
-#   / /_/_  / / /_
-#  / __/ / /_/ __/
-# /_/   /___/_/ key-bindings.zsh
-#
-# - $FZF_TMUX_OPTS
-# - $FZF_CTRL_T_COMMAND
-# - $FZF_CTRL_T_OPTS
-# - $FZF_CTRL_R_OPTS
-# - $FZF_ALT_C_COMMAND
-# - $FZF_ALT_C_OPTS
+#!/bin/zsh
+
+# TODO: move this into other zsh config
 
 # Key bindings
 # ------------
@@ -71,30 +62,27 @@ bindkey -M vicmd '^T' fzf-file-widget
 bindkey -M viins '^T' fzf-file-widget
 
 # ALT-C - cd into the selected directory
-# WARN: Disabled because the vim-browse patch for st uses this key combo already
-# LF is better for this anyways
-
-# fzf-cd-widget() {
-#   local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
-#     -o -type d -print 2> /dev/null | cut -b3-"}"
-#   setopt localoptions pipefail no_aliases 2> /dev/null
-#   local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
-#   if [[ -z "$dir" ]]; then
-#     zle redisplay
-#     return 0
-#   fi
-#   zle push-line # Clear buffer. Auto-restored on next prompt.
-#   BUFFER="builtin cd -- ${(q)dir}"
-#   zle accept-line
-#   local ret=$?
-#   unset dir # ensure this doesn't end up appearing in prompt expansion
-#   zle reset-prompt
-#   return $ret
-# }
-# zle     -N             fzf-cd-widget
-# bindkey -M emacs '\ec' fzf-cd-widget
-# bindkey -M vicmd '\ec' fzf-cd-widget
-# bindkey -M viins '\ec' fzf-cd-widget
+fzf-cd-widget() {
+  local cmd="${FZF_ALT_C_COMMAND:-"command find -L . -mindepth 1 \\( -path '*/\\.*' -o -fstype 'sysfs' -o -fstype 'devfs' -o -fstype 'devtmpfs' -o -fstype 'proc' \\) -prune \
+    -o -type d -print 2> /dev/null | cut -b3-"}"
+  setopt localoptions pipefail no_aliases 2> /dev/null
+  local dir="$(eval "$cmd" | FZF_DEFAULT_OPTS="--height ${FZF_TMUX_HEIGHT:-40%} --reverse --bind=ctrl-z:ignore $FZF_DEFAULT_OPTS $FZF_ALT_C_OPTS" $(__fzfcmd) +m)"
+  if [[ -z "$dir" ]]; then
+    zle redisplay
+    return 0
+  fi
+  zle push-line # Clear buffer. Auto-restored on next prompt.
+  BUFFER="builtin cd -- ${(q)dir}"
+  zle accept-line
+  local ret=$?
+  unset dir # ensure this doesn't end up appearing in prompt expansion
+  zle reset-prompt
+  return $ret
+}
+zle     -N             fzf-cd-widget
+bindkey -M emacs '\ec' fzf-cd-widget
+bindkey -M vicmd '\ec' fzf-cd-widget
+bindkey -M viins '\ec' fzf-cd-widget
 
 # CTRL-R - Paste the selected command from history into the command line
 fzf-history-widget() {