KISS 🇺🇦

Stop the war!

Stop the war in Ukraine! Fuck putin!

More information is at: https://war.ukraine.ua/.

There is a fund to support the Ukrainian Army: https://savelife.in.ua/en/donate/, and there is a special bank account that accepts funds in multiple currencies: https://bank.gov.ua/en/about/support-the-armed-forces. I donated to them. Please donate if you can!

Killer putin

Killer putin. Source: politico.eu.

Arrested putin

"It hasn't happened yet, but it will happen sooner or later. Beautiful photo, isn't it?" Source: twitter.

Decent terminal on Windows

| comments

Yes, you’ve read the title right! It’s possible to some extent.

Working on some projects on windows, I still needed to use at least git. As the preferred way of interacting with it is via the command line, there was a necessity to set up a proper console there. Strange enough, there isn’t much information about configuring the stuff on the internets. The default windows’ cmd.exe shell and the terminal emulator are horrible, if you’ve ever used a linux shell (such as bash or zsh), so those are dead end. I needed something like yakuake from KDE or iTerm2 on OS X, which have the crucial feature of one-button appearance and disappearance.

As a git distro I use portablegit on windows, which comes with the bash shell.

I’ve come up with a setup based on the solution here: http://blog.errorok.com/2009/05/26/168/. You’ll need AutoHotkey_L (regular, old AutoHotkey should work as well), Console2, and QuakeTerminal.ahk script.

First of all, get Console2 to, say, e:\portable\Console2\ directory. If you run it now, you’ll get the standard, very poor cmd.exe command interpreter, but in a better looking and more functional terminal emulator.

Ctrl-D, Ctrl-D,… doesn’t work here, at least exit works.

Now we’re connecting it with portablegit (download a file with name like PortableGit-1.7.11-preview20120710.7z). Unpack the archive in e:\portable\portablegit\ directory. Running git-bash.bat will give you the standard, very functionally limited terminal emulator, but with much more powerful bash command interpreter (that everybody knows in Linux and other UNIXes).

Ctrl-D. Better, but not quite what we want yet. Digging more…

An important line in the git-bash.bat file is marked with the :startbash label:

1
call %COMSPEC% /c %BIN%bash --login -i

which runs the shell. Now, run Console2 again, go to Settings (Ctrl-S), the Console category on the left has Shell: field to the right. Put the path to bash.exe file there, \portable\portablegit\bin\bash --login -i in our case. Restart the program, and bash will be loaded inside. Much better!

A few more tweaks are required to make it look more like a real drop-down terminal, without those fancy toolbars, menus, and window decorations. In Appearance / More, deselect Show menu, Show toolbar, Show status bar, and Show scrollbars. In Styles section, turn off Caption, Border, and Taskbar button as well. Unfortunately, Resizable option leaves an ugly border around the window, so I had to deactivate it too. Here’s what I got:

Another addition, you can expand the area for the terminal by setting bigger Window size, to something like 138x38. Fine, we’ve configured the terminal emulator, and one thing left, namely setting a hotkey for instant access to it.

That’s where AutoHotkey_L comes into play. Unpack the executable file to e:\portable\ directory. Drop the QuakeTerminal.ahk file into the same dir:

AutoHotkey script for fast access to console (QuakeTerminal.ahk) download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
last_active_window := 0
#WinActivateForce

; Change your hotkey here
F12::

DetectHiddenWindows, on
IfWinExist ahk_class Console_2_Main
{
  IfWinActive ahk_class Console_2_Main
    {
          WinHide ahk_class Console_2_Main
          WinActivate ahk_id %last_active_window%
      }
  else
    {
      WinGet, last_active_window, ID, A
      WinShow ahk_class Console_2_Main
      WinActivate ahk_class Console_2_Main
    }
}
else
{  
  WinGet, last_active_window, ID, A
  Run Console2\Console.exe
}

DetectHiddenWindows, off
return

To run the script, you need to pass its filename to the interpreter. To simplify the matters, here’s a quick and dirty startup batch file:

Startup script (QuakeTerminal.bat) download
1
start AutoHotkey.exe QuakeTerminal.ahk

The hotkey is specified in the .ahk file, F12 by default. So, you start the .bat file, press the hotkey, and after a while the Console with bash inside appears. Another hotkey press, and it’s gone…

That’s all for today, folks! This lifehack allowed to me survive in the not very friendly windows environment for some time. git works there, and so does vim. If you have any comments, share them!

dev, git, windows

Note: The comments in the blog are provided by disqus.com; if you don't see the comment form under the post, probably your browser or its extension (such as uBlock Origin or NoScript) blocks their scripts.

« Jenkins and Qt To tailgate and to piggyback »

Comments