Tag Archives: utils

Using ncdu to examine disk usage

du has been my go-to tool for checking disk usage and it’s wonderfully simple. But I’ve been using ncdu for a few weeks now.

ncdu is short for NCurses Disk Usage. In addition to being able to visualize disk usage by directory, it lets you sort on different parameters, delete files, show hidden files, and a few more stuff that you’ll miss if you go back to plain du. Most importantly it acts as a file manager, so you can simply enter the directories to see a more fine-grained breakdown of file sizes. As an added bonus it has Vim keybindings along with normal arrow key movements.

ncdu - ncurses disk usage

Screenshot of ncdu + help popup

Installation:

brew install ncdu # macOS
sudo apt-get install ncdu # Ubuntu/debian

Installing rupa/z

z is a command-line tool that would make jumping around your favorite directories much, much faster. It sits in the background and monitors where you cd to often, like a creep. 😯 And whenever you need to change to that ~/pictures/lol/cats directory, all you have to type in is z cats and you’ll be there. How it achieves this feat is by overriding the default cd‘s functionality with a custom shell function. Bad, bad z. 😈

Install rupa/z somewhere in your $PATH, say ~/bin.

cd ~/bin
curl -O https://raw.githubusercontent.com/rupa/z/master/z.sh
chmod +x z.sh
source z.sh

You might get a ‘no such file or directory’ error the first time, just ignore that. z works in both bash and zsh. You might need to add the source ~/bin/z.sh line in your .bashrc or .zshrc so it starts up with your shell session.

Update:

Optionally, you can install the z man page as well. Jump to a directory in your MANPATH (you can find these using the command man -w) and download the man file.

cd /usr/local/man/man1
sudo curl -O https://raw.githubusercontent.com/rupa/z/master/z.1