fzf: Put the chosen editor command in shell history.
dblume

dblume commited on 2025-12-12 19:43:20
Showing 1 changed files, with 6 additions and 1 deletions.


It's more useful to have the chosen "vim [file]" in your history than just a "gf"
... ...
@@ -172,7 +172,12 @@ case "$-" in
172 172
       else
173 173
         file="$(git ls-files | fzf --preview 'cat {}' --preview-window=right:60%)"
174 174
       fi
175
-      [ -n "$file" ] && ${EDITOR:-vim} "$file"
175
+      if [ -n "$file" ]; then
176
+        echo ${EDITOR:-vim} "$file"
177
+        # It's more useful to have "vim [file]" in your history than just a "gf".
178
+        history -s "${EDITOR:-vim} \"$file\""
179
+        ${EDITOR:-vim} "$file"
180
+      fi
176 181
     }
177 182
 
178 183
   fi
179 184