📜  hanselman pretty prompt (1)

📅  最后修改于: 2023-12-03 15:15:28.192000             🧑  作者: Mango

Hanselman Pretty Prompt

Hanselman Pretty Prompt is a command-line interface (CLI) tool designed for developers who use the Windows platform. This tool was created by Scott Hanselman, a well-known developer and entrepreneur who has been working with Microsoft for over a decade.

Features

The main feature of Hanselman Pretty Prompt is its ability to customize the command prompt with various themes and visual styles. Some of the features available include:

  • Custom color schemes
  • Git branch and status information
  • Timestamps
  • Current directory display
  • Emoji support

These features make the command prompt more useful and visually appealing. Additionally, the tool includes several helper functions and command enhancements that can be used to simplify development workflows.

Installation

To install Hanselman Pretty Prompt, follow these steps:

  1. Install the Windows Terminal application (download from Microsoft Store or GitHub).

  2. Open the settings.json file for the Windows Terminal by pressing Ctrl+,.

  3. Add "Hanselman.PrettyPrompt" as one of the "schemes" of the "schemes" object, and "Hanselman.PrettyPrompt" as "colorScheme" of "profiles", like this:

{
    "schemes": [
        {
            "name": "Hanselman.PrettyPrompt",
            "background": "#000000",
            "foreground": "#bfbfbf",
            "cursorColor": "#bfbfbf",
            "black": "#000000",
            "red": "#ff1800",
            "green": "#53ff00",
            "yellow": "#ffd500",
            "blue": "#1478db",
            "purple": "#5f5fff",
            "cyan": "#5fd7ff",
            "white": "#ffffff",
            "brightBlack": "#4d4d4d",
            "brightRed": "#ff4b4b",
            "brightGreen": "#9dff6a",
            "brightYellow": "#ffe94a",
            "brightBlue": "#0092ff",
            "brightPurple": "#ff6cff",
            "brightCyan": "#00f6ff",
            "brightWhite": "#ffffff"
        }
    ],
    "profiles": {
        "defaults": {
            "colorScheme": "Hanselman.PrettyPrompt",
            "cursorShape": "vintage",
            "cursorColor": "#bfbfbf"
        },
        "list": [
            {
                "guid": "{YOUR-GUID-HERE}",
                "name": "Hanselman Pretty Prompt",
                "commandline": "powershell.exe",
                "fontFace": "Consolas",
                "fontSize": 10,
                "colorScheme": "Hanselman.PrettyPrompt",
                "historySize": 9001,
                "snapOnInput": true,
                "padding": "0, 0, 0, 0",
                "cursorShape": "vintage",
                "cursorColor": "#bfbfbf"
            }
        ]
    }
}
  1. Restart the Windows Terminal application.
Usage

Once Hanselman Pretty Prompt is installed, you can use it to customize your command prompt by adding the following line to your Microsoft.PowerShell_profile.ps1 file:

# Add this line to the PowerShell profile to enable Hanselman Pretty Prompt
Import-Module Hanselman.PrettyPrompt

This will enable the Hanselman Pretty Prompt tool and load the default theme. To customize the theme, you can use the Set-Theme function and pass in the name of the theme you want to use:

# Set the theme to "Dark"
Set-Theme Dark

This will change the theme to the "Dark" color scheme. You can also use the Get-Themes function to view a list of available themes:

# View a list of available themes
Get-Themes

Finally, you can use the about_Hanselman.PrettyPrompt command to view additional information about the tool, including a list of available commands and functions:

# View information about Hanselman Pretty Prompt
about_Hanselman.PrettyPrompt
Conclusion

Hanselman Pretty Prompt is a powerful tool that can help developers customize their command-line experience on the Windows platform. With its extensive customization options and wide range of features, it's definitely worth checking out.