38

Is there a way to open a file not from the workspace tree view but from the c9-terminal tab?

Background: c9 doesn´t allow me to set the workspace path to / for a user who doesn´t have write access there. But I´d like have a look around and change files outside of the main project directory (virtual hosts, php ini, etc). Using the terminal I can roam around everywhere my user has read access.

perelin
  • 1,367
  • 1
  • 17
  • 32

6 Answers6

49

At the moment, the only way to open a file from the terminal is in vim or by using ls and then clicking on the file you'd like to open.

Edit: You can now open from the terminal by running npm install -g c9, restarting your workspace, then doing c9 file.ext or c9 open file.ext

Brady Dowling
  • 4,920
  • 3
  • 32
  • 62
  • Tried it, doesn´t work for files outside of the file tree (workspace path). Error: "No files found that match [FILENAME]" – perelin Jan 20 '15 at 18:02
  • Oh I see, I also am unable to open anything below my ubuntu folder. It looks like this is a limitation at the moment and you'll need to use vim to open anything below the ubuntu folder. – Brady Dowling Jan 21 '15 at 09:39
  • 1
    Just tried this and it worked great (without restarting the workspace even)! – Arel Sep 09 '15 at 06:26
  • 2
    Old thread, but I was looking for this solution, too. Now this works without restarting the workspace. – Vince Mar 12 '18 at 22:26
  • Hey, I have this working. However, when collaborating it opens the files for everyone logged into the environment. Is there a way to open files just for me? – trixtur Aug 16 '18 at 21:49
14

Borrowing from here,

c9 open <filename>
Community
  • 1
  • 1
user139301
  • 344
  • 6
  • 12
  • I get a "bash: c9: command not found". Where do I find the c9 command line client? – perelin Aug 12 '15 at 11:05
  • 2
    See Brady's answer... you may need to install `c9` first with something like `sudo npm install -g c9`. – Arel Sep 09 '15 at 06:29
9

You can do the next:

cd ~
ln -s / root

Then you can see the root link in the workspace. You can navigate through it and open any file (If you do not see the ~ folder in your favorites section, mark the 'Show Home in Favorites' option)

Root folder in ~

If you prefer, (once you've installed c9) you can open files from the terminal with:

c9 open ~/root/...

NOTE: You can open files but not save them if they require superuser permissions.

guiferviz
  • 150
  • 1
  • 9
1

If you go to Preferences -> Settings -> Terminal, there is an option "Use Cloud9 as the Default Editor". If you enable this option and open a terminal, the EDITOR env variable will look like this:

$ echo $EDITOR
`which c9` open --wait

The path to c9 in my case is:

/mnt/shared/sbin/c9

For some reason, this didn't work for me initially, but now it works flawlessly. Perhaps the above default editor setting has to be enabled for it to work?

Hubro
  • 56,214
  • 69
  • 228
  • 381
1

I've just written into /mnt/shared/plugins/google.cloud/etc/gitconfig. First I was not allowed to write it, in nano. But using "c9 open" - just closing the tab with .gitconfig saved my changes.

Petr Kosvanec
  • 115
  • 1
  • 7
0

If you want to open any file from / the cloud 9 IDE must have permission. While configuring the C9 IDE give root as the user name and copy paste the public key in .ssh folder of root, allow root login in the ssh d config ,then you will be able to edit any file from the IDE.