aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2020-11-12 15:24:14 -0300
committerEuAndreh <eu@euandre.org>2020-11-12 15:25:53 -0300
commitb7261a8dca68fc56a727afaac9a3b2d7812146be (patch)
treef1ee79fc9c79481687e512a029a8a60bd36847b4
parentAdd (first) building a database post (diff)
downloadeuandre.org-b7261a8dca68fc56a727afaac9a3b2d7812146be.tar.gz
euandre.org-b7261a8dca68fc56a727afaac9a3b2d7812146be.tar.xz
Add useful bash variables TIL
-rw-r--r--_tils/2020-11-12-useful-bash-variables.md70
-rw-r--r--locale/eo/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po88
-rw-r--r--locale/fr/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po88
-rw-r--r--locale/pt/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po88
4 files changed, 334 insertions, 0 deletions
diff --git a/_tils/2020-11-12-useful-bash-variables.md b/_tils/2020-11-12-useful-bash-variables.md
new file mode 100644
index 0000000..af83015
--- /dev/null
+++ b/_tils/2020-11-12-useful-bash-variables.md
@@ -0,0 +1,70 @@
+---
+
+title: Useful Bash variables
+
+date: 2020-11-12
+
+layout: post
+
+lang: en
+
+ref: useful-bash-variables
+
+---
+
+[GNU Bash][gnu-bash] has a few two letter variables that may be useful when
+typing on the terminal.
+
+[gnu-bash]: https://www.gnu.org/software/bash/
+
+## `!!`: the text of the last command
+
+The [`!!` variable][previous-command] refers to the previous command, and I find
+useful when following chains for symlinks:
+
+[previous-command]: https://www.gnu.org/software/bash/manual/bash.html#Event-Designators
+
+```shell
+$ which git
+/run/current-system/sw/bin/git
+$ readlink $(!!)
+readlink $(which git)
+/nix/store/5bgr1xpm4m0r72h9049jbbhagxdyrnyb-git-2.28.0/bin/git
+```
+
+It is also useful when you forget to prefix `sudo` to a command that requires
+it:
+
+```shell
+$ requires-sudo.sh
+requires-sudo.sh: Permission denied
+$ sudo !!
+sudo ./requires-sudo.sh
+# all good
+```
+
+Bash prints the command expansion before executing it, so it is better for you
+to follow along what it is doing.
+
+## `$_`: most recent parameter
+
+The [`$_` variable][recent-parameter] will give you the most recent parameter
+you provided to a previous argument, which can save you typing sometimes:
+
+```shell
+# instead of...
+$ mkdir -p a/b/c/d/
+$ cd a/b/c/d/
+
+# ...you can:
+$ mkdir -p a/b/c/d/
+$ cd $_
+```
+
+[recent-parameter]: https://www.gnu.org/software/bash/manual/bash.html#Special-Parameters
+
+## Conclusion
+
+I wouldn't use those in a script, as it would make the script terser to read, I
+find those useful shortcut that are handy when writing at the interactive
+terminal.
diff --git a/locale/eo/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po b/locale/eo/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po
new file mode 100644
index 0000000..c2b94f4
--- /dev/null
+++ b/locale/eo/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po
@@ -0,0 +1,88 @@
+#
+msgid ""
+msgstr ""
+
+msgid "title: Useful Bash variables"
+msgstr ""
+
+msgid "date: 2020-11-12"
+msgstr ""
+
+msgid "layout: post"
+msgstr ""
+
+msgid "lang: en"
+msgstr ""
+
+msgid "ref: useful-bash-variables"
+msgstr ""
+
+msgid ""
+"[GNU Bash](https://www.gnu.org/software/bash/) has a few two letter "
+"variables that may be useful when typing on the terminal."
+msgstr ""
+
+msgid "`!!`: the text of the last command"
+msgstr ""
+
+msgid ""
+"The [`!!` "
+"variable](https://www.gnu.org/software/bash/manual/bash.html#Event-"
+"Designators) refers to the previous command, and I find useful when "
+"following chains for symlinks:"
+msgstr ""
+
+msgid ""
+"$ which git\n"
+"/run/current-system/sw/bin/git\n"
+"$ readlink $(!!)\n"
+"readlink $(which git)\n"
+"/nix/store/5bgr1xpm4m0r72h9049jbbhagxdyrnyb-git-2.28.0/bin/git\n"
+msgstr ""
+
+msgid ""
+"It is also useful when you forget to prefix `sudo` to a command that "
+"requires it:"
+msgstr ""
+
+msgid ""
+"$ requires-sudo.sh\n"
+"requires-sudo.sh: Permission denied\n"
+"$ sudo !!\n"
+"sudo ./requires-sudo.sh\n"
+"# all good\n"
+msgstr ""
+
+msgid ""
+"Bash prints the command expansion before executing it, so it is better for "
+"you to follow along what it is doing."
+msgstr ""
+
+msgid "`$_`: most recent parameter"
+msgstr ""
+
+msgid ""
+"The [`$_` "
+"variable](https://www.gnu.org/software/bash/manual/bash.html#Special-"
+"Parameters) will give you the most recent parameter you provided to a "
+"previous argument, which can save you typing sometimes:"
+msgstr ""
+
+msgid ""
+"# instead of...\n"
+"$ mkdir -p a/b/c/d/\n"
+"$ cd a/b/c/d/\n"
+"\n"
+"# ...you can:\n"
+"$ mkdir -p a/b/c/d/\n"
+"$ cd $_\n"
+msgstr ""
+
+msgid "Conclusion"
+msgstr ""
+
+msgid ""
+"I wouldn't use those in a script, as it would make the script terser to "
+"read, I find those useful shortcut that are handy when writing at the "
+"interactive terminal."
+msgstr ""
diff --git a/locale/fr/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po b/locale/fr/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po
new file mode 100644
index 0000000..c2b94f4
--- /dev/null
+++ b/locale/fr/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po
@@ -0,0 +1,88 @@
+#
+msgid ""
+msgstr ""
+
+msgid "title: Useful Bash variables"
+msgstr ""
+
+msgid "date: 2020-11-12"
+msgstr ""
+
+msgid "layout: post"
+msgstr ""
+
+msgid "lang: en"
+msgstr ""
+
+msgid "ref: useful-bash-variables"
+msgstr ""
+
+msgid ""
+"[GNU Bash](https://www.gnu.org/software/bash/) has a few two letter "
+"variables that may be useful when typing on the terminal."
+msgstr ""
+
+msgid "`!!`: the text of the last command"
+msgstr ""
+
+msgid ""
+"The [`!!` "
+"variable](https://www.gnu.org/software/bash/manual/bash.html#Event-"
+"Designators) refers to the previous command, and I find useful when "
+"following chains for symlinks:"
+msgstr ""
+
+msgid ""
+"$ which git\n"
+"/run/current-system/sw/bin/git\n"
+"$ readlink $(!!)\n"
+"readlink $(which git)\n"
+"/nix/store/5bgr1xpm4m0r72h9049jbbhagxdyrnyb-git-2.28.0/bin/git\n"
+msgstr ""
+
+msgid ""
+"It is also useful when you forget to prefix `sudo` to a command that "
+"requires it:"
+msgstr ""
+
+msgid ""
+"$ requires-sudo.sh\n"
+"requires-sudo.sh: Permission denied\n"
+"$ sudo !!\n"
+"sudo ./requires-sudo.sh\n"
+"# all good\n"
+msgstr ""
+
+msgid ""
+"Bash prints the command expansion before executing it, so it is better for "
+"you to follow along what it is doing."
+msgstr ""
+
+msgid "`$_`: most recent parameter"
+msgstr ""
+
+msgid ""
+"The [`$_` "
+"variable](https://www.gnu.org/software/bash/manual/bash.html#Special-"
+"Parameters) will give you the most recent parameter you provided to a "
+"previous argument, which can save you typing sometimes:"
+msgstr ""
+
+msgid ""
+"# instead of...\n"
+"$ mkdir -p a/b/c/d/\n"
+"$ cd a/b/c/d/\n"
+"\n"
+"# ...you can:\n"
+"$ mkdir -p a/b/c/d/\n"
+"$ cd $_\n"
+msgstr ""
+
+msgid "Conclusion"
+msgstr ""
+
+msgid ""
+"I wouldn't use those in a script, as it would make the script terser to "
+"read, I find those useful shortcut that are handy when writing at the "
+"interactive terminal."
+msgstr ""
diff --git a/locale/pt/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po b/locale/pt/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po
new file mode 100644
index 0000000..c2b94f4
--- /dev/null
+++ b/locale/pt/LC_MESSAGES/_tils/2020-11-12-useful-bash-variables.po
@@ -0,0 +1,88 @@
+#
+msgid ""
+msgstr ""
+
+msgid "title: Useful Bash variables"
+msgstr ""
+
+msgid "date: 2020-11-12"
+msgstr ""
+
+msgid "layout: post"
+msgstr ""
+
+msgid "lang: en"
+msgstr ""
+
+msgid "ref: useful-bash-variables"
+msgstr ""
+
+msgid ""
+"[GNU Bash](https://www.gnu.org/software/bash/) has a few two letter "
+"variables that may be useful when typing on the terminal."
+msgstr ""
+
+msgid "`!!`: the text of the last command"
+msgstr ""
+
+msgid ""
+"The [`!!` "
+"variable](https://www.gnu.org/software/bash/manual/bash.html#Event-"
+"Designators) refers to the previous command, and I find useful when "
+"following chains for symlinks:"
+msgstr ""
+
+msgid ""
+"$ which git\n"
+"/run/current-system/sw/bin/git\n"
+"$ readlink $(!!)\n"
+"readlink $(which git)\n"
+"/nix/store/5bgr1xpm4m0r72h9049jbbhagxdyrnyb-git-2.28.0/bin/git\n"
+msgstr ""
+
+msgid ""
+"It is also useful when you forget to prefix `sudo` to a command that "
+"requires it:"
+msgstr ""
+
+msgid ""
+"$ requires-sudo.sh\n"
+"requires-sudo.sh: Permission denied\n"
+"$ sudo !!\n"
+"sudo ./requires-sudo.sh\n"
+"# all good\n"
+msgstr ""
+
+msgid ""
+"Bash prints the command expansion before executing it, so it is better for "
+"you to follow along what it is doing."
+msgstr ""
+
+msgid "`$_`: most recent parameter"
+msgstr ""
+
+msgid ""
+"The [`$_` "
+"variable](https://www.gnu.org/software/bash/manual/bash.html#Special-"
+"Parameters) will give you the most recent parameter you provided to a "
+"previous argument, which can save you typing sometimes:"
+msgstr ""
+
+msgid ""
+"# instead of...\n"
+"$ mkdir -p a/b/c/d/\n"
+"$ cd a/b/c/d/\n"
+"\n"
+"# ...you can:\n"
+"$ mkdir -p a/b/c/d/\n"
+"$ cd $_\n"
+msgstr ""
+
+msgid "Conclusion"
+msgstr ""
+
+msgid ""
+"I wouldn't use those in a script, as it would make the script terser to "
+"read, I find those useful shortcut that are handy when writing at the "
+"interactive terminal."
+msgstr ""