How To Create Files Faster in Visual Studio Code With a Command

How To Create Files Faster in Visual Studio Code With a Command

Creating files using a mouse on Visual Code seems like a lot of work so I mostly use UNIX commands; mkdir to make directories and touch to make files.

But the touch command only works when the file directory(s) (destination) exist(s).

So we will create a bash-alias to create a file and create the directory(s) from the path if they do not exist.

For instance:

[command] src/components/App.ts

# should create
- src/
    -- components/
         -- App.ts
  • create a shell script and paste this code into it:

function t() {

while [[ $f =~ $regex ]]; do
    mkdir $temp -p

touch $temp$f    
  • enable running commands from the file by adding it to bash aliases using this command below:
source ./path/to/your_bash_alias_file

# mine, for instance
source /temp/scripts/
  • Now, we can make use of t to created files and automatically create the paths to the file even if they do not exist:
t src/components/App.js


The alias we created above is temporal only for testing the script out. To create an alias permanently add the alias to your .bashrc file.

And I also published an npm package to make use of the t command. by installing it globally with

npm install-g touch-alias.

Please, kindly star the repository if you find this helpful and leave a comment.