Change colors in PowerShell
Committed recently discovered this shell. Immediately climbed to look for books that have already been translated and you can take them here. And everything seems to be fine, and the code is written, and easy integration with vsb-skipti, but, for some reason, draws me to Maldini Windows.
And so, it was decided to repaint the window PowerShell in standard color cmd and in parallel to configure startup custom functions and aliases. Also, slightly strained the input sentences with the word — PS, which, together with the color resembles the logo of Adobe Photoshop ( Nothing against Adobe does not have ).
so, the following information is exclusively for beginners.
First start the shell, we see the familiar window:

first, we will need permission to run certain scripts with a. ps1 extension.
You can check them by running the command:
the
The default policy is: Restricted, which prohibits the execution of any scripts.
There are three options.
1. Or to change policy in AllSigned and sign the scripts ( more can be read using the command get-help about_signing ).
2. Or amenity policy on RemoteSigned to allow all to run all scripts, except for downloaded from Internet.
3. Or to change policy in Unrestricted that allows you to run any scripts, except for downloaded, on the fulfilment of which will be asked.
I chose the second path, it is all the same safer. Therefore, change policy team:
the

Get the request for a policy change that you want to answer Y().
second, create a script that will be run with PowerShell:
the
The idea is that at this point it can pop up here this error:

But don't worry, the shell writes that there is no folder WindowsPowerShell in My Documents, create it and retry the command:

As we can see, create an empty file called Microsoft.PowerShell_profile.ps1.
Half the work we did. We have execute privileges on the scripts and created a script podgryzayuschie by default.
third, we need to learn to get and modify information about the shell.
Cmdlet Get-Host just after doing:

Property UI is actually an object, and if we introduce (Get-Host).UI, we will see that this object also has a property RawUI that contains the needed settings:
the

To change these settings, you can:
the
It is important, in order for modified settings displayed on the screen, we need to specify alias cls responsible for cleaning of the screen.
This, of course, all cool, but the settings are reset if you close the window, so we write them to a file, which is loaded with a shell at the start. Edit the file Microsoft.PowerShell_profile.ps1 like this:
the
Now, briefly on the code.
The first 4-d properties are responsible for configuring the window, after setting the properties, do the mandatory cleansing cls.
Cd $MyRoot; — is responsible for, in which directory when you load the shell we will be.
promt — standard modified function that is responsible for a string input. I removed PS and added your nick.
Save the file, restart the shell.
It looks like this:

And lastly, in the file Microsoft.PowerShell_profile.ps1 you can easily write your aliasy. For example
the
Thank you all, good luck in the development of this beautiful shell.
Article based on information from habrahabr.ru
And so, it was decided to repaint the window PowerShell in standard color cmd and in parallel to configure startup custom functions and aliases. Also, slightly strained the input sentences with the word — PS, which, together with the color resembles the logo of Adobe Photoshop ( Nothing against Adobe does not have ).
so, the following information is exclusively for beginners.
First start the shell, we see the familiar window:
first, we will need permission to run certain scripts with a. ps1 extension.
You can check them by running the command:
the
Get-ExecutionPolicy
The default policy is: Restricted, which prohibits the execution of any scripts.
There are three options.
1. Or to change policy in AllSigned and sign the scripts ( more can be read using the command get-help about_signing ).
2. Or amenity policy on RemoteSigned to allow all to run all scripts, except for downloaded from Internet.
3. Or to change policy in Unrestricted that allows you to run any scripts, except for downloaded, on the fulfilment of which will be asked.
I chose the second path, it is all the same safer. Therefore, change policy team:
the
Set-ExecutionPolicy RemoteSigned
Get the request for a policy change that you want to answer Y().
second, create a script that will be run with PowerShell:
the
New-Item -type file $PROFILE
The idea is that at this point it can pop up here this error:
But don't worry, the shell writes that there is no folder WindowsPowerShell in My Documents, create it and retry the command:
As we can see, create an empty file called Microsoft.PowerShell_profile.ps1.
Half the work we did. We have execute privileges on the scripts and created a script podgryzayuschie by default.
third, we need to learn to get and modify information about the shell.
Cmdlet Get-Host just after doing:
Property UI is actually an object, and if we introduce (Get-Host).UI, we will see that this object also has a property RawUI that contains the needed settings:
the
(Get-Host).UI.RawUI
To change these settings, you can:
the
(Get-Host).UI.RawUI.WindowTitle = “Window”
(Get-Host).UI.RawUI.BackgroundColor = “Black”
cls
It is important, in order for modified settings displayed on the screen, we need to specify alias cls responsible for cleaning of the screen.
This, of course, all cool, but the settings are reset if you close the window, so we write them to a file, which is loaded with a shell at the start. Edit the file Microsoft.PowerShell_profile.ps1 like this:
the
# We to Hell?! - Is't WorldCount!
# Change the window settings
(Get-Host).UI.RawUI.ForegroundColor="Gray";
(Get-Host).UI.RawUI.backgroundColor="Black";
(Get-Host).UI.RawUI.CursorSize=10;
(Get-Host).UI.RawUI.WindowTitle="WorldCount Console";
# Clear the screen
cls
# Display the greeting
echo " ";
echo "Hello, WorldCount!";
echo " ";
echo " ";
# Set the initial directory
$MyRoot = "C:\Shell\";
CD $MyRoot;
# Type of the input sentences
function prompt
{
"[WorldCount:] " + $(get-location) + "> "
}
Now, briefly on the code.
The first 4-d properties are responsible for configuring the window, after setting the properties, do the mandatory cleansing cls.
Cd $MyRoot; — is responsible for, in which directory when you load the shell we will be.
promt — standard modified function that is responsible for a string input. I removed PS and added your nick.
Save the file, restart the shell.
It looks like this:
And lastly, in the file Microsoft.PowerShell_profile.ps1 you can easily write your aliasy. For example
the
set-alias WeToFuck Get-Process
Thank you all, good luck in the development of this beautiful shell.