Set command line different color than result text in iTerm2 - macos

As it is right now, it has become rather annoying having to wade through old result texts through iTerm trying to distinguish where my command line was and what the resulting text is.
Is there a way to make it easier for me to clearly identify my command line?
I was thinking I could set it a different color than my result text.

You can setup your shell prompt in a different color please have a look at following two links, one for bash and the other for zsh.
Remember if you ssh to a different host you most likely will lose the color unless you have exactly same settings on that host.
on-my-zsh
crazy bash prompt

Related

Add a header in a Bash script, over the output of commands [duplicate]

Under Ubuntu 14.04, I'm writing a script that output a lot of text (several commands...), and I would like to keep one or more lines always on top of the terminal screen to display what's running title.
In other words, I try to reduce terminal vertical scroll zone and write in that non-scrolling zone.
How can I do that? I saw similar stuff using a loop catching output line by line, but I'm unable to find a way to tell the system to print from let's say line 2 or 3.
Thanks for your answers,
Nicolas
Nic, it appears this does quite nicely.
http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x361.html

Change Color of Text Being Currently Used (Terminal - OSX)

For reference purposes: I am using a Macbook Pro Retina (2014) and all software is up to date as of the time I am posting this question. (Using OSX 10.10.2 Yosemite)
I have been struggling for the past few days as I attempted to customized the Terminal window. Everything was going fine... until I decided I only wanted to change the color for the text that you are currently typing (text input) which will then be executed.
I have no problems getting into my .bash_profile and adjusting anything. I simply cannot seem to grasp the color concept well enough such that it only does this one thing for me. Currently my .bash_profile looks like this:
export PS1="\n\n\njboned$ "
export PATH="/usr/local/mysql/bin:$PATH"
export CLICOLOR=1
export LSCOLORS=ExFxCxDxBxegedabagacad
Any assistance would be greatly appreciated. As a sidenote: I understand the 8-bit snippets used to represent the individual colors, however it seems I cannot figure out how to use them to address only the text input only.
To do what you are asking, these steps would be needed:
at the end of the prompt, turn on the text color which you want to show
when you press return (to complete editing) turn the text-color off.
bash does not reset attributes while you edit, so the color "should" work — while editing. As you edit, bash is likely to use escape sequences which clear the current line (which may fill it with whatever background color you have selected).
The real problem is how to reset the colors when you press Enter. That does not appear to have a straightforward solution: I do not see a way to rebind the Enter key to add features—no distinction is made between levels of interpretation, and you may not find it possible to enhance the Enter key. The key binding feature in bash talks mainly to the readline library; leftovers are sent to bash. In a binding you may be able to do these things:
send the name of a macro to bash, or a full echo command which resets colors (since readline has no echo of its own, it seems)
the Enter key (i.e., ^M), and
to readline directly, the accept-line function
Alternatively, what you could do is bind another key, say control/L to do the bash accept-line function as well as resetting color. Here are a couple of links which you would find useful to investigate how to do this:
how to bind the 'Enter key'
Complex keybinding in bash
In bash, how do I bind a function key to a command?
Smart preparsing with the bash shell

Is it possible to change style of an SSH pane in iTerm2 with zsh?

I am using iTerm2 and zsh on my mac.
I'd like to be able to easily differentiate between which panes are ssh'd and which ones are local. It'd be awesome if I could change the colors for these different cases.
Is this possible?
Let's say you current prompt is:
_PROMPT=%n#%m:%c\ $\
Note the space character after \. Add some colors:
_PROMPT=%B%F{green}%n#%m%b:%B%F{blue}%c%b\ $\
Similarly, use different colors on the remote machine.

Modifying How Windows Path is Displayed in CMD

I need to modify the way the CMD shows the path, whether it's in a batch file or not.
For example:
~/Users/MyName/Desktop
instead of:
C:\Users\MyName\Desktop
It would also be appreciated if somene could tell me how to use colours in CMD in the following way:
echo /color1Blah/color2Blah
This takes me back to the days when everyone knew and used DOS!
There is a environment variable that controls how the prompt is displayed in the command window.
PROMPT=$P$G
You can kind of accomplish what you want, but with limitations. For instance, if you go to a command window and type:
C:\>prompt ~$P[space] (don't type the C:\> and [space] is an actual space), your prompt will change to:
~c:\[space]
You can type prompt /? to see all of the available options. Once you have found a combination that you like, edit the environment variable and it will be set for all future command windows. The biggest limitation is that you cannot change the backslashes to forward slashes.
As for colors, type color /? from the command line. You can set the entire background and foreground colors, but not individual elements on the screen. That is unless you can get a copy Ansi.sys and get Windows to load it when you open a Command Window. Here are a couple of cool links to sites that use color in the PROMPT.
http://www.robvanderwoude.com/ansi.php
http://www.robvanderwoude.com/prompt.php
I Googled ansi.sys windows 7 and found a few people that said they got it working (like here). I don't have Ansi.sys anywhere to give it a try.
The first path is a Linux path the second is a windows path - never the two shall meet.

Most elegant way to detect available colors in terminal to use colorschemes in vim?

I want to know if it's possible to detect available colors in terminal which vim was called, so I could select different colorschemes for each color situation.
This is different from checking &t_Co variable. Sometimes I open a vim with 8 colors, and can set t_Co=256 to use some colorschemes, but sometimes (Like in Terminal.app in mac), setting this variable doesn't throw an error but the t_Co isn't changed because Terminal.app's color limit is 16.
Fact is: I only know this limit by experience, I would like to know if it's possible to know this value from calling a function (if terminal_supports > 256) or something like that.
Can I do it using just viml functions, or I would need to create some bash scripts and call them from vimrc for example? I would like to have this information in Linux, Mac and Windows (also, using Cygwin).
(If I, for some reason, can't get this information from the system, is there a table or in vim help some information about different terminals and their color capabilities? If so, then I could create a hash table with all terminals and ther colors capabilities.)
Another try: some information is here, if you haven't found it already, including informative link at bottom of the linked page:
256_colors_in_vim
So far as I know Vim gets the t_Co number from termcap. So if you can get value from termcap to accurately reflect max colors supported then you're set. I think that's what the info in linked page does, at least for 256 color terms. . .

Resources