This repository was archived by the owner on Apr 26, 2024. It is now read-only.
Share marked_files array between fff sessions.#191
Open
gbajson wants to merge 1 commit intodylanaraps:masterfrom
Open
Share marked_files array between fff sessions.#191gbajson wants to merge 1 commit intodylanaraps:masterfrom
gbajson wants to merge 1 commit intodylanaraps:masterfrom
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.
Roy-Orbison
reviewed
Mar 6, 2024
Roy-Orbison
left a comment
There was a problem hiding this comment.
I like your idea, but I think it could do with a bit of polishing.
|
|
||
| load_marked_files() { | ||
| date >> /tmp/load | ||
| IFS=$'\r\n' GLOBIGNORE='*' command eval 'marked_files=($(< $marked_files_cache ))' \ |
There was a problem hiding this comment.
Dangerous and unnecessary eval.
Suggested change
| IFS=$'\r\n' GLOBIGNORE='*' command eval 'marked_files=($(< $marked_files_cache ))' \ | |
| mapfile -t marked_files < "$marked_files_cache" \ |
| } | ||
|
|
||
| load_marked_files() { | ||
| date >> /tmp/load |
There was a problem hiding this comment.
Logging to generic names. Not opt-in.
|
|
||
| USER=$(whoami) | ||
| # Create marked files cache. | ||
| declare -r marked_files_cache="/tmp/fff_${USER}_marked_files" |
There was a problem hiding this comment.
Not configurable with FFF_* enc vars like other dirs.
| 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.
Isn't $USER defined by default? If not guaranteed, use a variable with fallback like user="${USER:-"$(whoami)"}"
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 ." |
There was a problem hiding this comment.
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.
Will this make the status crazy long?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This feature enables the user to share
marked_filesarraybetween all
fffsessions.It allows marking some files in one session, and execute
action in another. It's handy when working in, e.g. tmux.