number of lines and columns of your terminal

November 16, 2018 Leave a comment
$ tput lines
$ tput cols

Of course, the values depend on your own settings.

I found it in the script, which adds snowflakes to your terminal. Really cool.

Related animated short film: Operation White Widow (2011).

In Nim, there are functions for these in the module terminal. See terminalWidth and terminalHeight.


grep something and show the surrounding lines too

October 24, 2018 Leave a comment

You grep a pattern but you also want to see the lines before and after.


$ cat file.txt | grep -C 1 pattern

It will also show one line before and one line after.

Categories: bash Tags:

[Nim] A URL shortener command-line app.

October 23, 2018 Leave a comment

This afternoon I wrote a URL shortener command-line application in Nim. It uses the URL shortener service.

You can find the project here: .

Categories: nim Tags: , , ,

[Nim] cross-compile under Linux to Windows

October 23, 2018 1 comment

You are under Linux, and you can produce an executable binary with the Nim compiler. However, you would like to produce a Windows EXE too. We want to stay under Linux and we want to produce the EXE on Linux. How to do that?

On Manjaro, I had to install this package:

$ yaourt -S mingw-w64-gcc-bin

It’s a cross-compiler that we’ll use for producing the EXE.

Let’s take a simple Nim source (hello.nim):

echo "hello windows"

Now cross-compile it:

$ nim --os:windows --cpu:amd64 --gcc.exe:x86_64-w64-mingw32-gcc --gcc.linkerexe:x86_64-w64-mingw32-gcc -d:release c hello.nim

And you get hello.exe .

$ file hello.exe
hello.exe: PE32+ executable (console) x86-64, for MS Windows

If you copy it on a Windows system, you can run it there without any problem. Or, you can also run it under Linux with wine :)

$ wine hello.exe
hello windows

I found this idea in the following blog post: Writing a 2D Platform Game in Nim with SDL2.

Update (20181028)
I found info about it in the official docs too:

browse your fonts easily

October 13, 2018 Leave a comment

I wanted to create a captioned image with Gimp and for this I was looking for a nice font. Under Manjaro I installed the package “aur/ttf-google-fonts-opinionated-git” and thus I got hundreds of fonts. How to visualize and browse them easily?

FontManager can do exactly this. Install the package “aur/” and launch the app. with the command FontManager. It looks similar to this:

On the left side click on a font, then use the down arrow to run through the fonts.

Categories: linux, manjaro Tags: , , ,

maximize a window

October 13, 2018 Leave a comment

In Manjaro (XFCE) it’s “Alt+F10”. In Windows it’s “Super key + up arrow”.

In Manjaro, you can find and edit all window manager shortcut keys from Menu → Settings Manager → Window Manager → Keyboard tab.

Originally, I wanted to figure out how to maximize a VS Code window (reddit question here).

moved from KeePassX to KeePassXC

October 13, 2018 Leave a comment

KeePassX served me very well in the last few years. It’s a password manager that keeps your usernames / passwords in an encrypted file and you only need to memorize just one master password.

KeePassXC is the community edition of KeePassX. From its FAQ: “KeePassX is an amazing password manager, but hasn’t seen much active development for quite a while. Many good pull requests were never merged and the original project is missing some features which users can expect from a modern password manager. Hence, we decided to fork KeePassX to continue its development and provide you with everything you love about KeePassX plus many new features and bugfixes.

I tried it and it could open my .kdbx database file without any problem. It has some nice changes compared to KeePassX so I think I’ll use this newer and fresher version. Just like KeePassX, it runs under Linux and Windows too.