-
Notifications
You must be signed in to change notification settings - Fork 176
Share marked_files array between fff sessions. #191
base: master
Are you sure you want to change the base?
Conversation
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.
There was a problem hiding this 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.
@@ -185,6 +217,13 @@ status_line() { | |||
"$LINES" | |||
} | |||
|
|||
load_marked_files() { | |||
date >> /tmp/load | |||
IFS=$'\r\n' GLOBIGNORE='*' command eval 'marked_files=($(< $marked_files_cache ))' \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dangerous and unnecessary eval
.
IFS=$'\r\n' GLOBIGNORE='*' command eval 'marked_files=($(< $marked_files_cache ))' \ | |
mapfile -t marked_files < "$marked_files_cache" \ |
@@ -185,6 +217,13 @@ status_line() { | |||
"$LINES" | |||
} | |||
|
|||
load_marked_files() { | |||
date >> /tmp/load |
There was a problem hiding this comment.
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.
@@ -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" |
There was a problem hiding this comment.
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.
@@ -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) |
There was a problem hiding this comment.
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)"}"
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 ." |
There was a problem hiding this comment.
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.
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] ->" |
There was a problem hiding this comment.
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?
This feature enables the user to share
marked_files
arraybetween 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.