snippetjavascriptTip
A bash alias for copying commands from the web
Viewed 0 times
webfromaliasbashcommandsgitthecopyingfor
Problem
If you've ever copied a terminal command from the web, chances are you've also copied the dollar sign (
But what about variables? Aren't these prefixed with a dollar sign? This bash 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.
$) 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:But what about variables? Aren't these prefixed with a dollar sign? This bash 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.
Solution
Implementation for A bash alias for copying commands from the web:
See the code snippet for the complete implementation.
alias '
See the code snippet for the complete implementation.=''See the code snippet for the complete implementation.
Code Snippets
alias '$'=''Context
From 30-seconds-of-code: bash-alias-dollar-sign
Revisions (0)
No revisions yet.