How can I write a function that Bash ignores $
in first of commands? I want this because sometimes when I paste a command from web it includes a $
in first character.
$ ls
should do ls
or $ grep 'foo'
should do grep 'foo'
.
This will not work because $
is not a valid function name.
function $ {
...
}
Create a file called $
somewhere on your $PATH
, e.g. in ~/bin
:
cd ~/bin
cat <<'EOF' > \$
#!/bin/sh
"$@"
EOF
Make it executable:
chmod 755 \$
And enjoy the madness:
$ ls -l
total 92
-rwxr-xr-x 1 thomas thomas 13 Jan 3 19:09 $
$ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ ls
total 92
-rwxr-xr-x 1 thomas thomas 13 Jan 3 19:09 $
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With