Friday, April 19, 2024
HomePowershellSQLAdm.in — PowerShell and SQLServer

SQLAdm.in — PowerShell and SQLServer


Introduction

When you’ve got adopted together with me earlier than, chances are high you realize I like coloration.
Coloration helps me zoom in on the data I need sooner.
Coloration can assist me know if I’ve the suitable variety of curly braces.
Trendy browsers and phrase processors present a pink squiggly line if you misspell a phrase.
Your eye is drawn to that little bit of coloration that’s completely different than the remainder of the web page.
Maintain studying and I’ll present you the right way to add some spice to your PowerShell expertise.

Defaults

On first login to a Home windows machine, your PowerShell console goes to be plain.
You’re going to see the standard white textual content on a blue background.
When you or your group have put in PowerShell 7, you’ll see a black display screen with white textual content.

Opening up the properties and looking out beneath the colour tab, you possibly can see a row of sixteen colours as proven beneath.

These are the values the console makes use of for displaying colours by title.
When you run Write-Host "Check" -ForegroundColor Pink, the console will use the this worth to show the textual content in pink.

The identical goes for the usual ANSI colours.
The names don’t match up fairly proper.
Right here’s a desk with customary names for each.

Console Coloration Identify ANSI Coloration Identify Console Coloration Identify ANSI Coloration Identify
White Vibrant White DarkBlue Blue
Grey White DarkGreen Inexperienced
Blue Vibrant Blue DarkCyan Cyan
Inexperienced Vibrant Inexperienced DarkRed Pink
Cyan Vibrant Cyan DarkMagenta Magenta
Pink Vibrant Pink DarkYellow Yellow
Magenta Vibrant Magenta DarkGray Vibrant Black
Yellow Vibrant Yellow Black Black

Again earlier than I obtained a lot into customizing my immediate, I nonetheless went in and adjusted the background to black and adjusted the worth of black from 12,12,12 to 0,0,0.
One thing to notice right here.
The sixteen coloration decisions are tied to the 4 radio buttons above them for “Display Textual content”,“Display Background”,“Popup Textual content” and “Popup Background”.

To vary a coloration worth you’ll want to pick that coloration, change it after which decide the colour for that radio button.
For instance if I’ve “Display Background” chosen and it’s set to black, I can click on on inexperienced to alter the values for inexperienced, however I want to return and choose black once more earlier than clicking okay so my background doesn’t change to inexperienced.

Colours

So by now you’ve observed which you could change colours round however it’s not very handy.
You’ll be able to mess around with the colour packing containers, or if you wish to give your self a headache you possibly can edit the values within the registry saved in HKCU:Console.

ColorTool

You’re not alone in wanting coloration and to keep away from the ache.
Microsoft launched a program appropriately named
ColorTool as a part of the Home windows Terminal undertaking on GitHub.
This software means that you can rapidly change between coloration schemes.

Console Coloration Schemes

ColorTool comes with a handful of coloration schemes so head over to
https://iterm2colorschemes.com/ and flick through over 250 coloration schemes.
One of many issues I’ve run into when messing with coloration palettes, is both the parameter names or values shall be too darkish to see.
I then have to determine which coloration is getting used there and modify it to one thing I can see higher.

One other good useful resource talked about within the ColorTool README, is
https://terminal.attractive.
Right here you possibly can visually modify colours to see what works.

Home windows Terminal

If you’re utilizing Home windows Terminal you get a plain black display screen.
With Home windows Terminal, you’re already arrange for utilizing coloration schemes.
There are just a few to choose from with a brand new set up.

Home windows Terminal Coloration Schemes

Adjusting the colours for a theme is way nicer in Home windows Terminal.
The colours aren’t tied to the 4 perform colours.
Clicking on a coloration brings up a pleasant coloration picker.

If you wish to add a coloration scheme, it will get rather less straightforward,
Go to
https://windowsterminalthemes.dev/ and browse for a theme that you simply like.
Subsequent click on on the “Get theme” button.
This copies the JSON to your clipboard.
Now within the Window Terminal settings Coloration schemes tab click on on the “Open JSON file” button within the decrease left nook.

As soon as in your JSON editor of selection, scroll all the way down to the “schemas” part.
Paste your clipboard contents between the left sq. bracket and the left curly brace.

Scroll all the way down to the tip of what you simply added and add a comma after your proper curly brace.

Mac and Linux

With PowerShell on Linux or Mac, your expertise is determined by your terminal of selection.
For MacOS I like to recommend
iTerm2.
Virtually all of my Linux interplay is thru ssh, so I don’t have a desktop advice.

Nerd Font

Nerd Fonts is a group of fonts which have included tons of additional glyphs from standard ‘iconic fonts’ reminiscent of Font Superior, Devicons, Octicons, and others.
Obtain the fashion of font you need and set up it.
This requires administrator entry in Home windows.
For console work I’d decide one of many monospace fonts.
I made my selection based mostly on how O,0,g,G,q & 1 seemed.
I like with the ability to inform the distinction between a ‘one’ and a lowercase L or a zero and capital O.

I’ll let you determine the right way to change the font in your atmosphere.
I’ve used Nerd Fonts in VSCode, Home windows Terminal, Home windows PowerShell, Home windows PowerShell ISE and PowerShell 7 (on Home windows and Mac).

Looking the “cheat sheet” on Nerd Fonts web site you will discover the icon you need and seize the hex code within the backside proper nook.
[char]0xf5ea will show the icon.
I prefer to put the icons I need in a PSCustomObject to simply reference

    
        
$nf=[PSCustomObject]@{
# nerdfont icons
cake=[char]0xf5ea
greenback=[char]0xf155
bang=[char]0xf12a
mail=[char]0xf003
}
    

Terminal Icons

After you have picked out your font (I went with Bitstream Vera Sans Mono), it is best to set up the Terminal-Icons module.
It provides icons to a ton of file sorts in addition to colorizing to the output of Get-ChildItem.

Right here’s a earlier than and after.

You’ll want so as to add Import-Module -Identify Terminal-Icons to your $PROFILE

Conclusion

As you possibly can see there a numerous methods to fairly up your PowerShell window.
Mess around.
Experiment.
Most significantly, have enjoyable.

Thanks for studying.
-Jeff

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments