Skip to content

lf directory history via fzf #1429

Closed Answered by DusanLesan
techeddie asked this question in Q&A
Discussion options

You must be logged in to vote

Something like this maybe:

cmd fzf_jump_history ${{
	res="$(cat /tmp/lf_dir_history | fzf --reverse --header='Jump to location' | sed 's/\\/\\\\/g;s/"/\\"/g')"
	if [ -d "$res" ] ; then
		cmd="cd"
	elif [ -f "$res" ] ; then
		cmd="select"
	else
		exit 0
	fi

	lf -remote "send $id $cmd \"$res\""
}}

cmd on-cd &{{
	list="$(tail -n 20 /tmp/lf_dir_history | sed "\|^$PWD$|d")"
	echo "$list"$'\n'"$PWD" > /tmp/lf_dir_history
}}

map b :fzf_jump_history

On every change it adds one last entry to a file in tmp, removes duplicates and removes older lines. On history command it displays content of tmp file

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
5 replies
@techeddie
Comment options

@CAESIUS-TIM
Comment options

@CAESIUS-TIM
Comment options

@CAESIUS-TIM
Comment options

@DusanLesan
Comment options

Answer selected by techeddie
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants