14

When I fist start Nautilus I invariably open five favourite tabs..

I've tried multiple URIs from the command line, but it opened multiple windows.

Is it possible to somehow do this via command-line ?...

Peter.O
  • 24,311
  • 37
  • 113
  • 162
  • This doesn't appear possible, best thing to do here is probably file a wishlist bug upstream in Nautilus and see if someone will implement it. – Jorge Castro Feb 13 '11 at 19:49
  • @Jorge: Thanks... In that case, I've hacked a macro workaround, and posted the script as an answer – Peter.O Feb 14 '11 at 06:29
  • check [this](http://sourceforge.net/p/scriptechocolor/git/ci/master/tree/ScriptEchoColor/bin.extras/secNautilusRestartAndRestoreTabs.sh) with `--continue` option – Aquarius Power Dec 30 '14 at 16:34
  • 1
    Does this answer your question? [Open Nautilus as a new tab in an existing window](https://askubuntu.com/questions/55656/open-nautilus-as-a-new-tab-in-an-existing-window) – vanadium May 09 '21 at 09:55

2 Answers2

4

It is still unsupported by Nautilus itself, however you can use a script that admits several parameters to reuse or open a new instance of Nautilus if not running.

In order to use this solution you'll need to install pachages wmctrl and xclip. You can do it installing wmctrl and xclip using the Software Center (click on the links) or via Terminal with sudo apt-get install wmctrl xclip.

Create a new file nautab.sh and add the following code:

#!/bin/bash
# Nautilus opens folders in new tabs
# Dependencies: sudo apt-get install wmctrl xclip
# Pass directories as parameters, i.e. nautab /opt /var/log /usr/local/etc
# Wrong parameters will be shown as invalid directories
    
if [ "$(wmctrl -xl | grep "nautilus\.Nautilus")" == "" ]; then
    # wmctrl reports Nautilus not running
    if [[ -d $1 ]]; then
        nautilus "$1" &
    else
        >&2 echo Not a directory: $1
        nautilus &
    fi
    shift
    # Nautilus takes some time to become responsive to automation
    sleep 2
fi 
#Save old clipboard value
oldclip="$(xclip -o -sel clip)"
for folder in "$@"
    {
    if [ -d "$folder" ]; then   
        echo -n $folder | xclip -i -sel clip
        wmctrl -xF -R nautilus.Nautilus && xdotool key --delay 120 ctrl+t ctrl+l ctrl+v Return
        # Use this if you suspect funny clipboard behaviour
        #xclip -verbose -o -sel clip
        #Leave some time before opening a new tab
        sleep 0.5
    else
        >&2 echo Not a directory: $folder 
    fi
}
#Restore old clipboard value
echo -n "$oldclip" | xclip -i -sel clip

This code is based is based on an answer to other question.

Runnautab [directory]... and new tabs will open on it. Note that there will be some delay; this is in order to wait for Nautilus to be responsive. Feel free to play with numbers.

Roshin Raphel
  • 123
  • 14
Dr. Windows
  • 151
  • 1
  • 3
3

As per jorge's comment, the answer is "no"...


So as a side issue, because it's not a current option in Nautilus, I've cobbled together a script.. It suits me, given the situation.
I initially had some timing inssues which caused modifier-key states to go whacko, so I've added 100ms delays between steps, and it is now behaving itself on my system...
This may need to be changed in a different environment... Here it is; at paste.ubuntu.com

Peter.O
  • 24,311
  • 37
  • 113
  • 162