owenrusk.dev

dotfiles

shell, editor, ssh.

git clone https://owenrusk.dev/dotfiles.git

dotfiles / zsh/functions.zsh -rw-r--r-- · 546 bytes

 1 # make a directory and go into it
 2 mcd() { mkdir -p -- "$1" && cd -- "$1" }
 3 
 4 # up 3 is cd ../../..
 5 up() {
 6     local d=
 7     repeat ${1:-1} d+=../
 8     cd $d
 9 }
10 
11 # top of the current git repo
12 top() { cd "$(git rev-parse --show-toplevel)" }
13 
14 # unpack whatever this is
15 x() {
16     case $1 in
17         *.tar.gz|*.tgz) tar xzf $1 ;;
18         *.tar.xz) tar xJf $1 ;;
19         *.tar.zst) tar --zstd -xf $1 ;;
20         *.tar) tar xf $1 ;;
21         *.zip) unzip -q $1 ;;
22         *.gz) gunzip $1 ;;
23         *) echo "x: no idea what $1 is" >&2; return 1 ;;
24     esac
25 }