-
Hi and thanks for an amazing file manager. The preview implementation is superb compared to any other file managers I have used. I'm currently trying to migrate my workflow from LF to Yazi. In LF, I have a shell script that saves a file/directory path to a specific file, which I then use with fzf to access those paths easily, sort of a bookmark or tag implementation. I know there is a bookmarks plugin, but to my knowledge they are not persistent yet across sessions. So my questions is whether there is a good way to assign a multiple line shell snippet/command to a keymap (other than creating a separate executable shell script file). This is the snippet I would like to assign to a keymap: path="$1"
file_tags="$HOME/Sync/file_tags.txt"
# check if file_tags exists
if [ ! -f $file_tags ]; then
touch $file_tags
fi
# replace $HOME with ~ from the start of path
path="${path/#$HOME/~}"
if rg -q "^$path\$" $file_tags; then
echo "Path already present."
else
# append the path to the file name and save it in the "file_tags" file
echo "$path" >> $file_tags
fi Thanks in advance for your help! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
Hi! Sorry for not addressing your question directly, but have you considered the built-in zoxide integration in Yazi? Zoxide learns your frequently used directories, letting you jump to them easily – it might offer a similar workflow to your fzf-based file tagging approach. |
Beta Was this translation helpful? Give feedback.
-
I think you can do it like this: [[manager.prepend_keymap]]
on = [ "i" ]
run = '''
shell --block --confirm '
path="$1"
file_tags="$HOME/Sync/file_tags.txt"
# check if file_tags exists
if [ ! -f $file_tags ]; then
touch $file_tags
fi
# replace $HOME with ~ from the start of path
path="${path/#$HOME/~}"
if rg -q "^$path\$" $file_tags; then
echo "Path already present."
else
# append the path to the file name and save it in the "file_tags" file
echo "$path" >> $file_tags
fi
'
''' But this isn't very ergonomic, I would recommend implementing it through a plugin, if you need to hide Yazi and activate fzf, you can achieve this using the BTW, I just merged a new data distribution system that will allow cross-process communication and state synchronization through plugins, I think this will be useful for plugins like bookmarks. |
Beta Was this translation helpful? Give feedback.
I think you can do it like this:
But this isn't very ergonomic, I would recommend implementing it through a plugin, if you need to hide Yazi and activate fzf, you can achi…