Microsoft Build 2019 has just finished and some very exciting announcements were made among some of them is the new Windows Terminal which is described as:
a new, modern, fast, efficient, powerful, and productive terminal application for users of command-line tools and shells like Command Prompt, PowerShell, and WSL.
They even created a video that is quite the marketing effort and I have to admit it, it's looking quite nice.
You can see the presentation at Microsoft Build here: Windows Terminal: Building a better command line experience for developers and you can see more details on this blog post: Introducing Windows Terminal
Too little too late?
There is no doubt about too late because we know we haven't had a decent built-in terminal in windows, all we had is the Windows command prompt which is already ~30 years old and while it does it works it's not a tool where you want to spend your time in. The team working on it have added some basic improvements to it but is still a long way from most terminals especially the ones available on UNIX systems and we certainly can not customized as it is possible on UNIX and if you have used something like oh my zsh you will know cmd it just miles away from that but is this new terminal too little? We will know for sure once it fully released in around June.
You also have Powershell as an option and even tho it has been the favorite for many Windows SysAdmins for developers is not that great, why hasn't this be a priority for Microsoft? Well... I can't tell for sure but on the past Dotnet developers have been mostly using IDE(Visual Studio) for development and you normally had eveything you needed there.
Do we need a good console application on Windows?
Such was my case when I started doing Django development, coming mostly from a DotNet background I opted to stay on Windows to do Django development everything was going well except for cmd I was doing my pip installs, creating virtual environments, generating and running migrations and even running the application on the console and cmd was just not good enough. So I set myself to find a decent console for Windows that would provide me a better experience.
Console application available for Windows
If you do a google search for alternatives on Windows you will find many options available for you, and one that you probably already have is you are a software developer is git bash which is normally included on the Git installer for Windows and no doubt it' a great improvement it allows you to execute Unix style commands it also provides you with commands such as ssh, scp, cat, etc and in addition, it has great auto-complete for git commands however there are a few things that are missing.
- 1. Tabs and Split Views
- 2. Better keyboard shortcuts support
- 3. Better looks and more customizable options
So what choices do we have? actually, a lot since many people have felt the need for a better console application in Windows, just to mention a few Taken from Slant.co
I'm in an agreement with results in Slant since I also went for cmder -- pronounced “Commander” it provides exactly what I wanted, I really like the default styles and if you don't you can customize it, it also provides great split views and great keyboard shortcuts
Tabs and Split Views
Great keyboard shorcuts
Unix Style CommandsThese are actually a gift from git for Windows and not cmder itself however cmder can take advantages of them and use them and if case you are new to the console world on Windows I want you to be aware of the goodies available
ls to list the folders and file names in the current working directory and you can actually use the variety of flags available
touch have you ever tried to create a
.someNamefile on Windows? it could be troublesome but you can use touch for quickly create empty files and update the modification date on existent files eg:
cat to concatenate and quickly check the contents of a file directly on the console.
rm for deleting files and folder use it with
-rto recursively delete subfolders and
-fto force my most typical use for this is
rm -rf node_modules😅
ssh, ssh-keygen and ssh-add For accessing remote servers, the lack of using ssh
as I was able to use it on Linux is probably the biggest reason I have cursed Windows, having to deal with PuTTY and it's utilities
was a nightmare to me in comparison with using ssh on Linux, and to my surprise many people still think PuTTY is the only way to use ssh
on Windows, but we actually have two ways to use ssh just like on Linux now, one that comes with git for Windows an open ssh client that now
comes built in on Windows 10 so Putty is no longer your only option if you need to ssh into a server. If you want to check which ones you have available you can
- Ctrl + t you are probably already familiar with this short cut since it's used to open a new tab on browsers and on cmder it does exactly the same so it is easy to get used to it.
- Ctrl + w close the current tab
- Alt + Enter Full screen
Ctrl + Alt + u Same as typing
cd ..and hitting enter on the console it allows you to quickly traverse up in the directory structure
Ctrl + r Have you ever typed and execute any command with so many parameters that is hard to remember and you didn't save it? this shortcut has saved me
many times since it allows you to do a reverse search
Copy & Paste
- Copy just select/highlight the text that you would like to copy and you have copied the selected text
Paste you can simply right click to paste the text on the clipboard or use
Ctrl + shift + v
Git auto complete just type something like
git coand hit tab and it will autocomplete
git commitfor you it can even suggest commands for you when there is more than one autocomplete options try something like
git chethen hit tab twice and you will see something like:
Git info right there on the console
AliasesThis is probably the feature I love the most because of much it has increased my productivity and how simple it is to use it. The following is a list of a few commands that I've used pretty much on a daily basis.
- python manage.py runserver
- python manage.py makemigrations
- python manage.py migrate
- dotnet run
- cd source/repos/somerepo
- rm -rf node_module && npm install
- git fetch && git checkout somebranch
- git commit -m "my commit comment"
You can see some of them are a bit long with Alias I can create shorthands for all of these and it's as simple as
alias djrun=python manage.py runserver
where djrun is the alias you would like to use for me is dj from Django and run of running the server so now I can just type
djrun which it's a lot less typing
python manage.py runserver and you even get autocomplete for your aliases too.
I can do similar things for my other commands, one that I find very helpful is creating an alias my accessing my repositories
alias gotopesite=cd C:\Users\LuisPalacios\source\repos\personal-site this way no matter where I'm in my directory structure
I can just type
gotopesite hit enter and I'll be immediately in my repository.
What about when you need an alias that supports an argument such as
git commit -m "this should be an argument"
you can easily accomplish that using
$* wherever you want your alias to receive an argument so in my case it can
be something like this
alias gtcommit=git commit -m "$*" and then I can use it like this:
gtcommit this my example comment
There is a lot more you can do with alias and you can find more details on the official docs in cmder on the links I shared but hopefully this is enough to get you started.
This one also helps a lot with productivity, because you can create your own custom startup task, let's take a look at what I normally need to do when working on my personal site which is build on Dotnet Core but it also uses Nodejs tools for building the front-end such as Webpack.
- 1. A command line tab for handling my git commands
2. A command line running my site
3. A command line watching and building my front-end files
npm run watch
Not to mention, I need to navigate to my repository directory in order to run these commands, so the manual steps I would need to do every time I want to work on my personal site would look like the following:
1. Open cmder and navigate to my repository directory
2. Open a new split tab to the right, navigate to my repository and run
3. Open a new split tab to the bottom, navigate to my repository and run
npm run watch
That is a lot of repetitive work, even using aliases is still annoying, cmder has an option like internet browsers that you can save and re-open all the same tabs you had every time you close and open cmder.
That might be everything you need if you only work in a repository, but if you are like me and you need to work on multiple repositories through the day this isn't that good because if you try to keep open all the tabs for all the repository that you need, the navigation through the tabs becomes more difficult not to mention you would be wasting precious RAM.
So it would be great if I can just tell cmder "Open everything I need to work on my Personal Site" that is exactly what I can do trough Startup tasks, I'm going to define my own custom Startup task to work on my personal site
1. Open cmder and go to settings
Win + alt + pthen go to Startup -> Tasks and click the "+" button.
2. Now we need to tell cmder exactly what we want our task to do, there is a lot we can do here you can see more about it here ConEmu’s Tasks
however this can be overwhelming if you are new to this console emulator world, cmder has an awesome feature that pretty much allows us to tell it "Save my current tabs as a new task"
so all we need to do is define whatever name you want to identify your task and click on Active tabs.
3. This will create a task that will open all of the tabs I need on with the split views I have defined and on the directory where I need them, however, it won't run any command
when is started but adding that is pretty simple I just append at the end of each command
&& mycommandand I also need to define task parameter which in my case I just copy and paste from the task cmd::Cmder. Make sure you click Save Settings.
4. Now whenever I open cmder I can
ctrl + tto open a new tab and you will see that my new task is listed there and if I selected it, it should open all the tabs and run the commands that I want in order to work on my personal site repository
That is a great improvement however, we can take it one step further, I can actually pin my new task to the windows taskbar. I've already had my cmder pinned to my taskbar but if I right click it all I see is the option to open cmder or unpin it from the task bar.
In order to add the new task to the taskbar we need to follow the next steps.
1. Open settings and go select your task and make sure the checkbox Taskbar Jump list is active, you can also go through the task list and remove this check for the task
that you don't want to appear on the taskbar
2. On the settings windows go to General -> Taskbar and make sure the checkboxes Add ComEmu Task and AutoUpdate are active then click the Update now button and then save settings
3. Now for our last step, execute the command
ConEmu.exe /updatejumpliston a cmder tab.
With this, I'm ready to open everything I need on my command line in order to work on my Personal Site repository with just a right click and a click
Is there a catch?
cmder just like many other options for a better console on Windows is an emulator so this mean performance could be affected, on older versions, I did notice the startup time was slower than starting cmd or PowerShell but I also had older hardware, now that I have better hardware (i7 and SSD) I don't notice any performance problems.
What do you think? are you excited about the new Windows Terminal? do you think cmder is a great option while we wait for it? What have you been using as your go-to console on Windows? let me know in the comments below.