I use SublimeText3 and try to change the colour for SublimeREPL Shell because its all white. Is that possible? Or is it possible to use colours from system prompt like PS1=''
?. I am running on ubuntu. I haven't found a soloution.

- 764
- 1
- 8
- 19
1 Answers
I assume you're trying to color the prompt in the SublimeREPL shell - if you want syntax highlighting of the commands you type, just change the syntax to Shell Script (Bash)
. To do this permanently, open your Packages
folder (Preferences -> Browse Packages...
), browse to SublimeREPL/config/Shell
, and open Main.sublime-menu
as a JSON file. Line 26 contains the "syntax"
setting; just change the value to "Packages/ShellScript/Shell-Unix-Generic.tmLanguage"
, save the file, and the next time you start it the syntax will be applied.
However, if you're just trying to color the prompt, you'll have much more work to do. First, you'll have to create a custom .tmLanguage
syntax definition file creating scopes for the various parts of the prompt you want to highlight, then you'll need to alter your color scheme's .tmTheme
file to actually style the scopes. (If you're using the ST3 dev builds and have Build 3084 or newer, you can also use the new YAML-based .sublime-syntax
format instead of the XML-based .tmLanguage
one.)
If you're not using a dev build, the best way to write syntax definitions is to use the wonderful PackageDev
package. I maintain an alternate - and better :) - syntax definition for Python and I much prefer using PackageDev's .YAML-tmLanguage
format, which as you can tell is also based on YAML, but was around long before the new "official" .sublime-syntax
format, and of course they're incompatible. However, it is quite easy to convert from YAML-tmL to tmL to sub-syn and back again, so it's no big deal.
However, as I was saying, the contents of your syntax definition will vary depending on the exact structure of your prompt, and what you want to do with it. For the following examples, I'm assuming you have the default Ubuntu user@hostname:/present/working/directory$
prompt. To create a new syntax definition, after installing PackageDev, select Tools -> Packages -> Package Development -> New Syntax Definition
and you'll get the following:
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Syntax Name
scopeName: source.syntax_name
fileTypes: []
uuid: 7e1549b3-fb0b-44fc-a153-78a7fc2157c2
patterns:
-
...
The first line is required, don't mess with it. You can make name
whatever you want. scopeName
is obviously the identifier for the base scope, perhaps something like source.shell.prompt
. fileTypes
can be left blank, and the uuid
left alone as well.
If you want to get a feel for how these files are supposed to work, feel free to check out PythonImproved.YAML-tmLanguage
on Github, and also make use of the Sublime Text Unofficial Documentation page on the subject as well as the reference. There's also some info in PackageDev's README.
I'll let you develop the rest of the regexes, but here's one for matching the username to get you started:
# [PackageDev] target_format: plist, ext: tmLanguage
---
name: Shell Prompt
scopeName: source.shell.prompt
fileTypes: []
uuid: 7e1549b3-fb0b-44fc-a153-78a7fc2157c2
patterns:
- name: meta.username.prompt
match: ^([A-Za-z_][A-Za-z0-9_-]{0,31})(?=@)
...
You can see it working here.
Once your .YAML-tmLanguage
is complete, save the file, open the command palette, and select PackageDev: Convert (YAML, JSON, PList) to...
. This will build the .tmLanguage
file and put it in the same directory as the .YAML-tmLanguage
file. If it's not already under the Packages
directory tree, copy it to your Packages/User
directory, then modify the Main.sublime-menu
file as described in the first paragraph. Finally, open your color scheme's .tmTheme
file and edit it to add the scopes defined in your new syntax. Save it, restart Sublime for good measure, and you should be all set!

- 100,794
- 21
- 241
- 231