Topic: [SOLVED] pcmanfm/CLI integration, "browse here"

The "browse here" function from the "places" menu presumably sends a signal to pcmanfm running in daemon mode, to open a window at the requested location.  Is there a command-line equivalent?  Just a simple "pcmanfm --starting-directory" would work, but there is no such thing, it appears.

I often find I navigate around in the shell, and then want to do something better suited to a GUI, eg select multiple arbitrary files, etc, and want to start a filemanager from `pwd`.

Conversely, in gnome, you can drag and drop files from nautilus to a shell, and the names appear on the command-line, quoted to protect spaces in filenames etc.  Is there a way to do this in crunchbang?  you can "copy" multiple files, and the buffer will have the filenames one-per-line, but no quotes, etc, so you often need to edit when you paste into a terminal.


EDIT:  Doh.  I'm absolutely sure I tried this yesterday and it didn't work.  Now I've just looked through openbox menu, and obpipemenu, and found that it just runs "pcmanfm <directory>", eg "pcmanfm `pwd`", which I've set as a shell alias.  Perhaps I tried "pcmanfm ." yesterday - the "dot" gets translated to "home" for some reason, probably because that's where the daemon thinks it is.  Anyway that answers the first question.

Last edited by jackbang (2009-06-22 05:15:27)

Re: [SOLVED] pcmanfm/CLI integration, "browse here"

Maybe you could mark your thread as solved.

FHSM: avoid vowels and exotic consonants and you'll get your handle every time.  identi.ca

Re: [SOLVED] pcmanfm/CLI integration, "browse here"

Is there a "50% solved" tag?  I'm still interested in how to "export" actions from pcmanfm back to a shell.

Incidentally,

pcmanfm .

Always starts in your home directory.

sudo pcmanfm .

starts in your current directory.  A minor point, and there is an explanation, but it's not great consistency.

Re: [SOLVED] pcmanfm/CLI integration, "browse here"

jackbang wrote:

I'm still interested in how to "export" actions from pcmanfm back to a shell.

I don't know this for sure but my hunch is that this isn't possible in #!.  The bag-of-parts model doesn't typically make that sort of integration easy.  You could test it using terminator on Ubuntu and gnome terminal on #! and see if it's the terminal emulator or the file manager that is providing the functionality you are used to.  I suspect it is the combination of the two rather than a feature of one component.

FHSM: avoid vowels and exotic consonants and you'll get your handle every time.  identi.ca

Re: [SOLVED] pcmanfm/CLI integration, "browse here"

I think you're right.  Drag and drop is quite complicated in that you need to know the source and destination in order to massage the data appropriately.
Anyway, some "solutions"

In order to run a filemanager from the shell, in my current working directory, I have set an alias in .bashrc:

alias fm='pcmanfm `pwd`'

And also a "run as root" version:

alias sfm='sudo pcmanfm `pwd`'

Note "fm" actually conflicts with a command from fmtools, but it's not installed by default on #! and I don't now what id does anyway.


Then, I want to be able to select a bunch of files in pcmanfm, and paste them into a command line in a shell.  By default, when you "copy" a selection of files from pcmanfm, it dumps a list of filenames into the clipboard, one per line.  We just need to convert so that each filename is quoted, and all of them are on a single line.

Install xsel:

sudo apt-get install xsel

The xsel command returns the clipboard.  For pcmanfm, a bunch of selected files are put in the clipboard as lines, and we want to concatenate those lines into a single line, with quotes around each item, so we can use the selection in the command line.  Both the bash built-in "quote" command, and the unix "paste" command have potential, but unfortunately aren't up to the job.  Ideally the "paste" command should have a "-quote" argument, and the "quote" operator should be able to handle multiple fields.  Ah well, in true unix style, joining the two gives what we want:

xsel --clipboard | while read x ; do quote $x; done | paste -s

Alternatively, you could have the command put it's output into the middle-click paste buffer:

xsel --clipboard | while read x ; do quote $x; done | paste -s | xsel -p -i

PS, for some reason the "quote" coommand doesn't work from inside a shell script file, you can use the less elegant echo \'$x\' instead:

xsel --clipboard | while read x ; do echo \'$x\'; done | paste -s | xsel -p -i

It would be great to be able to put something in the openbox rc.xml, for example so Windows-V ran the translation, and psted the text directly.  Not sure how to do that.

Last edited by jackbang (2009-06-22 06:28:29)