Last active
September 16, 2022 13:39
-
-
Save Adam--/fe311d75c20242fbed14841512fbd9eb to your computer and use it in GitHub Desktop.
Revisions
-
Adam-- revised this gist
Jul 12, 2021 . 1 changed file with 4 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,8 +1,7 @@ ### Windows Terminal Windows Terminal is a modern feature-rich open source terminal from Microsoft that runs many shells, including PowerShell. The easiest way to install it is from the [Microsoft Store](https://aka.ms/terminal). Go ahead and open Windows Terminal, which should default to PowerShell. Have a look around, it's already pretty awesome. There's support for multiple tabs, color schemes, custom fonts, custom shells, and more. We are going to customize it even further by setting up git support, customizing the prompt, installing custom fonts, setting the color scheme, and optionally adding a couple of extra tools. ### posh-git and oh-my-posh posh-git allows git information to be displayed within PowerShell and provides tab completion of git commands and branches. @@ -70,13 +69,14 @@ To set a theme go back to your PowerShell profile (or open it again with `code $ Set-PoshPrompt -Theme powerline ``` If some of the fonts look a little off, you might want to try a different Nerd Font. Some fonts simply look better than others. Also, if you don't find any additional value out of the oh-my-posh customization, I'd recommend uninstalling oh-my-posh with `Remove-Module oh-my-posh` and removing `Import-Module oh-my-posh` from your profile. ### Windows Terminal color schemes Windows Terminal ships with some pretty nice looking color schemes. To select one, navigate to Settings > Profiles > Windows PowerShell > Appearance > Color scheme. ### Adding the Git Bash shell Windows Terminal is not a shell, but rather a host. Out of the box it includes PowerShell and Command Prompt. If you'd like to setup a different shell, it's pretty straight forward. One way is to navigate to Settings and click the plus icon. Here you can setup your shell. Assuming Git for Windows is installed, you can add the Git Bash shell with the following >Name: Git Bash -
Adam-- renamed this gist
Jul 11, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes -
Adam-- renamed this gist
Jul 11, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Adam-- renamed this gist
Jul 11, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Adam-- revised this gist
Jul 11, 2021 . 1 changed file with 14 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,22 +1,22 @@ ### Windows Terminal Windows Terminal is a modern feature-rich open source terminal from Microsoft that runs many shells, including PowerShell. The easiest way to install it is from the [Microsoft Store](https://aka.ms/terminal). Open Windows Terminal, which should default to PowerShell. ### posh-git and oh-my-posh posh-git allows git information to be displayed within PowerShell and provides tab completion of git commands and branches. oh-my-posh is a prompt theme engine for PowerShell. To install these tools, run the following commands in PowerShell ```ps Install-Module posh-git -Scope CurrentUser Install-Module oh-my-posh -Scope CurrentUser ``` After installing posh-git and oh-my-posh, your PowerShell profile needs to be configured to load them on startup. You can get the location of your profile by executing `$profile` within PowerShell. Open this file with your favorite text editor, `code $profile`, and add the following lines: ``` Import-Module posh-git @@ -46,24 +46,25 @@ To set the execution policy to unrestricted, run Windows Terminal or PowerShell ``` Set-ExecutionPolicy Unrestricted ``` ### Nerd Font Nerd Fonts are extended fonts that provide additional glyphs. Many prompt themes in oh-my-posh use these fonts to display information. Themes that indicate that they are minimal typically do not require Nerd Fonts. At a minimum, I'd recommend installing [Cascadia Mono PL](https://github.com/microsoft/cascadia-code/releases). While this is not a Nerd Font, it does provide additional glyphs for most powerline style themes. For fuller experience choose your favorite font from https://www.nerdfonts.com/font-downloads. The default Windows Terminal font is Cascadia Mono and the Nerd Font version is Caskaydia Cove (at the time of writing this, there was only the normal weight available and it didn't seem to have all glyphs yet). You might also find familiarity in FiraCode and Inconsolata. I recommend FiraCode. To install a font, unzip the zip file, right click on the font file and click install. Install the versions that are marked Windows Compatible. Font file type doesn't matter much, but ttf font files are common for Windows. To configure Windows Terminal to use the font installed, navigate within Windows Terminal to Settings > Profiles > Windows PowerShell > Appearance > Font face, select the font you just installed and click save. If the font you installed isn't shown, close and reopen Windows Terminal and try again. ### oh-my-posh prompt themes Right now there is no theme set for oh-my-posh and PowerShell is showing a modified prompt from posh-git and looks something like `C:\Source\maui [main ≡]>`, which is already a big step up from the default `PS C:\Source\maui>`. However, oh-my-posh include a lot of prebuilt themes that can provide additional information and just make the prompt look fun. To get and preview all oh-my-posh themes run `Get-PoshThemes`. To set a theme go back to your PowerShell profile (or open it again with `code $profile`) and add the following line, replacing powerline with your theme of choice. ``` Set-PoshPrompt -Theme powerline @@ -82,7 +83,7 @@ Windows Terminal is not a shell, but rather a host. Out of the box it includes P >Command line: "%PROGRAMFILES%\git\bin\bash.exe" >Icon: %PROGRAMFILES%\git\mingw64\share\git\git-for-windows.ico Alternatively, you can click the settings icon after navigating to Settings. This will open a `settings.json` file. In the `profiles` `list` array add the following object ```json { @@ -92,11 +93,11 @@ Alternatively, you can click the settings icon after navigating to Settings. Thi }, ``` While it is out of the scope of this article, it is possible to customize the Bash shell with oh-my-posh in a very portable manner, check out https://ohmyposh.dev/ for more info. ### Quickly open .sln files If you find yourself opening .sln files from within PowerShell often, this [Open-Solution PowerShell module](https://gist.github.com/refactorsaurusrex/2a0d8efd88ceb30eb69488c1b11c7682) is very handy. Once installed, the module will search through the current folder and open the .sln file just by exectuing `sln`. If there are multiple .sln files, it'll list them all. No more need for the finger gymnastics of typing `**\*.sln` then tabbing though the results ### Enjoy! That's everything. Let me know if you found this helpful, if you ran into any issues or if you have any suggestions. -
Adam-- revised this gist
Jul 9, 2021 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
LoadingSorry, something went wrong. Reload?Sorry, we cannot display this file.Sorry, this file is invalid so it cannot be displayed. -
Adam-- revised this gist
Jul 6, 2021 . 1 changed file with 23 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -74,6 +74,29 @@ If you don't find any additional value out of the oh-my-posh customization, I'd ### Windows Terminal color schemes Windows Terminal ships with some pretty nice looking color schemes. To select one, navigate to Settings > Profiles > Windows PowerShell > Appearance > Color scheme. ### Adding the Git Bash shell Windows Terminal is not a shell, but rather a host. Out of the box it includes PowerShell and Command Prompt. If you'd like to setup a different shell, it's pretty straight forward. One way is to navigate to Settings and click the plus icon. Here you can setup your shell. Assuming Git for Windows is installed, you can add the Git Bash shell with the following >Name: Git Bash >Command line: "%PROGRAMFILES%\git\bin\bash.exe" >Icon: %PROGRAMFILES%\git\mingw64\share\git\git-for-windows.ico Alternatively, you can click the settings icon after navigating to Settings. This will open a `settings.json` file. In the `profiles` `list` array and the following object ```json { "commandline": "\"%PROGRAMFILES%\\git\\bin\\bash.exe\"", "icon": "%PROGRAMFILES%\\git\\mingw64\\share\\git\\git-for-windows.ico", "name": "Git Bash", }, ``` While, it is out of the scope of this article, it is possible to customize the Bash shell with oh-my-posh in a very portable manner, check out https://ohmyposh.dev/ for more info. ### Quickly open .sln files If you find yourself opening .sln files, this [Open-Solution PowerShell module](https://gist.github.com/refactorsaurusrex/2a0d8efd88ceb30eb69488c1b11c7682) is very handy. Once installed, this module will search through the current folder and open the .sln file just by exectuing `sln`. If there are multiple, it'll list them all. No more need for the finger gymnastics of typing `**\*.sln` then tabbing though the results ### Enjoy! That's everything. Let me know if you found this helpful or if you ran into any issues or if you have any suggestions. -
Adam-- revised this gist
Jul 3, 2021 . 1 changed file with 79 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,79 @@ ### Windows Terminal Install [Windows Terminal](https://aka.ms/terminal) from the Microsoft Store. Windows Terminal runs many shells, including PowerShell. There are many ways to install Windows Terminal, but the Microsoft Store is recommended. It has the benefit of keeping itself up to date. Open Windows Terminal, which should default to PowerShell. ### posh-git and oh-my-posh posh-git allows git information to be displayed within PowerShell and provide tab completion of git commands and branches. oh-my-posh is a prompt theme engine for PowerShell. Within PowerShell run the following commands ```ps Install-Module posh-git -Scope CurrentUser Install-Module oh-my-posh -Scope CurrentUser ``` Edit your PowerShell profile to load posh-git and oh-my-posh. You can get the location of your profile by executing `$profile` within PowerShell. Open this file with your favorite text editor, `code $profile`, and add the following lines: ``` Import-Module posh-git Import-Module oh-my-posh ``` Save the file and keep it open, we'll come back to it later when configuring these tools. ### PowerShell execution policy At this point if you run a new instance of PowerShell, you may get an error: ``` . : File C:\Users\~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 cannot be loaded. The file C:\Users\~\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:3 + . 'C:\Users\~\Documents\WindowsPowerShell\Microsoft.Powe ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess ``` PowerShell is setup to not allow executing the profile script that you created in the last step. The easiest way to get around this is to set the execution policy to unrestricted. This comes with some security risks. If you do not want to take on these risks, search for running signed scripts and signing your profile script. To set the execution policy to unrestricted, run Windows Terminal or PowerShell as Administrator and execute the following ``` Set-ExecutionPolicy Unrestricted ``` ### Nerd Font Nerd Fonts are extended fonts that provide additional glyphs. Many prompt themes in oh-my-posh uses these fonts to display information. Themes that indicate that they are minimal typically do not require Nerd Fonts. At a minimum, I'd recommend installing [Cascadia Mono PL](https://github.com/microsoft/cascadia-code/releases). While this is not a Nerd Font, it does provide additional glyphs for most powerline style themes. For fuller experience choose your favorite font from https://www.nerdfonts.com/font-downloads. The default Windows Terminal font is Cascadia Mono and the Nerd Font version is Caskaydia Cove (at the time of writing this, there was only the normal weight available and it didn't seem to have all glyphs yet). You might also find familiarity in FiraCode and Inconsolata. I recommend FiraCode. To install a font, unzip the zip file, right click on the font file and click install. Install the versions that are marked Windows Compatible. File type doesn't matter much, but ttf font files are common for Windows. Configure Windows Terminal to use the font installed by navigating within Windows Terminal to Settings > Profiles > Windows PowerShell > Appearance > Font face. Select the font you just installed and click save. If the font you installed isn't shown, close and reopen Windows Terminal and try again. ### oh-my-posh prompt themes Right now there is no theme set for oh-my-posh and PowerShell is showing a modified prompt from posh-git and looks something like `C:\Source\maui [main ≡]>`, which is already a big step up from the default `PS C:\Source\maui>`. However, oh-my-posh include a lot of prebuilt themes that can provide additional information and just make the prompt look fun. To get and preview all oh-my-posh themes run `Get-PoshThemes`. To set a theme go back to your PowerShell profile (or open it again with `code $profile`) and add the following replacing powerline with your theme of choice. ``` Set-PoshPrompt -Theme powerline ``` If you don't find any additional value out of the oh-my-posh customization, I'd recommend uninstalling oh-my-posh with `Remove-Module oh-my-posh` and removing `Import-Module oh-my-posh` from your profile. ### Windows Terminal color schemes Windows Terminal ships with some pretty nice looking color schemes. To select one, navigate to Settings > Profiles > Windows PowerShell > Appearance > Color scheme. ### Enjoy! That's everything. Let me know if you found this helpful or if you ran into any issues or if you have any suggestions. -
Adam-- created this gist
Jul 3, 2021 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ TBW