Archive

Posts Tagged ‘zsh’

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: https://github.com/jabbalaci/quickjump . Visit the GitHub page for more info.

Demo

Categories: python, shell Tags: , , , ,

[shell] How to tell your distro version?

November 28, 2018 Leave a comment

Problem
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?

Solution
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'
else
  alias files='pacman -Ql'
fi 

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: , , , , ,