Let's say I want to create a .desktop file in /usr/share/applications and I do something like

sudo -i gedit /usr/share/applications/cipricus.desktop

This will open that file in gedit.

If I try to use the default text editor Scratch,

sudo -i scratch-text-editor /usr/share/applications/cipricus.desktop

that will just open Scratch.

If that file already exists, Scratch will open it just like Gedit does. But it doesn't seem able to create files. I have also tried without the need of administrator privileges.

2 Answers 2


I don't think it's possible, if you do open scratch text editor in the debug mode using

scratch-text-editor test.py -d

if the file does not exists, you will see someting like this in the terminal

[_LOG_LEVEL_WARN 11:26:52.180479] Scratch.vala:236: Error when getting
information for file '/hello': No such file or directory

Which means that the file/folder does not exists.

I think you should report this on Launchpad

Ps: you can have the list of possible options in terminal using scratch-text-editor --help-all


You can set up an alias to create the file if it doesn't exist. First, create the bash file:

touch .bash_aliases
scratch-text-editor .bash_aliases

Then add the following:

scratch() {
    touch $1
    scratch-text-editor $1

This will set the command scratch to make the file (with touch) and then edit it with scratch-text-editor. $1 means the first argument given.

This solves the other issue of the command for scratch being annoyingly long. Anyway, restart your terminal, and check the top. If you see an error like this:

bash: /home/tim/.bash_aliases: line 2: unexpected EOF...

or any error about the file, then check you've entered it all correctly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.