Warning: file( failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /mnt/data/home/www/www-bernaerts/plugins/content/displayfile/displayfile.php on line 121

Warning: Invalid argument supplied for foreach() in /mnt/data/home/www/www-bernaerts/plugins/content/displayfile/displayfile.php on line 123

Warning: file( failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /mnt/data/home/www/www-bernaerts/plugins/content/displayfile/displayfile.php on line 121

Warning: Invalid argument supplied for foreach() in /mnt/data/home/www/www-bernaerts/plugins/content/displayfile/displayfile.php on line 123

Gnome Shell - Create New Documents from Nautilus contextual menu


dropcap nautilus

With Gnome 3, Nautilus doesn't provide any more an empty file creation menu.

As amazing as it can be, this very simple and very productive feature has been remove with Gnome 3. You still can create an empty folder, but not an empty file !

As this very simple feature is a must have, this article explains how to get it back, but boosted with steroids.

It explains how to setup Nautilus to handle creation of different empty document types, based on some document models you have written and configured.

You'll then be able to create any type of new documents customised to your specific need (writer document with your letter head, bash script with your default title block, …) straight from :

  • any Nautilus window
  • Nautilus toolbar menu

ubuntu nautilus newfile menu

It has been tested on Ubuntu Gnome 14.04 LTS and 16.04 LTS, but should be installable on any Linux distribution running Gnome.

1. Basic Principle

To get a customized contextual right click document creation menu in Nautilus you'll have to set few things :

  • the type of documents you want to create
  • the empty document model you want for every type
  • if new document should get execute flag

To enable a contextual right click menu you'll need to :

  1. Create empty document model
  2. Create Nautilus action menu entry for the document type
  3. Provide the document creation script

To have a generic approach that provides real flexibility, all document models and associated actions will be configured in a simple text file.

If you want to create your empty documents right away, you can directly jump to Installation & configuration

1.1. Empty document models

All empty document models should be stored in ~/.config/nautilus-actions/nautilus-newfile sub-directory.

Nautilus action menu will trigger a script which will copy empty documents from here.

ubuntu nautilus newfile models

1.2. Create document Nautilus actions

For every empty document, one action .desktop file should be declared in Nautilus.

These .desktop files are located under ~/.local/share/file-manager/actions and follow the Free Desktop specifications.

Each file provides a complete description of one nautilus action menu entry.

Here is the example of a .desktop file to create a new Bash Script :

[Desktop Entry]
Name=Bash script
Tooltip=Bash script
ToolbarLabel=Bash script

[X-Action-Profile directory]
Exec=/usr/local/bin/nautilus-newfile-action bash %f

You can see that, when the corresponding menu will be selected, Nautilus will call nautilus-newfile-action with the document type and the target location.

This nautilus-newfile-action script which will be in charge of creating the empty document. It is described later in this article.

1.3. Main submenu

To avoid having too many meny entry at first level, we'll declare a New file ... submenu which will hold all the other new document action menus.

ubuntu nautilus newfile menu

This submenu .desktop files is also located under ~/.local/share/file-manager/actions and follows the Free Desktop specifications.

It should be something like that :

[Desktop Entry]
Name[C]=New file ...
Tooltip[C]=Create new empty file

ItemList key lists all the Nautilus actions that should be placed under this submenu entry.

As we've gone thru basic principle, it's now time to setup a script which will help you to create all needed files according to your empty document models.

1.4. Configuration file

The list and main characteristics of your empty document models are managed thru a simple .ini configuration file.

Why an .ini file ? Just because it is really simple to write and manage.

This configuration file, located under ~/.config/nautilus-actions and named nautilus-newfile.ini, provides one section per document type.

Every section has few simple parameters :

  • label : text to be displayed in the menu
  • icon : icon to be used for the menu entry
  • model : empty document model filename
  • option : set execute right

label=Bash script

1.5. Action script

nautilus-newfile-action script is the script called by Nautilus menus to create the needed empty document.

It is called with the document type and the target folder where to create the document.

As document type is given as parameter, the script then gets all needed data (document model filename and creation option) from the configuration file.

The script can then create the empty document from document model.


1.6. Declaration script

as we've seen earlier :

  • configuration is done in ~/.config/nautilus-actions/nautilus-newfile.ini
  • documents models are placed under ~/.config/nautilus-actions/nautilus-newfile directory

So it's now time to call a nautilus-newfile-declare script which will do all the Nautilus action declaration job :

  • Creation of a Nautilus action .desktop file for every document model declared in the configuration file
  • Creation of Nautilus action menu that will hold all former actions

 Script can take --install parameter to declare all Nautilus action menus and --remove to suppress them.

When called, it removes all previous actions and create new actions described in the configuration file.


2. Installation & Configuration

2.1. Installation

To get a complete working setup to be able to create new documents from Nautilus file manager, you need to :

  • install nautilus-actions package
  • create empty document models
  • declare empty document configuration
  • run a nautilus-newfile-declare script

All operations can be done in one go from a all-in-one installation script available from my GitHub repository.

This script has been written for Ubuntu 16.04 and provides 4 different models of documents (text file, bash script, writer and calc documents).

It will do whatever installation which has been described earlier in this article.

# wget
# chmod +x
# ./

All Nautilus instances are killed to enable the 4 new menus to be available with a right click in Nautilus windows.

ubuntu nautilus newfile menu        ubuntu nautilus newfile toolbar

2.2. Add/remove document model

Everytime you want to declare or remove an Empty Document model, you'll just need to :

  1. create/remove document model in ~/.config/nautilus-actions/nautilus-newfile
  2. declare/remove document type declaration in ~/.config/nautilus-actions/nautilus-newfile.ini
  3. run the declaration script from any console

# nautilus-newfile-declare --install

That's it !


Hope it helps.

Signature Technoblog

This article is published "as is", without any warranty that it will work for your specific need.
If you think this article needs some complement, or simply if you think it saved you lots of time & trouble,
just let me know at This email address is being protected from spambots. You need JavaScript enabled to view it.. Cheers !

icon linux icon debian icon apache icon mysql icon php icon piwik icon googleplus