0

I want to create a keyboard shortcut to launch the java compiler in the folder that's opened in Nautilus.

I tried commands like these:

gnome-terminal -e #script that invokes the javac and adds stuff the the classpath#

But whatever I do, the terminal will start in my home folder, not in the folder I'm currently working in.

2 Answers 2

0

I think the best way to do it is to create a context menu entry similar to "Open in Terminal..." for directories in nautilus.
I do not know how to map nautilus menu entries to a key (You can activate the entry with multiple keys using the context menu by keyboard, like with Menu).
But as you seem to already solved the key mapping part, maybe some hints on how to configure a menu entry for the script help:

For starting gnome-terminal with a specific start directory for the shell, there is an option --working-directory:

gnome-terminal --working-directory /some/java/dir -e startscript.sh

There is a nautilus extension to add menu entries: "Nautilus Actions". That would allow to implement the context menu that supplies the directory to use from nautilus.

It is described in one of the answers of How do I customize the context menu in Nautilus?.
(See also How can I add a custom item to the nautilus context menu, but NOT in a sub-menu?)

2
  • Thanks for the reply, but that wont solve it because the working directory is unknown to the keyboard shortcut command. I cannot set the working dir to one final dir because I use multiple folders with source files in it. What I meant was going to a folder and pressing a keyboard shortcut to launch the javac there. Dec 15, 2014 at 0:09
  • I see. I added some more hints - but still not a full solution. If it does not work with your keyboard shortcut, pleas describe how you configured that shortcut (In nautilus?). Dec 15, 2014 at 9:42
0

So this is sort of variation of my answer to this question. Make sure you set the profile in your terminal to hold the window , then create the script bellow, and assign a keyboard shortcut to this script (basicall full path to the script as command of the shortcut).

When you are in nautilus folder where you wanna run java compiler, run

#!/bin/sh
# set -x
OPENDIR=$(zenity --entry --text="Type or paste address");gnome-terminal --working-directory=$OPENDIR -x javac *.java &

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .