cmd-colors-solarized icon indicating copy to clipboard operation
cmd-colors-solarized copied to clipboard

Can't figure out how to appy that to windows10 ubuntu bash

Open KwanWaiChung opened this issue 7 years ago • 22 comments

I don't know how to apply

" Copy the Set-Solarized*ColorDefaults.ps1 files to your profile directory, likely ~\Documents\WindowsPowerShell. Then add the following line of code to the end of your Microsoft.PowerShell_profile.ps1 or profile.ps1:"

to the windows 10 ubuntu bash, i tried to add that to the .bash_profile and .bashrc, but it can't recognize the line..

KwanWaiChung avatar Apr 08 '17 06:04 KwanWaiChung

Can't figure out to apply over anything on Windows 10 Build 15063.13

kshitijdeota avatar Apr 12 '17 06:04 kshitijdeota

Same. I have it all installed, I verified the script is being sourced (I also tried sourcing it directly). No colors are changing.

Edit: maybe some colors are changing. Kind of looks like the text background changed to black. But the theme is definitely not applying.

Windows build 15063.rs2_release.170317-1834.

andyleejordan avatar Apr 13 '17 18:04 andyleejordan

The theme cannot be applied to Windows 10 build 15063.138

andy-liu-9711 avatar Apr 17 '17 01:04 andy-liu-9711

Finally figured out how to make it work. The registry key should be set as HKEY_CURRENT_USER\Console%SystemRoot%_System32_bash.exe or HKEY_CURRENT_USER\Console%SystemRoot%_system32_cmd.exe instead of HKEY_CURRENT_USER\Console in the *.reg files. Also the command prompt or bash should be started via win + r instead of win + s, and then the theme configuration could be loaded successfully.

andy-liu-9711 avatar Apr 17 '17 08:04 andy-liu-9711

Thanks @andy-liu-9711 . As you said, it only works if I spawn bash with win-r. Why does it matter if I run it from win-r, win-s or win?

mxtopher avatar Apr 19 '17 06:04 mxtopher

@mxtopher when you run win-s it will use the shortcut to open the application. with win-r you run the command.

To get Bash on Ubuntu on Windows to use the correct color scheme you have to re-create the Shortcut. A shortcut seems to save the color setting in the shortcut. It does not respect the settings from the registry.

  • Target: C:\Windows\System32\bash.exe ~
  • Icon Location: %USERPROFILE%\AppData\Local\lxss\bash.ico

Besides of recreating the shortcuts you also have to add the registry key suggested by @andy-liu-9711 [HKEY_CURRENT_USER\Console%SystemRoot%_System32_bash.exe]

OliverMartini avatar Apr 20 '17 14:04 OliverMartini

@OliverMartini may I ask how to create a shortcut with the color setting in it?

spiedeman avatar May 07 '17 09:05 spiedeman

@spiedeman; At the time a Windows Shortcut is created, the then current color settings are used. Therefore the shortcuts for Windows PowerShell, Bash on Ubuntu on Windows, etc. which were created at install time, still use the "old" color settings.

After you applied the new color settings, simply remove/delete the shortcuts form the Windows Start Menu and recreated them.

e.g. Replace Windows PowerShell shortcut

  1. Open Windows Explorer
  2. Navigate to %USERPROFILE%\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Windows PowerShell
  3. Delete Windows PowerShell shortcut
  4. Right click and choose "New > Shortcut" from context menu
  5. Use "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe", and click Next
  6. Name it "Windows PowerShell" and click Finish.

These are the steps to recreate the shortcuts to use the new color profiles. Do the same for Ubuntu Bash, Cmd Prompt, etc. shortcuts.

OliverMartini avatar May 08 '17 10:05 OliverMartini

@andy-liu-9711 it looks like github markdown may be causing the registry key location to not render correctly.. what is shown is missing a backslash. The full locations I found to work are:

HKEY_CURRENT_USER\Console\%SystemRoot%_system32_bash.exe HKEY_CURRENT_USER\Console\%SystemRoot%_system32_cmd.exe

ajb3ck avatar May 10 '17 19:05 ajb3ck

If we take the change with #19, it should resolve this. The shortcut link is what dictates the color scheme and the change provides a way to easily apply different color schemes to a .lnk file.

rbeesley avatar Jun 23 '17 04:06 rbeesley

Thank you for the theme it is so much nicer, currently on bash with the dark theme; the folders are highlight with a gray box, is there a way to remove the highlight box and just use a different color font instead ? Also it seems to apply to the default user and not root under bash

StephaneKazmierczak avatar Jun 28 '17 18:06 StephaneKazmierczak

@StephaneKazmierczak, you will still probably want to apply the Solarized .dir_colors to match. Right now I'm using dircolors.256dark from seebi/dircolors-solarized. Clone the dircolors-solarized project then link ~/.dir_colors to the appropriate dircolors theme. Then in your ~/.bashrc run this: eval "$(dircolors -b ~/.dir_colors)". This will give you a Solarized bash instance.

Each user needs to apply this though, so if you su root, you will get the same thing you see now.

The dircolors.256dark theme takes advantage of the increased color capability of the improved console. So it is what I recommend. I also then created my own prompt based off some .bash_prompt which was "Heavily inspired by @necolas's prompt".

I just source this at the end of my ~/.bashrc by executing: . ~/.bash_prompt.

rbeesley avatar Jun 28 '17 19:06 rbeesley

I remember having done that successfully while i was still using a full linux os, Now I just follow the configuration you gave on my windows10/ubuntu hybrid and there was no effect, is there an additional step ?

StephaneKazmierczak avatar Jun 29 '17 19:06 StephaneKazmierczak

No, I can't think of anything. Do you see 256 colors when you run this script?

rbeesley avatar Jul 10 '17 19:07 rbeesley

the script failed :-en \e[38;5;{0..256}m {0..256} \e[0m script_color.sh: 14: script_color.sh: arithmetic expression: expecting primary: "({0..256} + 1) % 10"

StephaneKazmierczak avatar Jul 10 '17 21:07 StephaneKazmierczak

@StephaneKazmierczak How are you launching Bash? If you're using the Bash shortcut that existed before you applied the registry file, try launching "bash" directly from Run / Windows + R.

What shell are you using? I can't reproduce that script failing.

Thynix avatar Jul 27 '17 11:07 Thynix

@Thynix I found that the {} in the for loop is not working in the windows bash bash version is 4.3.48(1)

StephaneKazmierczak avatar Jul 28 '17 17:07 StephaneKazmierczak

I used sh command that was my problem, now I can see the colors and numbers

StephaneKazmierczak avatar Aug 02 '17 17:08 StephaneKazmierczak

does anyone know how to save the font setting for bash on windows 10?

spiedeman avatar Aug 04 '17 07:08 spiedeman

Also I found that coloring of the folder work on remote machine without any config when I ssh on my server the shell get the right color for folder and not highlight also using shortcut or from the run> bash.exe get me the same results

StephaneKazmierczak avatar Aug 10 '17 22:08 StephaneKazmierczak

@StephaneKazmierczak Did you manage to fix the highlighting of the folder names?

I'll answer myself.: @rbeesley solution above fixes the folder names color.

persep avatar Feb 18 '18 09:02 persep

C:\repos\cmd-colors-solarized>regedit solarized-dark.reg worked for me without any editing. Note sure it was required but I used an 'admin' command prompt. All versions latest general release as of today.

ajostergaard avatar Nov 04 '18 16:11 ajostergaard