jeremyramin / terminal-plus

A terminal package for Atom, complete with themes and more.
https://atom.io/packages/terminal-plus
MIT License
481 stars 255 forks source link

Different command line and command prompt text colours? #50

Closed objectkit closed 8 years ago

objectkit commented 8 years ago

Does terminal-plus provide the means to display different colours for the command prompt text e.g. host:path:user$ and the command line text e.g. emacs -q --no-splash -f doctor? I know the text colour can be changed outright, and perhaps I'm missing an option already there, but I'd like to be able to have both these text segments different colours to tone down things a little.

(Seriously though, it would be great to have command line text and command prompt text different colours!)

jeremyramin commented 8 years ago

@objectkit Prompt coloring would have to be done on your end since I have no control over that. Your prompt is set by the shell you are running.

If you know which shell you are using, then you can customize your prompt with the profile file.

Terminal-Plus Default Shells: Windows: Powershell OS X: Bash Linux: Varies (Usually Bash or Zsh)

Try searching around for tutorials on custom color prompts for the shell that matches your system. Coloring of the commands after the prompt could probably be done while you are customizing the prompt itself.

objectkit commented 8 years ago

@jeremyramin Thanks for getting back to me! I guess I just assumed that as terminal-plus is representational of the shell (Bash in my case) as opposed to a shell instance itself, and that as .less styling is used by the package to display text, that it would be possible to somehow parse the shell text input, use a regex to split prompt from text, assign a span to the command prompt span which could have its own styling, leaving the rest of the text as is inheriting from the text styles already in place, before displaying it representationally, which would make different command line and command prompt text styles possible. I'm sure it would be a pain to support all shells this way, but no idea myself. Top of your head, would that be possible thereby avoiding having to edit Terminal preferences for the OS shell? Would be great if so...

jeremyramin commented 8 years ago

Terminal-Plus launches a full shell instance and then pipes the output directly to a terminal emulator that makes the output display nicely as HTML. Since it makes no distinction between the prompt and the command, it would be difficult to have it start making a distinction. Not to mention that it would have to apply the regex matching through all output, increasing the amount of computation per line of terminal output. Since the prompt is customizable, I wouldn't be able to support every prompt. In addition, the bash prompt varies on systems.

I think the easiest and least intensive way would be to edit the bash profile on your system. If you cannot do that for some reason, there is a bit of a work around you can do. I just tried this myself:

  1. Make a .tprc file somewhere. It can be anywhere, but I recommend putting it inside of the .atom folder for Atom files. (The .atom folder can be found in your user directory.) screen shot 2015-10-25 at 12 04 02 pm Here you can customize the colors of your prompt. I used this to look up the color escape sequences.
  2. Add an autorun command that tells the terminal to read in our configuration file on launch. screen shot 2015-10-25 at 12 03 34 pm
  3. Enjoy. screen shot 2015-10-25 at 12 05 15 pm Note: This image is an example without the && clear after source ~/.atom/.tprc so you can see what the difference would be after source is called. The && clear will reset the view so you wouldn't have to see the output from using source on launch.
objectkit commented 8 years ago

Fantastic info @jeremyramin - what a nice workaround - respects! By creating the ~/.atom/.tprc file with the export PS1="\e[36m$PS1\e[97m" content, and then later playing around with some klutzy coloured PS1's... it works! I found Bash $PS1 Generator2.0 to be a bit of fun to format on top of the colour escape sequences you linked to above. If anyone else finds this, make sure to save your file as UTF-8 without the BOM or terminal may complain- I overlooked that first time around and got a bash error. Drop the BOM and have fun! Thanks @jeremyramin :)