Archive for the ‘shell’ Category

QuickJump: bookmark your directories and switch between them easily

June 30, 2019 Leave a comment

I made a little project that facilitates jumping between directories in the command line. You can find it here: . Visit the GitHub page for more info.


Categories: python, shell Tags: , , , ,

[shell] How to tell your distro version?

November 28, 2018 Leave a comment

I use two different Linux distros, Ubuntu and Manjaro. Both of them are great. My shell resource files (previously .bashrc, now .zshrc) are shared via Dropbox. However, sometimes I would like to differentiate my Ubuntu and Manjaro settings, within the same resource file. How to do that?

Here is what I use:

# DESKTOP_SESSION is "ubuntu" (for Ubuntu) or "xfce" (for Manjaro)
if [[ "$DESKTOP_SESSION" == "ubuntu" ]]; then
  alias files='dpkg-query -L'
  alias files='pacman -Ql'

Older solution
Before finding the environment variable DESKTOP_SESSION, I used this:

# return "ubuntu", "manjaro" (without quotes)
get_distro_name() {
  cat /etc/os-release | grep "^ID=" | cut -d= -f2

# usage:
# if [[ $(get_distro_name) == "ubuntu" ]]; then
#   alias files='dpkg-query -L'    # ubuntu
# else
#   alias files='pacman -Ql'       # manjaro
# fi
Categories: shell Tags: , , , , ,

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.