A simple bash function to help you "go up" from the current working directory.
This saves you the energy you'd otherwise spend on typing cd followed with a
bunch of .. (dot dot). Laziness is the mother of invention.
- Put the contents of this repository in a directory.
- Source
gup.shfile in your shell to get thegupcommand. - Source
gup-completion.shfile in your shell to gettabcompletion.
Run gup --help to see the man page.
# In ~/.bashrc or equivalent.
source /path/to/gup/gup.sh
source /path/to/gup/gup-completion.shgup is intended to be used with a numeric or a string target (argument).
# Running "gup 3" is the equivalent of cd ../../..
/a/b/c/d $ gup 3 # Goes to: /a
# Running "gup b" takes you to the nearest directory in the current working
# path with the name "b".
/a/b/b/c/d $ gup b # Goes to: /a/b/bFor a given target, gup checks if an ancestor directory a matching
exists. If yes, then the user is taken there. If not, then it tries to treat
the argument as an integer and attempts to take the user \fTARGET\fP levels
above the current directory.
If the argument is numeric and an ancestor directory with a matching name
exists, then you go up to that ancestor directory. However, you can force the
argument to be treated as a number with the --number or -n flag.
/a/2/c/d/e $ gup 2 # Goes to: /a/2
/a/2/c/d/e $ gup -n 2 # Goes to: /a/2/cIf you don't know where you want to go, you can use the interactive mode
using the --interactive or -i flag.
/a/2/c/d/e $ gup -i
Choose a destination directory:
1) d
2) c
3) 2
4) aForgot your commands? Worry not! Run gup --help to see a man page.
This little program was written for having fun some with bash. However, it
turned out to be something useful which I regularly use. Feel free to use it
and leave your suggestions!
Brought to you by Jigarius.