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

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.

Related

OSX Terminal/Vim Syntax Colors

I've spent a bunch of time going over my Vim and Tmux configurations lately, trying to refine my workflow and I have come across a (small but annoying) problem that is stumping me. I am currently using OSX, but I have had the same issue with Windows' terminal/powershell.
My issue is that I am unable to change the brown color that appears in the default vim syntax highlighting which is used many of the languages that I write in. The color that I am speaking of can be seen in this vim colortest:
In the default OSX terminal (and in powershell) you can set the ANSI colors via terminal preferences, however, the brown color is not included in the GUI configuration options. This results in some ugly syntax highlighting that does not fit in with my desired color scheme:
My question is, what is the most portable way to change this default color? I would love to be able to do something in my .vimrc that would just work around this ugly color so I don't have to reconfigure colors for any system that I might be on, but I understand this might not be possible. Another route would be changing the syntax highlighting colors, but my investigations into that have so been unfruitful.
Thanks!
Appedix:
Colors selected in OSX profile for screenshots:
Sadly, the default Vim colorscheme is not as tidy as one would hope. In this case, Brown is a bit of a "catchall" name that ends up being interpreted differently in different contexts.
In GUI Vim, Brown refers to the "Brown" in X11's rgb.txt: #A52A2A.
In TUI Vim with &t_Co == 256, you get #af5f00, AKA 130 in the "xterm palette".
In TUI Vim with &t_Co == 16 or &t_Co == 8, you get your terminal palette's "Yellow", AKA 3.
By the looks of it, you seem to be affected by the second case.
While there exist ways to change the so-called "xterm palette" wholesale, you will have a hard time changing that specific color in a straightforward, non-messy way.
What you can do…
Do :set background=dark to force Vim to use a different set of default colors that doesn't include "Brown".
Choose a built-in or third-party colorscheme that doesn't use that specific color.
Override the Statement highlight group as explained in this gist with whatever color you want from the xterm palette.

How to split terminal into panes in macbook?

I am using iterm on my macbook and want to split it into multiple panes (both horizontally and vertically) like conemu. My end goal is to be able to type different git commands in each pane (conemu example). Is iterm capable of doing this?
If it's not possible with iterm, what are my other options?
I know you can "cmd + d" to split but then I only get the same terminal in 2 different panes.
Are you sue you are using iTerm? Any way I'll sugest to forget about it and use Terminal, for a macOS experience. iTerm remembers me of Linux, you have all the options but you'll spend all day configuring it and when finally is ok then some bug will hit and take your peace of mind How to exit alternate screen scrolling on iTerm2 Vim?.
This might help https://apple.stackexchange.com/questions/6504/how-do-split-panes-in-terminal-work. And #BennyPowers answer at https://superuser.com/questions/55459/how-to-get-vertical-split-of-terminal-in-mac-to-execute-different-actions.
I use the macOS native way to split vertically and GNU Screen (which came with macOS) to split horizontally. Execute screen then C-a S (to split into two regions), C-a TAB (to swith to the other region) and C-a c (to open bash).
You can even resize it with C-a : then type resize 10 i.e. and for more man screen.
When its done you exit andC-a k to destroy the window.
For completeness. A lot of people say tmux https://github.com/tmux/tmux/wiki is a better alternative to GNU Screen. I never tried afraid of the same experience I had with iTerm 2.

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

Set command line different color than result text in iTerm2

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

Vim color syntax highlighting changes not having any effect

I use vim on webfaction through putty and would like to change the colours used in the syntax highlighting. I have installed some example themes and then tried to change the colors in those themes to match the ones I want. For some reason this strategy does not work. What am I doing wrong? Is it because I'm using putty, or is it something weird with webfaction's linux or vim? Or is my logic just wrong?
I created /home/user/.vim/color/theme.vim
I then load the them by adding colorscheme theme to my /home/user/.vimrc
Aside from my color changes not working on obvious parts like
hi Normal guifg=#ffffff guibg=#000000 gui=none
it also does not seem to implement all the theme changes when I just use the theme without changing it. Is there something better than putty I can use?
In terminal mode, the ctermbg and ctermfg keys are used instead of guibg and guifg. It uses Xterm colors. See for example this table for a rough mapping, and even a VIM script that shows a color table.
So you would need to change your line to:
hi Normal ctermfg=15 ctermbg=0 guifg=#ffffff guibg=#000000 gui=none

Resources