27
Using alias of path in commands?
(piefed.social)
From Wikipedia, the free encyclopedia
Linux is a family of open source Unix-like operating systems based on the Linux kernel, an operating system kernel first released on September 17, 1991 by Linus Torvalds. Linux is typically packaged in a Linux distribution (or distro for short).
Distributions include the Linux kernel and supporting system software and libraries, many of which are provided by the GNU Project. Many Linux distributions use the word "Linux" in their name, but the Free Software Foundation uses the name GNU/Linux to emphasize the importance of GNU software, causing some controversy.
Community icon by Alpár-Etele Méder, licensed under CC BY 3.0
By default bash will only expand an alias if it's the first argument of the command (that is, the command itself).
It's probably not intended to use aliases this way, and there are probably better options for you.
However, there is a little trick you can do. If the alias command ends in a space, then bash will also check the next argument:
alias cd='cd 'Notice the trailing space after 'cd' in the alias definition.
alias docs='/media/docs'then,
cd docsshould work the way you expect.Another method would be to:
alias docs='echo /media/docs'Then you can do
The backticks will cause the shell to replace that portion with the output of the docs shell command, which will be expanded via the alias.
All that said, it's probably easiest just to use a link, like another commenter suggested.
Cursed knowledge.