Wednesday, 21 June 2017

bash - .bash_profile alias with variables





I'm trying to create an alias that will create a file and open it in VS Code.



Create an alias called create that will execute touch && code .



For example create app.js should execute touch app.js && code app.js.



Answer



From man bash, under ALIASES:




There is no mechanism for using arguments in the replacement text. If arguments are needed, a shell function should be used (see FUNCTIONS below)."




Thus:



create() { touch "$1"; code "$1"; }


No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...