Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions fff
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,17 @@ get_ls_colors() {
source /dev/stdin <<< "$ls_exts" >/dev/null 2>&1
}

cd_file() {
# Handle CD on exit based on the user's preference.
if [[ $FFF_CD_FILE == stdout ]]; then
printf '%s\n' "$PWD"

else
: "${FFF_CD_FILE:=${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d}"
printf '%s\n' "$PWD" > "$FFF_CD_FILE"
fi
}

status_line() {
# Status_line to print when files are marked for operation.
local mark_ui="[${#marked_files[@]}] selected (${file_program[*]}) [p] ->"
Expand Down Expand Up @@ -669,8 +680,6 @@ key() {
# Don't allow user to redefine 'q' so a bad keybinding doesn't
# remove the option to quit.
q)
: "${FFF_CD_FILE:=${XDG_CACHE_HOME:=${HOME}/.cache}/fff/.fff_d}"
printf '%s\n' "$PWD" > "$FFF_CD_FILE"
exit
;;
esac
Expand Down Expand Up @@ -722,7 +731,7 @@ main() {

# Trap the exit signal (we need to reset the terminal to a useable state.)
# '\e[?1049l': Restore saved terminal screen.
trap 'reset_terminal; printf "\e[?1049l"' EXIT
trap 'reset_terminal; printf "\e[?1049l"; cd_file' EXIT

# Trap 'Ctrl+c' and exit by mimicking the 'q' keypress.
# This allow us to run the same plumbing on exit for both.
Expand Down