<commit_before>ifdef(`HAVE_fzf', `', `return')
export FZF_DEFAULT_COMMAND='fd --type f'
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
export FZF_DEFAULT_OPTS="--height 40% --ansi"
. /usr/share/fzf/shell/key-bindings.bash

# Select mv command from history and suggest to undo it.
undo_mv() {
	local lines old_dest old_src new_src REPLY
	mapfile -t lines < <(python -c 'import shlex,sys,os.path; print(*map(os.path.expanduser, shlex.split(sys.argv[1])), sep="\n")' "$(READLINE_LINE="'mv " __fzf_history__)")
	if [ ${#lines[*]} -lt 3 ] || [ ${lines[0]} != "mv" ]; then
		echo "Not a mv command"
		return
	fi
	old_dest="${lines[$(( ${#lines[*]} - 1 ))]}"
	old_src="${lines[$(( ${#lines[*]} - 2 ))]}"
	if [ -d "$old_dest" ]; then
		new_src="$(realpath -e "$old_dest")/$(basename "$old_src")"
	elif [ -e "$old_dest" ]; then
		new_src="$old_dest"
	fi
	if ! [ -e "$new_src" ]; then
		echo "source doesn't exist: $new_src"
		return
	fi
	cmd=(mv -iv "$new_src" "$old_src")
	read -p "${cmd[*]} [y/N]? : "
	if [ "$REPLY" == "y" ]; then
		${cmd[*]}
	fi<commit_msg>fzf: use fd only if installed<commit_after>ifdef(`HAVE_fzf', `', `return')
ifdef(`HAVE_fd', `
export FZF_DEFAULT_COMMAND="fd --type f"
export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND"
')
export FZF_DEFAULT_OPTS="--height 40% --ansi"
. /usr/share/fzf/shell/key-bindings.bash

# Select mv command from history and suggest to undo it.
undo_mv() {
	local lines old_dest old_src new_src REPLY
	mapfile -t lines < <(python -c 'import shlex,sys,os.path; print(*map(os.path.expanduser, shlex.split(sys.argv[1])), sep="\n")' "$(READLINE_LINE="'mv " __fzf_history__)")
	if [ ${#lines[*]} -lt 3 ] || [ ${lines[0]} != "mv" ]; then
		echo "Not a mv command"
		return
	fi
	old_dest="${lines[$(( ${#lines[*]} - 1 ))]}"
	old_src="${lines[$(( ${#lines[*]} - 2 ))]}"
	if [ -d "$old_dest" ]; then
		new_src="$(realpath -e "$old_dest")/$(basename "$old_src")"
	elif [ -e "$old_dest" ]; then
		new_src="$old_dest"
	fi
	if ! [ -e "$new_src" ]; then
		echo "source doesn't exist: $new_src"
		return
	fi
	cmd=(mv -iv "$new_src" "$old_src")
	read -p "${cmd[*]} [y/N]? : "
	if [ "$REPLY" == "y" ]; then
		${cmd[*]}
	fi
{'fraction_non_alphanumeric': 0.22646784715750232, 'fraction_numerical': 0.0065237651444548, 'mean_word_length': 4.463104325699746, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '866597', 'n_tokens_mistral': 936, 'n_tokens_neox': 894, 'n_words': 207}