Because I am new to Windows I was wondering if using Git with PowerShell was realistic. Coming from Linux Git works well with the *nix toolset because it was designed around it. When I use Windows I was hoping it likewise reliably. The Git for Windows package does include a Bash shell and a number of *nix tools; to use Git though with the native tools would make me feel better.
The regular PowerShell has to be used. PowerShell ISE is for making scripts and some programs will only run on the regular PowerShell (e.g. Vim for instance). If PowerShell ANSI colors are desired to be edited they have to be done so manually as theme support is only available to PowerShell ISE.
Here are the Properties I edit:
Options Command History Buffer size to 1000, easy for processor to do Command History Discard Old Duplicates Text Selection Enable line wrapping selection Layout Screen Buffer Size Height to 8000 or large number Screen Buffer Size Wrap text on resize
PowerShell configuration create:
test-path $profile # config. existance test new-item -itemtype file -path $profile # config. creation
(Warning: After I created the profile I tried text redirection to add text to the file. This led me on a long path learning about file encoding. Text redirection uses the
Out-File cmdlet that uses the system’s current ANSI code page for encoding which is UTF-16LE with BOM for most Windows users now. Since I am mainly a Linux user I use UTF-8 without a BOM. The only help that appears to be reasonable to use UTF-8 without a BOM is to use this function but this will create Windows line endings. Using a regular text editor appears to be the only solution for me. More can be read about it here.)
Scripts to be run on Windows require that the ExecutionPolicy allow them. The profile is considered a script. The current execution policy can be obtained by typing
Get-ExecutionPolicy. The execution policy help pages can be viewed by typing
help about_signing. I choose to use
RemoteSigned where only remote scripts have to be signed:
I edited some of PowerShell’s varibles it sets for command coloring:
[enum]::GetNames([System.ConsoleColor]) # colors available print $host.ui.rawui # colors fore/back-ground print $host.ui.rawui.foregroundcolor = "Green" $host.privatedata # colors for errors print $host.privatedata.errorbackgroundcolor = "Blue" get-psreadlineoption # syntax highlighting colors print set-psreadlineoption -tokenkind comment gray
PowerShell and Vim color ties
Vim is a good text editor to work with Git for me. I hope to be able to continue using it. However, PowerShell uses unique ANSI colors and I lacked the know-how to map together Vim’s and PowerShell’s (like this other user). PowerShell itself is only a 16 color terminal which is good enough with a good Vim colorscheme. I edited the shell’s colors (in Properties) to match the *nix’s ANSI colors (this post) shows how they line up). My Vim colorschemes look better now but how Vim is handling the background color and maybe some other things unexpectedly and the colorschemes look off still. I have yet to resolve this.
- executable installer download
- installation options:
Vim executables # gvim and runtime files are likely desired Vim console # vim.exe for console version _vimrc # configuration with many basic settings plugin directrys native lang # english default (for other languages) .bat files # vim shortcuts... unrecognized in PowerShell
- installation location can be for allusers or local (e.g.
C:\Program Files (x86)\Vimor
$HOME\AppData\Local\). I recommend local as configuration files can be tucked there and because local data can only be edited by the local user.
For Vim to be recognized in PowerShell I create an alias (allusers may install
Set-Alias vim "C:\Program Files (x86)\Vim\vim80\vim.exe". I be recognized every time PowerShell is launched I added it to the
I also created a hackish $MYVIMRC setting so UTF-8 is used. Here is how it works: UCS [Unicode Character Set] is used as part of UTF-8 and UTF-16, so I set the characters that Vim uses to UTF-8).
fileencoding can now be left blank for discovery and will adopt
&encoding (UTF-8) otherwise:
if has ("multi_byte") if &termencoding == "" " characters the keyboard uses, null=basic of $enc let &termencoding = &encoding endif set encoding=utf-8 " characters that Vim uses setglobal fileencoding= " encoding of the file, null=discovr else=encoding "setglobal bomb " byte-order-mark used for discovery, leaves mark endif
When installing Git I used all the default settings.
After the install, I was able to use Git normally. I had wondered if Git would be tied to a number of *nix tools for it to be able to function: thank goodness it appears from all uses I have done that it can run on its own. I am happily using Git from PowerShell now.