IntellijIDEA 13 has an embedded shell in a terminal window. That's nice.
Is it possible to open a file from within this terminal window in the IDE for editing?
Update:
What I want is an alternative way to open a file for editing from inside the IDE.
Instead of using the "Open File..." dialog I want to open a file using IDEA's built in terminal window which I now use a lot to run other commands as well.
IDEA's "Go to anything" dialog is another alternative but it only works for files within my project.
Update 2
A good enough solution has been posted here IntelliJ: how to open files in an existing IntelliJ from the command line:
$ open -b com.jetbrains.Intellij README.md
opens the file README.md in the current running IDE. It works from the embedded terminal window as well as any other Terminal emulator you are using.
Since you do want to open some files with their native application and execute commands as is, you can't reconfigure IntelliJ to open everything within itself. You can however use a batch script to send a file to IntelliJ. Save this batch somewhere in your path and you'll be able to run this from terminal and having the file opened in IntelliJ:
idea file.txt
Idea.bat example:
#echo off
setlocal
SET IJ_PATH="c:\Program Files (x86)\JetBrains\IntelliJ IDEA Community Edition 13.0.1\bin\idea64.exe"
IF [%1]==[] (
echo usage: %0 file_name
exit /B -1
)
IF NOT EXIST %1 (
echo %1 does not exist
exit /B -2
)
%IJ_PATH% "%~f1"
Related
I can configure Cygwin as my terminal in Intellij by selecting the Cygwin.bat as shell path in Tools > Terminal settings.
I want it to open at the project folder. For example, If the project is at c:\projects\project1 and I open project1 when I'm clicking on the Terminal I expect the prompt to be at:
myuser# /cygdrive/c/projects/project1
How can I achieve this?
The solution from this forum post should help:
"c:\cygwin64\bin\sh" -lic 'cd -; exec bash'
When I use the idea command line tool to open a file in LightEdit mode
$ idea myfile.txt
and IDEA is already open in project mode it will not open file file. IDEA gets focus but the file does not open.
However, when I used the idea command line to open a file in LightEdit mode and IDEA is not already open, it works as expected.
If you use the Create Command-line launcher option to recreate the idea launcher file it will start working as expected.
I use git bash for my terminal configuration and it has --cd option where I can pass the path to open terminal in:
I have pretty deeply nested directory structure and thought it would be very convenient to open terminal in the directory I select in the tree:
Is there a plugin that can do that? If not, how hard will it be to write my own simple plugin?
It will probably be very basic:
read the currently selected folder path
run "open terminal" action supplied the command line string with the concatenated path
Thanks
there are no such plugins, please vote for IDEA-116724 and linked tickets.
You can try opening sh as External tool instead, like:
Program: C:\Windows\System32\cmd.exe
Parameters: /C "start sh.exe"
Working directory: $FileDir$
the only issue is that it will be opened as external window, not inside IDE
How can I specify the file to open in new tab with IntelliJ IDEA via command line?
If I run in command line:
idea d:\Dropbox\Dropbox\featurea\featurea-common\src\com\featurea\common\util\FileManager.java
I get "No project found to open file in" error
Open file in new tab with opened project also fails.
Is there any way to manage IntelliJ IDEA to behave as I want?
Thanks.
You can't open individual files in the IDE from the command line when there is no open project and the IDE is not already running.
You can pass the project directory as an argument to open the project first, then you will be able to open individual files.
I use GNUStep to compile Objective-C on Windows 7 using GCC and MinGW. I'd like to be able to automate the "make" instruction (with make files) from Notepad++ and have any complier errors reported to Notepad++s console window.
Edit:
What I am trying to do is script GNUStep/Bash to login to the right directory, build the directory, then exit. Currently I have to type in the following:
sh -login -i
$ cd d:\directory
$ make
Does anyone have any experience with this?
Rich
The npp-plugins gives you most of what you are looking for. Install the plugin and:
Press F6 to open the NppExec Execute window
Type 'make' (you may also want to cd to the proper directory first) and click OK
Output from make is shown in the notepad++ console
Another cool feature is that it will save the command if you restart notepad++, so you only need to type 'make' a single time.
You may need to make some tweaks to only show compiler errors, however.
I have done it, with considerable help from my friends.
Create a Bash script called 'nppmake'. I saved it in c:\GNUStep. The file should contain the following:
#! /bin/bash
cd $1
make
Create a DOS batch file called 'nppmake.bat', which again I saved in c:\GNUStep. This file contains the following:
sh --login -i C:\GNUstep\nppmake %1
In N++, go to 'Plugins > NppExec > Execute' and type in the following:
C:\GNUstep\nppmake.bat $(CURRENT_DIRECTORY)
Hit 'Save' and call the script 'make'.
In 'Plugins > NppExec > Advanced Options...', create a menu item, which I called 'Build' and associate it to the script called 'make' (I'm a Visual Studio developer, so 'build' feels more natural to me). Make sure 'Place to the Macros submenu' is checked.
You may need to restart N++ at this point, but then all that is left to do is add the keyboard shortcut. Go to 'Settings > Shortcut Mapper > Plugin Commands' and find 'Build'. I assigned 'Ctrl-Shift-B', is it is the same as VS.
You're done. Now open up a file in a Objective-C project, that has a GNUmakefile, and hit 'Ctrl-Shift-B'. The NppExec window reports any errors, or hopefully a successful build!
Just a small correction to kim3er's answer.
cd $1 make
should be
cd $1
make