News for hackers. Stuff that matters.
Re:ZSH Aliases by gpspake on Tuesday May 26, 2020 @08:17AM (#23310169)
I think I might be able to help with this one! Here's a little trick I learned from a friend. It's also tab completable.

I keep all my code in ~/code

$ c # cd to ~code

$ c pr<tab> # tab complete to c projectname

$ c projectname # cd to ~/code/projectname

This is pretty simple in zsh

# c to cd to ~/code

c() { cd ${CODE_DIRECTORY}/$1; }

# tab complete c against code

_c() { _files -W ${CODE_DIRECTORY} -/; }

compdef _c c

(Note: CODE_DIRECTORY is just an env var for ~/code)

I use this all the time and I use h to do the same for my home directory

https://github.com/gpspake/dotfiles/blob/master/zsh/gpspake/...

There are no comments on this comment yet.