Home Download Buy Blog Forum Support

Terminal Plugin

Terminal Plugin

Postby wbond on Tue Aug 16, 2011 7:29 pm

This is a simple plugin to allow for opening a terminal at the current file, or the current project folder. Terminals can be opened via key command or context menus. It works on Windows, OS X and Linux.

Full documentation including installation instructions, settings, key bindings and changelog is available at http://wbond.net/sublime_packages/terminal.

Updates

  • 2011-11-28 - version 1.3.1 released
  • 2011-11-05 - version 1.3.0 released
  • 2011-08-30 - version 1.2.0 released
Last edited by wbond on Tue Nov 29, 2011 4:02 am, edited 4 times in total.
wbond
 
Posts: 531
Joined: Mon Feb 28, 2011 5:33 am

Re: Terminal Plugin

Postby firefusion on Wed Aug 17, 2011 6:04 am

Another killer plugin. Thanks wbond!
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Terminal Plugin

Postby firefusion on Wed Aug 17, 2011 8:59 am

Hmm, I just had a thought that this could be useful to quickly launching SASS or LiveReload. Is it possible to set a shortcut or right click menu option that passes the terminal some arguments?
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Terminal Plugin

Postby wbond on Wed Aug 17, 2011 12:57 pm

I should be able to make the command accept an optional argument that would be passed to the terminal. Then you could create a menu entry or keyboard shortcut that would call the open terminal command with whatever parameters you wanted.
wbond
 
Posts: 531
Joined: Mon Feb 28, 2011 5:33 am

Re: Terminal Plugin

Postby firefusion on Thu Aug 18, 2011 5:12 am

Yeah that would be ideal. Thanks.
firefusion
 
Posts: 218
Joined: Fri Oct 16, 2009 7:37 am

Re: Terminal Plugin

Postby charlesroper on Thu Aug 18, 2011 7:59 am

That would be awesome. Thanks!
charlesroper
 
Posts: 107
Joined: Thu Feb 18, 2010 7:30 am

Re: Terminal Plugin

Postby charlesroper on Thu Aug 18, 2011 8:21 am

I use Console2 as my terminal and to pass it a directory to open at, you need this template:

Code: Select all
"C:\Program Files\Console2\Console.exe" -d "%1"


You can also pass it a tab argument:

Code: Select all
"C:\Program Files\Console2\Console.exe" -t "Git Bash" -d "%1"


This would open Console using the tab settings named "Git Bash". That is, it would open a new Git Bash prompt. Would be good to be able to configure the optional argument to accommodate these settings. For convenience, I've copied in the content of the help docs in regard to command line options:

Code: Select all
Command line parameters
Console supports these command line parameters:

-c <configuration file>
Specifies a configuration file.

-w <main window title>
Sets main window title. This option will override all other main window title settings (e.g. 'use tab titles' setting)

-t <tab name>
Specifies a startup tab. Tab must be defined in Console settings.

-d <directory>
Specifies a startup directory. If you want to parametrize startup dirs, you need to specify startup directory parameter as "%1"\ (backslash is outside of the double quotes)

-r <command>
Specifies a startup shell command.

-ts <sleep time in ms>
Specifies sleep time between starting next tab if multiple -t's are specified.


Note: -t option is not used to set tab's title. It specifies one of the names of the tabs defined in Console settings.

Note: If you specify multiple -t options, you can specify multiple -d and -r options as well. In that case, each -t, -d and -r option will be grouped together. If there is no corresponding -d option for a -t option, the initial directory from that tab's settings will be used. For example:

Console.exe -t bash -d C:\WINDOWS -r "ls -al" -t cmd -d D:\ -t ncftp

Will start 'bash' tab in C:\WINDOWS, running "ls -al" command in it and 'cmd' tab in D:\. 'ncftp' tab will be started in the initial directory specified in its settings.

Note: Some shells need an additional switch in the startup command string. E.g. when using cmd.exe, you must put /k at the beginning of your command string:

Console.exe -t cmd -r "/k dir /b"

Note: -ts option can be useful if you want to start multiple instances of a tab, and tab's shell needs write access to some files during initialization Using -ts option, you can specify time to sleep between starting the next tab, giving each shell enough time to initialize itself.


So, riffing on the Sass and Livereload stuff, we could open up two tabs and run shell commands to start up the Sass watcher in one and Livereload in another, all from one command. That would be pretty sweet.
charlesroper
 
Posts: 107
Joined: Thu Feb 18, 2010 7:30 am

Re: Terminal Plugin

Postby wbond on Thu Aug 18, 2011 1:49 pm

charlesroper wrote:I use Console2 as my terminal and to pass it a directory to open at, you need this template:


I just tested out Console 2 and it worked as expected just setting the exe path. What the plugin does is launch the exe with the CWD set to the directory that contains the file or folder you were editing or selected.

For passing arguments to the terminal, you'd either have to write a batch script, or wait until I add support for passing parameters. The way it is implemented with the subprocess module right now, the program path needs to be separate from any arguments.
wbond
 
Posts: 531
Joined: Mon Feb 28, 2011 5:33 am

Re: Terminal Plugin

Postby wbond on Mon Aug 22, 2011 2:03 pm

Version 1.1.0 now supports default parameters to the terminal application and also has a parameters arg for the open_terminal and open_terminal_project_folder commands. http://wbond.net/sublime_packages/terminal has documentation and an example.
wbond
 
Posts: 531
Joined: Mon Feb 28, 2011 5:33 am

Re: Terminal Plugin

Postby atomi on Mon Aug 22, 2011 10:52 pm

I've changed my terminal to:

Code: Select all
"terminal": "C:\\Windows\\system32\\cmd.exe",


The terminal window loads, however it takes nearly a minute for a prompt to appear.
atomi
 
Posts: 342
Joined: Thu Jan 20, 2011 5:06 pm
Location: Los Angeles CA US

Next

Return to Plugin Announcements

Who is online

Users browsing this forum: No registered users and 7 guests