Hacker News new | ask | show | jobs
by uxcn 3841 days ago
It's useful to be able to write functions for your shell. For example, I have a function up, which moves up n dirs.
1 comments

I wrote this function for my .bashrc as soon as I read this.
(defun eshell/up (n) (dotimes (i n) (cd "..")))
I use pup a lot too, which just prints the dir.
Zsh has quite a nice option "auto_cd". If the first word you type doesn't resolve to a command, it tries to change the current working directory to it instead. So just typing ~ will get you to $HOME, and .. will take you up one.
I love this option. I type "/tmp" when I'm about to create some short-lived scratch files. Those saying "you can just alias that" are missing the point. Where do you stop with the aliases?
At one point I had ".." aliased to one directory up, "..." to two, and so forth. For navigating I found that preferable to cd ../../.. etc.

    alias '..=cd ..'
    alias '~=cd "$HOME"'
Yes. Although you get it for free with Zsh where it works with any directory you type. Not just the ones you think to make an alias for beforehand. :-)