Files
30-seconds-of-code/articles/s/bash-alias-dollar-sign.md
Angelos Chalaris 5c913d20bd Reorganize snippets
2023-05-03 21:19:02 +03:00

980 B

title, shortTitle, type, tags, author, cover, excerpt, dateModified
title shortTitle type tags author cover excerpt dateModified
Tip: A bash alias for copying from the web Bash alias for copying from the web tip
git
configuration
chalarangelo capsule-coffee Many online resources prefix their terminal commands with a dollar sign. Luckily, we've got a solution to this small annoyance. 2023-03-05T05:00:00-04:00

If you've ever copied a terminal command from the web, chances are you've also copied the dollar sign ($) that precedes it. This is a small annoyance that many developers encounter almost daily, but it can be easily dealt with. All you need to do is add an alias for the dollar sign to your .bashrc or .zshrc file:

alias '$'=''

But what about variables? Aren't these prefixed with a dollar sign? This alias won't break your scripts, as aliases replace only the first word of each simple command. Simply put, the only dollar sign that will be replaced is the one at the beginning of the line.