diff dot_config/private_fish/functions/fzf_cdhist.fish @ 1045:7db5c9c8016f

feat: Add fzf cd history picker
author Zeger Van de Vannet <zeger@vandevan.net>
date Sat, 04 May 2024 11:47:05 +0200
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dot_config/private_fish/functions/fzf_cdhist.fish	Sat May 04 11:47:05 2024 +0200
@@ -0,0 +1,14 @@
+function fzf_cdhist-d 'cd to one of the previously visited locations'
+	# Clear non-existent folders from cdhist.
+	set -l buf
+	for i in (seq 1 (count $dirprev))
+		set -l dir $dirprev[$i]
+		if test -d $dir
+			set buf $buf $dir
+		end
+	end
+	set dirprev $buf
+	string join \n $dirprev | tac | sed 1d | eval (__fzfcmd) +m --tiebreak=index --toggle-sort=ctrl-r $FZF_CDHIST_OPTS | read -l result
+	[ "$result" ]; and cd $result
+	commandline -f repaint
+end