I want to be able to select a file, enter a command and have it return the current location of the file selected in a terminal.
Asked
Active
Viewed 328 times
2 Answers
0
If you want to get a file name into a terminal program, you should be able to use either mouse drag'n'drop or Ctrl-c and Ctrl-(Shift-)v to copy/paste it into an editor/terminal.
l0b0
- 9,271
0
I think the best thing to fit here is a nautilus plugin.
Install python-nautilus
sudo apt-get install python-nautilusCreate a plugin "TestExtension.py"
sudo nano /usr/share/nautilus-python/extensions/TestExtension.pyThis extension will call your script whenever the selection changes and pass the selection one by one as second command argument
$1:from gi.repository import Nautilus, GObject import os class ColumnExtension(GObject.GObject, Nautilus.MenuProvider): def __init__(self): pass def menu_activate_cb(self, menu, file): print "menu_activate_cb",file def get_file_items(self, window, files): for file in files: uri = file.get_uri() if uri.startswith("file:///"): os.system("yourscript_path"+" \""+uri[7:]+"\"") returnOr you may make a list, combine them as single string, then
exportit asenvvariable. So current selection will be accessible for all other scripts. (security hole)Kill nautilus
pkill nautilus
Reference:
user.dz
- 49,176