Long story short, dollar-sign is a script and it enables you (being super lazy) to run command like:

% $ echo "Hello world"
# Hello world

% $ $ $ $ $ $ echo "Hello world"
# Hello world

Rather than getting:

% $ echo "Hello world"
bash: $: command not found
  O
  h
,NO!I
t i
s $
comma
  n d
n o t
foun
  d
  !

It reminds me of a trick like this:

$ alias %=
$ % % echo Hello World
Hello World

This shell alias does a similar thing, but for % (percentage sign). In Bash, $ (dollar sign) can’t be aliased. So this dollar-sign script fills in the gap, which is literally a one-liner:

#!/bin/sh
exec "$@"

I can’t recall when and where I read this trick, but at the time I read it, I wondered why I hadn’t thought about that, and went on doing some research about the prompt sign for example code, commonly one of $, #, and %. After that, I tried to use % whenever I remember.

A script can work around for both $ and %, alias can do %, but neither for #. Personally, I do believe % is the best option if you want to choose a prompt sign for example code, however, # seems to be safest. In the end, I just dropped everything I’ve learned, the script and alias, I didn’t think it’s a good idea to have them, still don’t.

Of course, I must remind anyone who is lazy, copy-and-pasting is not a good habit. However, who am I kidding? We all do that all the time. Yes, now we have dollar-sign, but try not to use it.

dollar-sign is written in POSIX shell script by Christian Bundy under “Free Public License,” it was born in late October, 2014.