Starship for Command Prompt on Windows 11

In a follow-up to my previous post Starship prompt for PowerShell & WSL on Windows 11, I’ll show how to configure Starship for the good old native Windows shell cmd.exe.

These instructions assume you have already configured Starship as per my previous blog post. If not, follow those instructions first before proceeding.

Can I really customise the humble Windows shell cmd.exe?

Yes you can! Here’s mine, which looks almost exactly like my PowerShell and WSL instance;

Command Prompt

Customising the Command Prompt using Starship is achieved using a tool called Clink.

The first step is to install Clink, which is as simple as opening Windows Terminal and running the following PowerShell;

scoop bucket add main
scoop install main/clink

Add the following to a file called starship.lua and save in a Clink scripts directory:

-- starship.lua
os.setenv('STARSHIP_CONFIG', 'C:\\Users\\?\\.config\\starship\\starship.toml')
load(io.popen('starship init cmd'):read("*a"))()

Replace “?” with the relevant Windows “username” so that the path is valid, or modify the path to where you have your Starship TOML file saved. This means that the Command Prompt will use the same Starship configuration file as both your Windows Terminal AND WSL instance, ensuring consistency across all prompts!

And there’s more!

Clink as a powerful tool for customising the cmd.exe, including features such auto-suggestions, completions, persistent history and key bindings!

If you spend a lot of time using Command Prompt then take a look at the multitude of configuration options, but be careful you don’t conflict with customisations provided by Starship.

Wrap Up

All of the above code & config snippets are available on my dev-machine-configuration GitHub repo.

Conclusion

I hope this will be of help to you. Let me know if you have any suggestions for improvements in the comments.

Written on May 8, 2024

top