change xterm profile based on branch name - version-control

I want to change the Xterm background color based on what branch I'm currently in. Is there a good way to automate this?
Currently I'm changing the profile by hand. And I find it a bit annoying that google couldn't provide me with an answer. Everyone seems settled by just changing the prompt.

You could start with "fixing the prompt": some of those answers deal with modifying the (bash or zsh) prompts to send escape sequences which change the window title. The background color for xterm would be just another escape sequence, part of the same group of Operating System Commands:
OSC Ps ; Pt BEL
OSC Ps ; Pt ST
Set Text Parameters. For colors and font, if Pt is a "?", the
control sequence elicits a response which consists of the con-
trol sequence which would set the corresponding value. The
dtterm control sequences allow you to determine the icon name
and window title.
...
The 10 colors (below) which may be set or queried using 1 0
through 1 9 are denoted dynamic colors, since the correspond-
ing control sequences were the first means for setting xterm's
colors dynamically, i.e., after it was started. They are not
the same as the ANSI colors. These controls may be disabled
using the allowColorOps resource. At least one parameter is
expected for Pt. Each successive parameter changes the next
color in the list. The value of Ps tells the starting point
in the list. The colors are specified by name or RGB specifi-
cation as per XParseColor.
...
Ps = 1 0 -> Change VT100 text foreground color to Pt.
Ps = 1 1 -> Change VT100 text background color to Pt.
With xterm (not necessarily for "xterm" imitators...),
printf '\033]11;blue\007'
printf '\033]11;white\007'
changes the window background to blue and then white.
Unlike settings for "ANSI colors", the dynamic colors persist, will not be reset by other escape sequences.
Oddly, xterm: how to change the background color? suggests "two" (actually one) different way for setting the background color, but that's not useful for your purpose.

Related

How can I change the color of string values I type?

In my job I have recently begun using Powershell quite frequently. To facilitate using it, I am attempting to customize the command prompt colors to my liking, but I have run into a snag when attempting to customize the color of quoted string values. Given how PS is a text based interface, this statement may not mean that much, so please refer to this
Apparently I can't embed images yet, so you'll have to click the link.
Anyway, this text is extremely difficult for me to read, and I am attempting to switch it over to something with more contrast, but I can't find a setting for it.
I've looked at the following options already:
Setting these colors in the UI (right-click context menu), but that only allows setting default foreground and background
Setting the color utilizing $host.UI.RawUI, but this also only allows setting the default foreground and background
Setting the color using $host.PrivateData, but while this provides more options, it doesn't seem to have options for setting the more context sensitive items like the quoted text or even the variable you can see in the image.
My fallback plan is to use PowerShell ISE if I must (it allows me to customize this), but I would prefer to have a lighter weight command prompt available if possible.
Has anyone figured out how to change this?
I'm using PowerShell v5 on Windows 10.
PowerShell 5.0 ships with PSReadLine, a module that enhances the editing experience in the console by adding syntax highlight coloring among other things.
You can change the color of string tokens with Set-PSReadLineOption, for example:
Set-PSReadlineOption -TokenKind String -ForegroundColor Cyan
For PSReadLine version 2.0 and up, use the -Colors parameter and supply a dictionary of (optional) token color overrides to Set-PSReadLineOption:
Set-PSReadLineOption -Colors #{ String = 'Cyan' }

Is it possible to use a 16 color theme in gnome-terminal?

Has anyone been able to do this successfully? As far as I can tell this is very difficult because gnome-terminal lacks an option to disable "use bright as bold". Which means that:
$ echo "\e[1;31mred" # bold, color #1 (red)
and
$ echo "\e[31mred" # no bold, color #1 (red)
will use different colors (the former will actually use color #9, 'bright red'), whereas 16 color themes depend on this not happening.
You can get around it by doing:
$ echo "\e[1;38;5;1mred"
which will display bold text with color #1, not color #9, but many existing apps don't do this, and rely on "\e[1;31mred" being red.
Barring modifying all terminal applications that use color to use the 38 code method, is there any way to get gnome-terminal to work w/ these themes?

Popup color from color string like `#f2d3aa` with Emacs

I'm using scss-mode in Emacs.
There are a lot of color string like #f2d3aa in text.
I wonder if there is a function that pop up a color square from string of current position.
Is there a emacs function like this?
I'm using rainbow-mode. It's a minor mode that fontifies the text color descriptions as you type them.
Very user-friendly, since it's got only one interactive function (i.e. rainbow-mode).
It's available from MELPA.
Here are a couple of tools that can help:
hexcolour.el -- shows such hex color codes in their own color in the text
palette.el -- interactive color palette: takes such hex codes as input and provides them as output (in addition to color names etc.)
hexrgb.el -- (used by the color palette and other libraries) color manipulation functions
The first one, hexcolour.el, is the closest to what you asked for.

Set background color other then standard one in Powershell

I can change console background color by script:
$host.UI.RawUI.BackgroundColor = "Black"
but in this case I'm limited to preset number of defined colors and unfortunately one I'm looking for is not here. There is option to pick color from console GUI (right click on top Windows PowerShell bar->properties->Colors). Unfortunately (again) only BackGroundColor and ForeGroundColor can be changed there, no way to change one of $host.privatedata colors there.
Is there possibility to put hex coded color via script somehow?
there is a registry hack here : http://stackingcode.com/blog/2011/11/14/zenburn-powershell
In my view, Powershell should allow you to set colors to a rgb hex value rather than the predefined set of colors. But design questions aside, the way I worked around this was to create a .reg file to redefine the "color buckets" (which they call ColorTables) that Powershell uses. The code below includes comments indicating what the specific ColorTable controls in Powershell.
Notes:
To save your current colors first, open regedit and export HKCU\Console.
Save the code below to a file (e.g. colors.reg), and run it.
Create a shortcut pointing to powershell. Run it. It should have new colors.
To modify colors, set the appropriate ColorTableXX dword to the hex value, but note, the RGB values are actually BGR, and they need to be padded with 00 in front of the number. So a blue color, #4286f4, would have a dword of 00f48642.
colors.reg:
Windows Registry Editor Version 5.00
[HKEY_CURRENT_USER\Console]
; BACKGROUND
"ColorTable07"=dword:00efefef
; ERROR BACKGROUND
"ColorTable00"=dword:00efefef
;ERROR
"ColorTable12"=dword:00255ffc
; STATIC TEXT (PROMPT and OUTPUT) AND COMMAND ARGUMENT
"ColorTable01"=dword:00472713
; COMMAND TEXT
"ColorTable14"=dword:00c56e36
; COMMAND TEXT SELECTED
"ColorTable09"=dword:00ef47d3
; COMMAND FLAG
"ColorTable08"=dword:00a53733
; COMMAND FLAG SELECTED
"ColorTable15"=dword:00ef47d3
; COMMMAND ARGUMENT SELECTED
"ColorTable06"=dword:00ef47d3
; COMMAND VARIABLE (e.g. $profile)
"ColorTable10"=dword:00a53733
; COMMAND VARIABLE SELECTED
"ColorTable13"=dword:00ef47d3
; deep purple -- not sure what this is
"ColorTable04"=dword:00660566
; brown -- not sure what this is
"ColorTable05"=dword:00336699
; purple -- not sure what this is
"ColorTable11"=dword:00845f84
; green -- not sure what this is
"ColorTable02"=dword:00339933
; pastel lavendar -- not sure what this is
"ColorTable03"=dword:00FF9999

can i modify the color of emacs mini buffer?

i like emacs in terminal,but the blue color of mini buffer is hard to see clearly.
really need it,thanks for help!
Try this,
(set-face-foreground 'minibuffer-prompt "white")
If you can't stand your terminal's blue color, you can probably change it. The different terminal emulators have different tools for this, but most use X resources.
My own personal color choices for urxvt:
URxvt.background: #000000
URxvt.foreground: gray75
URxvt.color3: DarkGoldenrod
URxvt.color4: RoyalBlue
URxvt.color11: LightGoldenrod
URxvt.color12: LightSteelBlue
URxvt.color7: gray75
URxvt.colorBD: #ffffff
URxvt.colorUL: LightSlateGrey
URxvt.colorIT: SteelBlue
URxvt.cursorColor: grey90
URxvt.highlightColor: grey25
But of course, your own terminal emulator of choice may have a different class (URxvt) or application (urxvt, not used in my example) name, and the resource names may be different as well. urxvt will use color names (from the server's rgb.txt file -- use xcolorsel(1) to see them in a handy application) or numbers, but other terminals may not be this flexible.
From my xterm(1) manpage, the colors and their numbers are:
0 black
1 red3
2 green3
3 yellow3
4 a customizable dark blue
5 magenta3
6 cyan3
7 gray90
8 gray30
9 red
10 green
11 yellow
12 a customizable light blue
13 magenta
14 cyan
15 white
If your terminal does use X resources, save your desired resources to a file (by convention named ~/.Xdefaults or ~/.Xresources) and use xrdb -merge <filename> to load your resources into the server. Then start your terminal again, and try it out.
If your terminal uses some other mechanism to configure color choices (perhaps it has a Preferences menu item or something similar), it will probably still have different colors listed somewhere, and you'll need to change colors 4 and 12 to change the blue color.
On the other hand, if you like the blue for everything except emacs, you can either try to get emacs to use a different color (no idea there, sorry), or you can run your terminal emulator with a different "class", so it will read different X resources. (xterm(1) has a -class parameter for this.)