9o is GoSublime's command-shell, press ctrl+9
or super+9
activate it.
It has two basic concepts: commands and actions.
Type #
(hash/number sign/pound sign [space]) to begin a command sequence e.g. # help
', then press enter to execute it.
Filename and other actionable text are highlighted (usually bold).
Place the cursor over these areas and press ctrl+dot
,ctrl+g
' (or super+dot
,super+g
on OS X) to open the corresponding file.
Alternatively, press ctrl+shift
', (or super+shift
on OS X) and left-click.
9o has two command modes: sh
and 9o
.
In sh
mode your commands are passed as-is without interpretation directly to your shell.
e.g. you might want to use special features of your shell like piping (sh echo 123 | filter-cmd
)
For all other commands, the command line is split by spaces, taking quoted args into consideration
and then environment variables in each argument are expanded (as well as ~/
which
is short-hand for your $HOME
directory) and then the command is executed.
If the command is not found(not a 9o builtin), it's treated as-if it was run via sh
In 9o
mode, environment variables of the form $NAME
and ${NAME}
are supported.
The following variables are defined for each command you execute. These will override any variable
of the same name that might've been inherited from your shell
or the Sublime Text environment.
Additionally, these variables will be defined within the initial environment of all commands executed
through 9o, so they should appear inside commands run through your shell
. Please be aware that your
shell might override these variables with its own, epecilly in the case of $PWD
-
$_wd
(or$PWD
): the absolute path to the current working directory -
$_fn
: the absolute path to the current active file. If the file hasn't been saved, this will be an empty string. -
$_nm
: the base name of the current active file. If the file hasn't been saved, this will be n empty string
-
help: Present documentation for 9o and its supported commands
-
build: build the current package
-
run: build the current package. If it's a regular package run its tests otherwise(package main) execute it. e.g.
run
orrun -flag1 -flag2=abc
-
replay: like
run
but attempts to cancel any active executions before running -
go: run the
go
command e.g.go help
-
clear: clears the output panel
-
tskill: lists or cancels active tasks. type
tskill
to show a palette containing a list of active tasks and their summary and cancel them where possibletype
tskill [TASK ID]
to cancel the task. The task is represented by #TASK_ID. (you will be prompted with an ok/cancel dialog to confirm the action)[ tskill t1 | done ] kill t1: yes
the following aliases can be used in place of task ids:
tskill replay
kill the last instance of the replay commandtskill go
kill the last instance of the go commandgo run
etc. note, however that this may fail to actually kill the executable being run bygo run
-
settings: list settings as seen by GoSublime. type
settings
to get a listing of all settings. typesetting [NAME1] [NAME2] ...
to the value of the listed names -
env: list environment variables as seen/generated by GoSublime. type
env
to get a listing of all environment vars usable by GoSublime. typeenv [NAME1] [NAME2] ...
to the value of the listed names -
share: share the active view's content on play.golang.org
-
hist: manage command history type
hist
to list all historical commands typehist erase
to erase all historical commands -
cd: change directory type
cd
to cd to the directory of the current file (like ctrl+9 does) typecd ~/go
to cd to thego
directory in your home directory typecd $GOROOT/src/pkg/fmt
to cd thesrc/pkg/fmt
in your GOROOT -
which: locate a command type
which
to list all builtins typewhich cmd1 cmd2...
to locate the listed commands -
echo: output the specified arguments type
echo $_fn
to output the path to the current file (if it has a name on-disk)
When you run a command e.g. replay
, its line is replaced with the command followed by and hour glass
and a new prompt is initialised. When the command completes a its output is printed and the hour glass
replaced with a summary.
[ /go ] # replay
|
v
[ replay ⌛ ]
[ /go ] #
|
v
[ replay | done: 2.987ms ]
hello world
[ /go ] #
In the 9o autocompletion menu, old commands are listed in the (reversed) order they were last executed.
They are prefixed with a carret(^) e.g. ^1 replay
. In addition to being able to autocomplete them,
you can also expand them by their alias(without execution). To do so, type the alias and press [enter] e.g.
[ /go ] # ^1
is replaced with:
[ /go ] # replay
To expand and execute an old command by its alias, use two carrets e.g.
[ /go ] # ^^1
executes the last command:
[ `replay` | done: 2.557ms ]
hello world