3

In many file managers there is a shortcut/key to create a new folder. In Nautilus, Thunar, Panthon-Files, this is Ctrl+Shift+N, in Dolphin it is F10.

How does this shortcut work?

I imagine that behind it it's a mkdir command, but that would need a path (like discussed here). I can imagine that opening the file manager at a certain location and using the shortcut, this triggers the needed command: is this what happens? What command is that? Can a custom shortcut be used for the same purpose?

2

The new folder is not created until you actually provide a name, normally by typing something in what looks like a directory/folder name in the currently open directory/folder in the manager. Once you enter that name and press return the actual call to mkdir() is executed (not the mkdir commandline command). And if you directly press Enter you often get some default name.

The event that you press Ctrl+Shift+N triggers the routine that creates the box where you change the name for the new folder and that sets the whole thing rolling.

  • I was wandering if all that can be done with a new custom shortcut (linked maybe to a script if not a command) when the file manager is open at the given location. – user32012 Apr 27 '16 at 5:37
  • 1
    A shortcut would have to invoke some external program that activates functionality in the file manager probably by finding the manager as being the program with focus. The manager would need an API for that or you would have to insert the appropriate key events to emulate the keycombination the manager expects for making a new directory and the key events for the name. Is that what you are looking at creating a subdirectory with a specific pre-programmed name on pressing a key-combination? – Anthon Apr 27 '16 at 5:54
  • I came to ask such a general question by initially just asking for a custom shortcut for creating new folder (an alternative to Ctrl-Shift-N: I need to do that with just two keys) here. Now I understand that there is no such single command behind that, but I imagine a shortkey calling a script would work: but that should be adjusted to the specific applications of a given system. Maybe I should ask for a such script on askubuntu regarding Nautilus. – user32012 Apr 27 '16 at 6:07
  • 1
    @cipricus Sorry if I misunderstood. If you ask there make it simple: 1) nautilus is active with dir X open. 2) I press XYZ which is not a keyboard combination for Nautilus. 3) I want directory "KLM" (specified in a config file) created under "X" – Anthon Apr 27 '16 at 6:14
  • No misunderstanding. What I ask is very simple (use an alternative 2-key shortcut to Ctrl-Shift-N). The answer may be more complicated though. – user32012 Apr 27 '16 at 6:20

Your Answer

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