We would create a script ~/.local/share/nautilus/scripts/newFile with the commands to create a new file. Don't forget to make the file executable.
To run this script through a shortcut we need to modify the file ~/.config/nautilus/scripts-accels.
I added the line
and my files looks like this
F12 Terminal
N newFile
; Commented lines must have a space after the semicolon
; Examples of other key combinations:
; F12 Terminal
; F12 Terminal
; F12 Terminal
Now we have to put the commands for the file creation into ~/.local/share/nautilus/scripts/newFile. The simplest option is touch untitiled_document, however we still would need to click on the file, then press F2 to rename it and I find it is quite cumbersome to do every time. I tried to select a file through DBus messages but unfortunately Nautilus does not have a DBus interface for file selection. The possible solution is to use Zenity (a tool for creating Gnome dialogs, credit forum.xfce.org). I used the following script
#!/bin/sh
file=$(zenity --title 'Select Filename & Destination' \
--width=300 --height=200 --file-selection \
--save --confirm-overwrite)
if [ "$?" = "0" ]; then
touch "$file"
fi
No comments:
Post a Comment