2022-10-09533 chars
Make executables with shebang
You can make a JavaScript or TypeScript file executable in the shell, with the shebang #!
With this JS file at ~/bin/sayHi.js:
#!node
console.log('Hi there!');You can execute it with:
chmod 744 ~/bin/sayHi.js
# instead of typing `node ~/bin/sayHi.js`
# you can just
~/bin/sayHi.jsAnd you can do similar things for TS files ~/bin/sayHi.ts:
#!bun run
console.log('Hi there from bun run!');Or shell script ~/bin/sayHi.sh:
#!zsh
echo "Hi there from zsh!"