eclipse-theia / theia

Eclipse Theia is a cloud & desktop IDE framework implemented in TypeScript.
http://theia-ide.org
Eclipse Public License 2.0
19.99k stars 2.5k forks source link

Open file from Terminal - possible? #3724

Open andlo opened 5 years ago

andlo commented 5 years ago

Are there any way top open a file from the Terminal ?

As a user who use Terminal a lot i would like to open files that way.

Sometimes ne also navigate away from workspace to find something, and again sometimes need to previev or edit files. And then it would be awsome if that could happend from the Terminal.

AndrienkoAleksandr commented 5 years ago

You could use file-search "Ctrl + P".

andlo commented 5 years ago

Good point. My current Theia-Ide dosnt have file search, so maybe thats why I didnt think of that. Where Does filesearch come from (whivh addin ?)

But still - if in Terminal, and navigating away from workspace and find a important file I want to look at, it woud be nice to do that from Terminal. Using filesearch I have to write the path onse more as I guess that if it is outside the workspace filesearch hassnt indexed it.

andlo commented 5 years ago

That would be the package file-search that gives the file search posibility :) As it says "Adds the file search command, to quickly open any files in the workspace." this cant be used to open a file outside the workspace I guess.

Alt+O for open file can be used, but then I have to navigte fo open the file, and if alreddy in Termina have navigated to the directory it is not so fun to do it agan in open file dialog...Then it is faster to use nano or less to edit or look at the file. But it would be super to have a way top get it into the editor instead.

thegecko commented 5 years ago

That's a nice idea

svenefftinge commented 5 years ago

We have that in gitpod.io but it relies on the Gitpod CLI that we install into the workspace. So you can write

open my/file.ts

Not sure how that would technically fit into the general Theia framework, as I would prefer to have it going through the terminal and not being a hack that captures the terminal communication.

andlo commented 5 years ago

I dont know how it teknicaly could be made, but I were thinking of a program that could talk to the running theia. And it took some parameters - something like: theia open /home/me/myfile.ts (opens a file) theia openworkspace xxxxxx (opens new workspace) theia terminal run /home/myscript.sh (opens a new terminal and run a script)

and then one could make aliases and set env variables like $EDITOR

I see this working as long as the user has access to files - dont think sudo theia open /etc/somefile would work, as the file would be opend as the user running theia. But it would be nice :)

avelino commented 5 years ago

Is that possible? I certainly got to this issue because I have this need 😃

avelino commented 5 years ago

new feature on VSCode 1.31 Current working directory used for links

AndrienkoAleksandr commented 5 years ago

@avelino I guess they used link matcher with some regexp and click handler https://github.com/xtermjs/xterm.js/blob/3.11.0/typings/xterm.d.ts#L512

svenefftinge commented 5 years ago

See https://github.com/Microsoft/vscode/blob/622b3d62dd92ea1bcdc7d250e0a7565b018edcee/src/vs/workbench/contrib/terminal/electron-browser/terminalLinkHandler.ts

andlo commented 5 years ago

Looks interesting, but I cant figure ut what that means. :)

rymo commented 4 years ago

given I'm in a Theia-hosted terminal window in bash with all the expected environment variables set, is there a script one could fashion to get a signal to windowService.openNewWindow such that a file can be opened without the echo + ctrl+click trick?

akosyakov commented 4 years ago

@rymo There are so called command links of a format: command:commandId?args_serialized_as_json. You can try to use something like command:vscode.openFolder?partToFolder given that you have @theia/plugin-ext-vscode extension installed.

echuber2 commented 4 years ago

Do you have an example of how to implement one of these command links? I'd also be interested to add a bash script that would let you open a file in the editor from the terminal.