Closed zuiop3 closed 11 years ago
That's an interesting idea. While it's unlikely this would be made a built-in command, it's a good prospect for a custom command/plugin.
Also note that you can right-click on files and select Edit|Copy Path, which is designed for use with terminals - the paths can be pasted directly into a terminal.
You can also easily add custom menu items to almost any SpaceFM menu. eg to dump the currently selected files into a text file, use command line:
echo %F > /tmp/selected-files
That would put all the files on one line. Or to put them on separate lines (which would handle quote characters better), see some of the example scripts at the end of the default command script.
Note that the instructions and methods for creating custom menu items will be changing with version 0.9.0 (currently in next branch), so be sure to consult the user's manual for the version you're using (press F1).
Also note that SpaceFM allows you to easily read the files on the clipboard, and place files on the clipboard, using socket commands, so that might provide other integration options.
Some examples from the manual:
# Copy text to the clipboard:
spacefm -s set clipboard_text 'Some text'
# Copy multiple lines of text to the clipboard:
spacefm -s set clipboard_text 'Some\nlines\nof text'
# Copy the contents of a text file to the clipboard:
spacefm -s set clipboard_from_file /etc/fstab
# Copy text to the primary (middle-click) clipboard:
spacefm -s set clipboard_primary_text 'Some primary text'
# Copy files to the clipboard:
spacefm -s set clipboard_copy_files /etc/fstab /etc/hosts
# Cut files to the clipboard:
spacefm -s set clipboard_cut_files /etc/fstab /etc/hosts
# Get the text on the clipboard:
spacefm -s get clipboard_text
# Get the text on the clipboard and write it to a file:
spacefm -s get clipboard_text > /tmp/clipboard-contents.txt
# Get the files on the clipboard:
spacefm -s get clipboard_copy_files
#!/bin/bash
# Read the copied files into an array:
eval copied_files="$(spacefm -s get clipboard_copy_files)"
echo "These files have been copied to the clipboard:"
i=0
while [ "${copied_files[i]}" != "" ]; do
echo " ${copied_files[i]}"
(( i++ ))
done
if (( i != 0 )); then
echo "MD5SUMS:"
md5sum "${copied_files[@]}"
fi
Wow, thank you for the in-depth introduction to spacefm's command system. I saw it had one, but didn't expect it to be so powerful.
In case somebody finds this thread, below is the (trivial) function to implement what I meant. Admittedly, it's a one-way selection (i.e. you have to edit the file with a text editor to unselect a file), but it is quite close to what I wanted.
Thanks for your (quick!) help with this, IgnorantGuru.
#!/bin/bash
$fm_import # import file manager variables (scroll down for info)
# Build list of filenames, escape them, write them to ~/file_list
i=0
for f in "${fm_files[@]}"; do
echo "\"$f\"" >> ~/file_list
(( i++ ))
done
exit 0
One thought on this - if there are no files selected [ "$fm_file" == "" ], you could make it truncate or remove the file list, as a quick way to reset it. eg
if [ "$fm_file" == "" ]; then
rm -f ~/file_list
touch ~/file_list
else
# Build list
...
fi
Let me begin by thanking you (and the community) for the lightweight and simple file manager!
I commonly use the command line, but one thing GUIs are better at is navigating folder trees and picking various files manually. With this in mind, I would find the following feature incredibly handy:
Have a "pseudo-folder" into which files can be "copied". In reality, spacefm simply creates a text file with the filename (incl. path) of all files which have been copied into this special folder. Once done, the user can use the saved text file from the command line. This would allow spacefm to be used as a GUI file selection tool (and an advanced one at that!) in an otherwise command line based workflow.