git console: changing brach interactively

Some time ago I wrote about some helpful script that let me copy branch name without mouse. Later on I wrote about some simple console menu in Powershell. The second one seems to be a far better option here. Here’s the code:

#uncomment if you don't have ps-menu (powershellget is needed)
#install-module ps-menu -scope currentuser

$selection = menu (iex "git branch")
if ($selection -ne $null)
    $branch = $selection.Trim(" ", "*")
    iex "git checkout $branch"

Here is how it works:



Console aliases in Windows – the better approach

A big advantage of working in console mode is ability to create aliases. First you can easily shorten a command with a lot of switches. You can also automate your job by creating a script file and then set an alias for that script.

The default way of creating aliases in Windows is DOSKEY:

doskey np=notepad++.exe $*

The weak point of it is that you have to reassign them after restarting console window. There are ways for automating that using cmd.exe /k switch or using system
registry (see both article and comments).

There is also a buil-in option for ConEmu:

But all in all this is weak, as always you have to do two things: establish an
alias and then save it in some file for future use.

Alternative (better!) solution

I can sell you my way of dealing with aliases. I don’t use DOSKEY. Instead, I have a folder, i.e. C:\Tools\Aliases and there. I have a lot of *.cmd or *.ps1 files. The trick is that the folder is in my PATH variable.
Let’s say I have there a !notes.cmd command that runs:

vim c:\documents\notes01.txt

Then I can type ‘!notes’ and it runs “!notes.cmd” file that results in openning my temporary notes file. Obviously TAB autocompletion works fine. ‘!’ in the beginning lets me filter out my own aliases. I have also “!editaliases.cmd” for editing my aliases:

vim c:\tools\aliases\

Aliases are ready to use just after adding/editing them.
Other advantages:

  • no fancy escape characters (doskey defines its own list)
  • I can assing a whole script to an alias with one file
  • works in every console and emulator

Circular-style TAB behaviour in Cmder (like in cmd.exe)

For a long time I was addicted to ConEmu terminal-replacement. Nowadays I use
amazing cmder that is simply preconfigured Conemu + extensions. Nevertheless there is one very annoying thing that I didn’t like: TAB behavior. Instead of
simple circular-style autocompletion (like in cmd.exe) it stopped on the last
common character and then showed the list of matches (like in Linux).
It turned out that it is all because of clink – one of ConEmu’s extensions. As
it is very customizable, you can easily override it to behave just like in
the default Windows terminal. Authors predicted that and the configuration is already there, ready to uncomment.

In order to do that:
1. Find \vendor\clink folder in CMDER installation path
2. Open clink_inputrc_base file for editing
3. Uncomment lines 67 & 68 as following


Powershell, tools

Simple interactive console menu in Powershell

Personally I am a kind of console-freak. If possible, I would do everything in terminal. But in my case loving terminal is not about remembering all the different switches and options of console commands, but rather presenting things in a simple, readable manner, without fireworks. And most of all, navigation must be fast and comfortable. That’s why I prefer choosing options from simple menu than getting through command documentation and juggling with switches/parameters. That’s the course set out by yeoman for example.

I tried to find an easy way of building command-line menus but I couldn’t so I ended up with my own solution. It’s based on Powershell. I’m sharing it here in case you wanted to use it as well.

As we all know a picture is worth a thousand words:

You can still find the code on github:

The script is really short but the best way you can use it is to install it
with PowerShellGet from

install-module -name ps-menu

You can also copy-paste the code from ps-menu.psm1 file in case you wanted to have everything in one place.

tools, Web

Go to recent tab in Chrome

For a long time I have been searching for such feature in Chrome, but I could not find anything default. And it was difficult to understand, as it is so obvious for a developer. Windows has it (Alt + Tab), Resharper has it (Ctrl + ,), visual studio without plugins has it, same to Sublime Text, vim etc. But not Chrome, a default development tool for most of web developers. At the same time there are extensions, but most of them work far from what I expect. Below I would like to share what useful I have found. Both are fine, but for sure not flawless.

Ctrl + Tab MRU


This is the one I like the most. I have it bound to Ctrl + comma. That means that a combination Ctrl + comma, comma take me to the second recently used tab. It’s obvious, but actually this is the first extension I have found, that supports it.

The bad? Several times it had problems to render the list correctly. On the other hand I tried to reproduce it while writing this blog post and I couldn’t.

Quick Tabs


This one is more advanced, as it allows to search in usage history, recently closed and bookmarks. Unfortunately Ctrl + comma, comma, comma does not work as expected (but still it’s worth to have because of searching functionality).

What about you?

Do you have your own solution for that? I would really like to know if there is something better or at least if there is another useful alternative.

tools, Uncategorized

Vim for .NET – flickering omnicomplete problem

Since the beginning of my journey with vim I have experienced a problem with flickering screen. After a several tries with Google it turned out that it’s mostly about vim omnicomplete, and even more specifically Omnisharp-vim preview functionality.

In order to get rid of the flickering, you need to change the default omnisharp switch:
set completeopt=longest,menuone,preview
set completeopt=longest,menuone

The consequences are that you will not see the details of selected item in preview window, but actually I have never used it (since what’s shown in the menu is enough).


Vim for .NET – Move type to another file

When I started my journey with VIM for .NET, I tried to find VIM alternatives of common shortcuts/refactorings that I used in Visual Studio. Surprisingly I noticed that most of them were already there (Searching, Go To Definition, Find usages, create class etc). The one I had a real problem with was “Move type to another file”. I really like the idea that I can create all the types in one file and then use some shortcut (with ReSharper: Alt + Enter) to distribute them to their own files. As I could not find any existing plugin (which is really strange) I took it as a good time to try myself in writing vimscript. It turned out that it was pretty easy exercise. Here you can find the script that you can append to _vimrc to enable the feature.

function! ExtractClassToFile() abort
    " copy class name
    execute "normal! ?^.*\\sclass\\s\0/class\wviwy"
    " and store for future use (filename)
    let className = getreg('"')

    " cut class code and store it inside default register
    execute "normal! ?^.*class\V/{\%x"	
    " and store for future use
    let classText = getreg('"')
    " copy namespace + usings
    execute "normal! ggv/namespace \/{\ly"
    let usingAndNamespace = getreg('"')
    " get filename for the new file
    let currFileLocation = expand('%:p:h')
    let newFileName = "\\".className.".cs"
    let newFileFullPath = currFileLocation . newFileName
    " open the new file
    execute "e ".newFileFullPath

    " render the file
    let failed = append(line('$'), split(usingAndNamespace, '\n'))
    let failed = append(line('$'), split(classText, '\n'))
    let failed = append(line('$'), '}')

    " remove empty line in the beginning
    execute "normal! dd"
    " save
    execute "w"

noremap ef :call ExtractClassToFile()