2

Let's assume a situation where I have a terminal emulator open on my GUI and I have changed my working directory to some specific directory. I know that current directory contains file xyz.

Is it possible to open a new file browser window with my current working directory and have the file xyz focused by default but not launched automatically?

If multiple solutions exist, I'd prefer using xdg-open, caja, nautilus or nemo with some command line flags. Basically I'm looking for command like

xdg-open --in-file-browser xyz

which obviously does not work but is there a way to make it or something similar to work?

Bonus points for having a command that allows me to open a file browser view with multiple files pre-selected so that I could write

xdg-open --in-file-browser *.png

to e.g. easily start drag and drop operation for exactly those files.

  • How do you feel about that answer: unix.stackexchange.com/questions/364997/… – Yaron Aug 15 at 12:42
  • 1
    simply nautilus /path/to/file (where file is the actual file) seems to open the directory & select the file. -s does the same. multiple arguments does not work unfortunately. – Jacob Vlijm Aug 17 at 7:29
  • @JacobVlijm Thanks, it seems that nautilus does support this but nemo nor caja do not. It seems that nautilus file1 file2 will open two windows with one of the files selected in each. Interestingly, nautilus -s file1 -s file2 will open two nemo windows with one file selected in each. I guess it's possible open the window and focus the file via dbus or something and nautilus accidentally focuses the file in nemo. – Mikko Rantalainen Aug 21 at 7:50
0

I use the following functions, defined in my ~/.bashrc:

walt@bat:~(0)$ type url;type furl
url is a function
url () 
{ 
    if [[ "x$2" != "x" ]]; then
        ff_opt="$2";
    else
        ff_opt="-new-tab";
    fi;
    /usr/bin/firefox "$ff_opt" "$1"
}
furl is a function
furl () 
{ 
    if [[ -f "$1" ]]; then
        echo "$1" | egrep -q '^/';
        if [[ $? -ne 0 ]]; then
            furl_file="file://${PWD}/$1";
        else
            furl_file="file://$1";
        fi;
        url "$furl_file" -new-tab;
    else
        echo "furl: ${1}: No such file";
    fi
}
walt@bat:~(0)$ type furlw
furlw is a function
furlw () 
{ 
    if [[ -f "$1" ]]; then
        echo "$1" | egrep -q '^/';
        if [[ $? -ne 0 ]]; then
            furl_file="file://${PWD}/$1";
        else
            furl_file="file://$1";
        fi;
        url "$1" -new-window;
    else
        echo "furlw: ${1}: No such file";
    fi
}
  • That will open an URL or a file in your internet browser (a.k.a. User Agent). However, I'm looking for a way to open file browser (a.k.a. file manager) e.g. caja, nautilus or nemo. – Mikko Rantalainen Aug 16 at 6:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.