{"id":9520,"date":"2021-06-10T11:33:29","date_gmt":"2021-06-10T09:33:29","guid":{"rendered":"https:\/\/www.consolvis.de\/?p=9520"},"modified":"2021-06-25T15:25:26","modified_gmt":"2021-06-25T13:25:26","slug":"beautify-your-windows-powershell-in-visual-studio-code","status":"publish","type":"post","link":"https:\/\/www.consolvis.de\/en\/blog\/beautify-your-windows-powershell-in-visual-studio-code\/","title":{"rendered":"Beautify your Windows PowerShell in Visual Studio Code"},"content":{"rendered":"[vc_row type=”in_container” full_screen_row_position=”middle” column_margin=”default” column_direction=”default” column_direction_tablet=”default” column_direction_phone=”default” scene_position=”center” text_color=”dark” text_align=”left” row_border_radius=”none” row_border_radius_applies=”bg” overlay_strength=”0.3″ gradient_direction=”left_to_right” shape_divider_position=”bottom” bg_image_animation=”none”][vc_column column_padding=”no-extra-padding” column_padding_tablet=”inherit” column_padding_phone=”inherit” column_padding_position=”all” column_element_spacing=”default” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” gradient_direction=”left_to_right” overlay_strength=”0.3″ width=”1\/1″ tablet_width_inherit=”default” tablet_text_alignment=”default” phone_text_alignment=”default” bg_image_animation=”none” border_type=”simple” column_border_width=”none” column_border_style=”solid”][vc_video link=”https:\/\/youtu.be\/ZqEsWxzv8yg” align=”center”][vc_column_text]\n
This is what your Visual Studio Code Terminal looks like when you have Oh My Posh<\/a> installed along with Posh-Git<\/a>, which provides the additional Git-specific metadata on the command line. The theme shown below is Slim. Oh My Posh is a custom prompt engine for any shell that allows you to customize the prompt string with functions or variables. This can be helpful and looks better to me, but is not a necessity. So be warned and follow the steps only if you also want an extended PowerShell in VS code.[\/vc_column_text][nectar_image_with_hotspots image=”9492″ preview=”https:\/\/www.consolvis.de\/wp-content\/uploads\/2021\/06\/VSCodeWindowsPowershell.png” color_1=”Accent-Color” hotspot_icon=”plus_sign” tooltip=”hover” tooltip_shadow=”none”][nectar_hotspot left=”2.2877040281901193%” top=”61.99653625488282%” position=”top”]Operating system[\/nectar_hotspot][nectar_hotspot left=”20.859557499142444%” top=”61.13716125488281%” position=”top”]Session[\/nectar_hotspot][nectar_hotspot left=”43.653301118283615%” top=”60.486114501953125%” position=”top”]Root[\/nectar_hotspot][nectar_hotspot left=”52.72267507565744%” top=”60.27778625488281%” position=”top”]Path[\/nectar_hotspot][nectar_hotspot left=”67.31140134246073%” top=”60.763885498046875%” position=”top”]Git[\/nectar_hotspot][nectar_hotspot left=”79.43105601347928%” top=”60.46006774902344%” position=”top”]Node.js version[\/nectar_hotspot][nectar_hotspot left=”90.57527884836168%” top=”61.21528625488282%” position=”top”]Time[\/nectar_hotspot][nectar_hotspot left=”91.22494206295123%” top=”87.13540649414062%” position=”top”]Execution time and return code[\/nectar_hotspot][nectar_hotspot left=”6.35041237330901%” top=”89.00173950195312%” position=”top”]Input[\/nectar_hotspot][\/nectar_image_with_hotspots][vc_column_text]\n First, you need to install Oh My Posh and Posh-Git. I assume that you already have Visual Studio Code and Git for Windows installed. Start Visual Studio Code and open PowerShell in the terminal.[\/vc_column_text][image_with_animation image_url=”9496″ animation=”Fade In” hover_animation=”none” alignment=”” border_radius=”none” box_shadow=”none” image_loading=”default” max_width=”100%” max_width_mobile=”default”][vc_column_text]Now enter the following commands in PowerShell. The first time you run the Install-Modules command, you will get a warning that you are downloading and installing things from the Internet, so follow the prompts accordingly.[\/vc_column_text][vc_raw_js]JTNDc2NyaXB0JTIwc3JjJTNEJTIyaHR0cHMlM0ElMkYlMkZnaXN0LmdpdGh1Yi5jb20lMkZ0c3RlY2tlbmJvcm4lMkY3NGQzMDQ3ZGM5OGE3MmI5YTRjMTYwNjE0YWQzMzhjZS5qcyUzRmZpbGUlM0RnaXN0ZmlsZTEudHh0JTIyJTNFJTNDJTJGc2NyaXB0JTNF[\/vc_raw_js][image_with_animation image_url=”9498″ animation=”Fade In” hover_animation=”none” alignment=”” border_radius=”none” box_shadow=”none” image_loading=”default” max_width=”100%” max_width_mobile=”default”][vc_column_text]Then run “code $PROFILE” in PowerShell. This command opens your PowerShell profile in Visual Studio Code. Enter the following lines in this file and save it.[\/vc_column_text][vc_raw_js]JTNDc2NyaXB0JTIwc3JjJTNEJTIyaHR0cHMlM0ElMkYlMkZnaXN0LmdpdGh1Yi5jb20lMkZ0c3RlY2tlbmJvcm4lMkY3NGQzMDQ3ZGM5OGE3MmI5YTRjMTYwNjE0YWQzMzhjZS5qcyUzRmZpbGUlM0RNaWNyb3NvZnQuUG93ZXJTaGVsbF9wcm9maWxlLnBzMSUyMiUzRSUzQyUyRnNjcmlwdCUzRQ==[\/vc_raw_js][vc_column_text]The use of “Slim” is optional. It is the name of a theme <\/a>and you can (and should!) choose the theme you are excited about and use the name of that theme here.[\/vc_column_text][vc_column_text]Now open a new PowerShell in the terminal and you will see the first change.[\/vc_column_text][image_with_animation image_url=”9500″ animation=”Fade In” hover_animation=”none” alignment=”” border_radius=”none” box_shadow=”none” image_loading=”default” max_width=”100%” max_width_mobile=”default”][vc_column_text]But something is still not quite right. You see a lot of question marks. These question marks represent characters that your current font does not support. Let’s fix that in the next step.[\/vc_column_text][vc_column_text]\n The font you are using does not have the extended powerline characters. These characters are what make the terminal look so awesome! Such fonts are available from Nerd Fonts<\/a>, for example. I am currently using FiraCode. Choose the font<\/a> you like and install one of the included mono fonts.[\/vc_column_text][image_with_animation image_url=”9502″ animation=”Fade In” hover_animation=”none” alignment=”” border_radius=”none” box_shadow=”none” image_loading=”default” max_width=”100%” max_width_mobile=”default”][vc_column_text]Now you need to use the installed font in Visual Studio Code for the terminal. To do this, open the command palette in VS Code (Ctrl-Shift-P) and select “Preferences: Open Settings (JSON)”. Add an entry for “terminal.integrated.fontFamily” here. For example, for the font used above, it looks like this: “”terminal.integrated.fontFamily”: “FiraCode NF”,”.<\/p>\n Save your settings and see the font directly in your terminal. If you just installed the font, you may need to restart VS Code.[\/vc_column_text][image_with_animation image_url=”9508″ animation=”Fade In” hover_animation=”none” alignment=”” border_radius=”none” box_shadow=”none” image_loading=”default” max_width=”100%” max_width_mobile=”default”][vc_column_text]You now have a prettified and enhanced Windows PowerShell in your Visual Studio Code terminal. Do you have any other tips for a nicer PowerShell in VS Code?[\/vc_column_text][\/vc_column][\/vc_row]\n","protected":false},"excerpt":{"rendered":" [vc_row type=”in_container” full_screen_row_position=”middle” column_margin=”default” column_direction=”default” column_direction_tablet=”default” column_direction_phone=”default” scene_position=”center” text_color=”dark” text_align=”left” row_border_radius=”none” row_border_radius_applies=”bg” overlay_strength=”0.3″ gradient_direction=”left_to_right” shape_divider_position=”bottom” bg_image_animation=”none”][vc_column column_padding=”no-extra-padding” column_padding_tablet=”inherit” column_padding_phone=”inherit” column_padding_position=”all” column_element_spacing=”default” background_color_opacity=”1″ background_hover_color_opacity=”1″ column_shadow=”none” column_border_radius=”none” column_link_target=”_self” gradient_direction=”left_to_right” overlay_strength=”0.3″ width=”1\/1″ tablet_width_inherit=”default”…<\/p>\n","protected":false},"author":2,"featured_media":9493,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3002],"tags":[],"yoast_head":"\nStep 1 – Installing Oh My Posh and Posh-Git<\/h2>\n
Step 2 – Install a suitable font<\/h2>\n