24
loading...
This website collects cookies to deliver better user experience
$
character (e.g. $ npm install whatever
) to signal that the code block is a shell command. And when you're like me, you always copy and paste the $
sign with the command, leading to a command not found: $
error in your terminal.$
sign or paste the command into your terminal and remove the dollar manually. There has to be a better way...$
command that behaves like a proxy on your command line. The $
command simply runs all passed-in arguments.$ echo "hello world"
leads to an executed echo "hello world"
. $ ls
is basically the same as ls
. You get the idea. 🙈 $PATH
configuration. The $PATH
environment variable defines where executable files are located on UNIX systems. $PATH
. 👇$ echo $PATH
/usr/local/bin:/usr/local/sbin:/Users/stefanjudis/bin:/Users/stefanjudis/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
$PATH
is a long string that separates all different locations by a :
. And as you see, I have various bin
directories. All my custom commands are placed in my home's .bin
directory – ~/stefanjudis/.bin
. I chose this location because I don't want to mix system and custom commands (ls
, cat
, etc. are located at /bin
).$ pwd
/Users/stefanjudis/.bin
$ ll
.rwxr--r-- 14 stefanjudis 8 Dec 2020 -- $
.rwxr-xr-x 413 stefanjudis 2 Aug 2020 -- git-delete-branch
.rwxr-xr-x 183 stefanjudis 19 May 22:03 -- git-pr-select
.rwxr-xr-x 538 stefanjudis 17 Dec 2020 -- git-select
$
in this directory. Yep, that's right, this file doesn't include a file extension or something – it's really just a dollar. chmod 755 $
. chmod
command before, make sure to read up on "UNIX file permissions".#!/bin/zsh
exec "$@"
zsh
binary – #!/bin/zsh
. #!/bin/bash
works fine, too. exec "$@"
runs and expands all the passed-in parameters. And that's all the magic already! $@
to avoid parameter expansions.$ echo "hello world"
and all these "dollar commands" in your terminal. 🎉24