paritybit.ca

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 56df3f4387d5aaa240e4bd57e90698622b101f98
parent 7b849d445ede143c450b5a31768f63822b21bf8d
Author: Jake Bauer <jbauer@paritybit.ca>
Date:   Mon, 13 Jul 2020 22:16:49 -0400

Publish new blog post

Diffstat:
Mpages/blog.md | 1+
Apages/blog/using-rm-with-trash.md | 54++++++++++++++++++++++++++++++++++++++++++++++++++++++
Mpages/home.md | 4++--
Mpublic/feeds/sitewide-feed.xml | 24++++++++++++++++++++++++
Mpublic/sitemap.xml | 1+
5 files changed, 82 insertions(+), 2 deletions(-)

diff --git a/pages/blog.md b/pages/blog.md @@ -27,6 +27,7 @@ href="https://social.paritybit.ca/@jbauer">Mastodon</a>. ### 2020 <ul> + <li>2020-07-13 <a href="blog/using-rm-with-trash">Using the "rm" Command with Trash</a></li> <li>2020-07-13 <a href="blog/new-desktop-checklist">New Desktop Checklist</a></li> <li>2020-07-12 <a href="blog/new-server-checklist">New Server Checklist</a></li> <li>2020-07-12 <a href="blog/machine-hostnames">Machine Hostnames</a></li> diff --git a/pages/blog/using-rm-with-trash.md b/pages/blog/using-rm-with-trash.md @@ -0,0 +1,54 @@ +## Using the "rm" Command with Trash + +[//]: # "A quick hack to get a Trash bin with the rm command." + +[//]: # "main.min.css" + +[//]: # + +<div class="byline"> +<b>Written By:</b> Jake Bauer | + <b>Posted:</b> 2020-07-13 | + <b>Last Updated:</b> 2020-07-13 +</div> + +Those who use regular file browsers like Nautilus, Dolphin, or Thunar are used +to having an item go into the Trash folder (or "Recycle Bin" for Windows folks) +when it is deleted. This allows them to restore that file in the case that they +accidentally deleted it. However, on the command line the `rm` command will +irreversibly delete a file from your system (short of using data recovery +techniques) and has no concept of a Trash folder. This is a simple hacky way +to make `rm` remove a file to the Trash folder first so that you can prevent +yourself from accidentally irreversibly deleting something really important. + +### POSIX, Bash and Bash-like, Fish, and Korn Shells + +```bash +alias rm='mv -t $XDG_DATA_HOME/Trash/' +alias rm!='\rm' +``` + +### C Shell (csh) and TENEX C Shell (tcsh) + +```bash +alias rm 'mv -t $XDG_DATA_HOME/Trash/' +alias rm! '\rm' +``` + +### Explanation + +The aliases above do the following: + +* Alias `rm` to `mv` where any files specified will be moved to the XDG standard + trash folder instead of being deleted. +* Alias `rm!` to the normal `rm` program + which effectively makes `rm!` a "permanently delete this" command. + +If you choose not to have `$XDG_DATA_HOME` defined, you can replace that bit +with whichever path you prefer such as `$HOME/.Trash`. The folder you choose +must already exist or else `mv` will be angry. + +_This is my seventieth post for the +[#100DaysToOffload](https://social.paritybit.ca/tags/100DaysToOffload) +challenge. You can learn more about this challenge over at +[https://100daystooffload.com](https://100daystooffload.com)._ diff --git a/pages/home.md b/pages/home.md @@ -19,6 +19,8 @@ This site will soon be available over Gopher and Gemini. src="/img/feed-icon.png" width="15" height="15" alt="Click for RSS Feed"/> </a> </div> +2020-07-13 <a class="feed-item" href="blog/using-rm-with-trash">Using the "rm" Command with Trash</a> + 2020-07-13 <a class="feed-item" href="blog/new-desktop-checklist">New Desktop Checklist</a> 2020-07-12 <a class="feed-item" href="blog/new-server-checklist">New Server Checklist</a> @@ -36,8 +38,6 @@ This site will soon be available over Gopher and Gemini. 2020-07-06 <a class="feed-item" href="blog/improving-blog-searching">Improving Blog Searching</a> 2020-07-05 <a class="feed-item" href="blog/switching-to-cgit">Switching to cgit</a> - -2020-07-04 <a class="feed-item" href="blog/generating-my-geek-code">Generating My Geek Code</a> ### What is a Parity Bit? It is a bit (in the 1's and 0's sense) used in checking for errors in digital diff --git a/public/feeds/sitewide-feed.xml b/public/feeds/sitewide-feed.xml @@ -7,6 +7,30 @@ <description>The feed that covers all notable additions, updates, announcements, and other changes for the entire paritybit.ca website.</description> <item> + <title>Using the "rm" Command with Trash</title> + <link>https://www.paritybit.ca/blog/using-rm-with-trash</link> + <guid>https://www.paritybit.ca/blog/using-rm-with-trash</guid> + <pubDate>Mon, 13 Jul 2020 22:16:41 -0400</pubDate> + <description><![CDATA[<h2 id="using-the-rm-command-with-trash">Using the “rm” Command with Trash</h2> +<div class="byline"> +<p><b>Written By:</b> Jake Bauer | <b>Posted:</b> 2020-07-13 | <b>Last Updated:</b> 2020-07-13</p> +</div> +<p>Those who use regular file browsers like Nautilus, Dolphin, or Thunar are used to having an item go into the Trash folder (or “Recycle Bin” for Windows folks) when it is deleted. This allows them to restore that file in the case that they accidentally deleted it. However, on the command line the <code>rm</code> command will irreversibly delete a file from your system (short of using data recovery techniques) and has no concept of a Trash folder. This is a simple hacky way to make <code>rm</code> remove a file to the Trash folder first so that you can prevent yourself from accidentally irreversibly deleting something really important.</p> +<h3 id="posix-bash-and-bash-like-fish-and-korn-shells">POSIX, Bash and Bash-like, Fish, and Korn Shells</h3> +<div class="sourceCode" id="cb1"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb1-1" title="1"><span class="bu">alias</span> rm=<span class="st">&#39;mv -t $XDG_DATA_HOME/Trash/&#39;</span></a> +<a class="sourceLine" id="cb1-2" title="2"><span class="bu">alias</span> rm!=<span class="st">&#39;m&#39;</span></a></code></pre></div> +<h3 id="c-shell-csh-and-tenex-c-shell-tcsh">C Shell (csh) and TENEX C Shell (tcsh)</h3> +<div class="sourceCode" id="cb2"><pre class="sourceCode bash"><code class="sourceCode bash"><a class="sourceLine" id="cb2-1" title="1"><span class="bu">alias</span> rm <span class="st">&#39;mv -t $XDG_DATA_HOME/Trash/&#39;</span></a> +<a class="sourceLine" id="cb2-2" title="2"><span class="bu">alias</span> rm! <span class="st">&#39;m&#39;</span></a></code></pre></div> +<h3 id="explanation">Explanation</h3> +<p>The aliases above do the following:</p> +<ul> +<li>Alias <code>rm</code> to <code>mv</code> where any files specified will be moved to the XDG standard trash folder instead of being deleted.</li> +<li>Alias <code>rm!</code> to the normal <code>rm</code> program which effectively makes <code>rm!</code> a “permanently delete this” command.</li> +</ul> +<p>If you choose not to have <code>$XDG_DATA_HOME</code> defined, you can replace that bit with whichever path you prefer such as <code>$HOME/.Trash</code>. The folder you choose must already exist or else <code>mv</code> will be angry.</p>]]></description> + </item> +<item> <title>New Desktop Checklist</title> <link>https://www.paritybit.ca/blog/new-desktop-checklist</link> <guid>https://www.paritybit.ca/blog/new-desktop-checklist</guid> diff --git a/public/sitemap.xml b/public/sitemap.xml @@ -3,6 +3,7 @@ <url><loc>https://www.paritybit.ca</loc></url> <url><loc>https://www.paritybit.ca/home</loc></url> <url><loc>https://www.paritybit.ca/blog</loc></url> + <url><loc>https://www.paritybit.ca/blog/using-rm-with-trash</loc></url> <url><loc>https://www.paritybit.ca/blog/new-desktop-checklist</loc></url> <url><loc>https://www.paritybit.ca/blog/new-server-checklist</loc></url> <url><loc>https://www.paritybit.ca/blog/machine-hostnames</loc></url>