I like geeking out on my local shell setup, and my dotfiles hold a few aliases I can't live without – ll, ni, nr and all these other two-character commands are deeply engrained in my muscle memory.
Today I learned that the alias command in Zsh also supports a -s flag which enables suffix aliases. As a result, this is a valid alias in Zsh:
You can "just run files" with a suffix alias without defining a command or making it an executable. After defining the alias above, executing index
But there's more! You can define a suffix alias for multiple file types, too. I added cat (aliased to bat on my machine) as the standard handling of the following file formats.
This functionality is pretty neat already, but there's more (even though it might be a bit of a hack). @_smhmd pointed out that he uses suffix aliases to save typing git clone when cloning a git repository. He pastes the repo SSH link into the terminal, and it's expanded to a proper clone command. Smart! 😲
Sign up to start every week with quick to read Web Development learnings, productivity tricks, useful GitHub projects, #devsheets and music that keeps you going.