Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Share marked_files array between fff sessions. #191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

gbajson
Copy link

@gbajson gbajson commented Apr 10, 2022

This feature enables the user to share marked_files array
between all fff sessions.
It allows marking some files in one session, and execute
action in another. It's handy when working in, e.g. tmux.

This feature enables user to share marked_files array
between all yyy sessions.
It allows to mark some files in one session, and execute
action in another. It's handy when working in e.g. tmux.
Copy link

@Roy-Orbison Roy-Orbison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like your idea, but I think it could do with a bit of polishing.

fff
@@ -185,6 +217,13 @@ status_line() {
"$LINES"
}

load_marked_files() {
date >> /tmp/load
IFS=$'\r\n' GLOBIGNORE='*' command eval 'marked_files=($(< $marked_files_cache ))' \

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dangerous and unnecessary eval.

Suggested change
IFS=$'\r\n' GLOBIGNORE='*' command eval 'marked_files=($(< $marked_files_cache ))' \
mapfile -t marked_files < "$marked_files_cache" \

fff
@@ -185,6 +217,13 @@ status_line() {
"$LINES"
}

load_marked_files() {
date >> /tmp/load

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging to generic names. Not opt-in.

fff
@@ -1116,10 +1159,18 @@ main() {
mkdir -p "${XDG_CACHE_HOME:=${HOME}/.cache}/fff" \
"${FFF_TRASH:=${XDG_DATA_HOME:=${HOME}/.local/share}/fff/trash}"

USER=$(whoami)
# Create marked files cache.
declare -r marked_files_cache="/tmp/fff_${USER}_marked_files"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not configurable with FFF_* enc vars like other dirs.

fff
@@ -1116,10 +1159,18 @@ main() {
mkdir -p "${XDG_CACHE_HOME:=${HOME}/.cache}/fff" \
"${FFF_TRASH:=${XDG_DATA_HOME:=${HOME}/.local/share}/fff/trash}"

USER=$(whoami)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't $USER defined by default? If not guaranteed, use a variable with fallback like user="${USER:-"$(whoami)"}"

fff
Comment on lines +169 to +172
touch "$marked_files_cache" || die "Could not touch $marked_files_cache ."
test -f "$marked_files_cache" || die "$marked_files_cache is not a file."
chmod 600 "$marked_files_cache" || die "Could not set chmod 0600 on $marked_files_cache ."
chown "$USER" "$marked_files_cache" || die "Could not set owner of $marked_files_cache ."

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does the terminal actually look after such error conditions? fff resets it on exit which can interfere with messages.

fff
status_line() {
# Status_line to print when files are marked for operation.
local mark_ui="[${#marked_files[@]}] selected (${file_program[*]}) [p] ->"
local mark_ui="[${#marked_files[@]}] selected (${file_program[*]} ${marked_files[*]}) [p] ->"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this make the status crazy long?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants