A Better Powershell Console with Cmder (ConEmu) and PsReadLine

cmder_powershell
We’re making a better console. All of them, better consoles.

I don’t think I have to tell any Windows administrator that Powershell, while not perfect, is a God send compared to the old cmd days. But, my biggest gripe with Powershell has always been that its console (frankly) sucks compared to modern Linux terminals. And, the PS console has a very limited range of customization in terms of colors, fonts, tab completion, etc.

Trying to “natively” hack away at the console can be less than ideal from my experience. This is why ConEmu (or the prefab ConEmu setup Cmder) is the best solution I have seen thus far. It even allows you to attach easily to putty via something like putty -new_console

But, ConEmu and Cmder are both designed to improve the traditional CMD experience. Although a powershell session within ConEmu/Cmder are inherently better, it still lacks some things like Linux-style tab completion, coloring, location concatenation, etc.

This is where PsReadLine comes in. Assuming you’re running Powershell v3+, will allow us to manipulate the prompt, rebind hot keys, and customize coloring.

Font

A quick, personal few of my favorite mono spaced fonts:

$Profile Changes

Thanks to reddit user ataraxia_ for his great psreadline config (via comment). I only made a few modifications to do some very basic checks.

This (psreadline) does require Powershell v3.

Acclimation

ConEmu has a pretty good wiki, but I’ll throw in some basics (assuming you’re using Cmder, which has some of its own defaults set) for those previously living in powershell.exe

  • Win+Alt+P – Open Preferences
  • CtrL+` – Focus on Console
  • CTRL+t – New tab
  • CTRL+w – Close tab
  • Alt+Enter – Fullscreen
  • Shift+Mouse – Select text from buffer

Tabs

If you want to elevate the tab you’re in (run as admin) you can just right-click the tab

003

You also get more ‘run as’ options in the new tab window

004

You can setup the task (as seen below) to run the new console tab as admin always, but I prefer manual elevation. Sometimes, it’s fun in non-privileged land.

Personally, I like to set something like F2 to rename tabs to keep them organized.

cmder_rename

 Tasks

Cmder comes with both a “Cmd” and “Powershell” task, but you can easily create your own. If you click Add default it will populate with a lot of tasks including one for Chocolatey, ANSI, etc.

002

You can also change the default startup task.

005

Console Splits (psuedo tmux)

There is support for split screen functionality (and of course with keybinds). Notably, when you open a new console (default Ctrl+T) you have the New Split option (right or bottom).

cmder_tmuxLike

 

One comment on “A Better Powershell Console with Cmder (ConEmu) and PsReadLine

  1. PSReadLine is not a prerequisite to change your shell prompt… Just write a ‘prompt’ function.

    Also, C-style for-loops are ugly and less readable than a range. You should change it to For ($i in 1 .. $lvl) { ... }

1 Pings/Trackbacks for "A Better Powershell Console with Cmder (ConEmu) and PsReadLine"

Leave a Reply

Your email address will not be published. Required fields are marked *