<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="/atom.xsl" type="text/xsl"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:fh="http://purl.org/syndication/history/1.0">
  <title>Posts tagged: bash Archive</title>
  <id>https://pype.dev/tags/bash/archive/atom.xml</id>
  <updated>2022-09-21T11:26:02Z</updated>
  <subtitle>All posts with the tag &#34;bash&#34;</subtitle>
  <link href="https://pype.dev/tags/bash/" rel="alternate" type="text/html"></link>
  <link href="https://pype.dev/tags/bash/archive/atom.xml" rel="self" type="application/atom+xml"></link>
  <link href="https://pype.dev/tags/bash/atom.xml" rel="current" type="application/atom+xml"></link>
  <author>
    <name>Nic Payne</name>
  </author>
  <generator uri="https://github.com/WaylonWalker/markata-go">markata-go</generator>
  <fh:complete></fh:complete>
  <entry>
    <title>Append string to list of files with xarg</title>
    <id>https://pype.dev/append-string-to-list-of-files-with-xarg/</id>
    <updated>2022-09-21T11:26:02Z</updated>
    <published>2022-09-21T11:26:02Z</published>
    <link href="https://pype.dev/append-string-to-list-of-files-with-xarg/" rel="alternate" type="text/html"></link>
    <summary type="text">❯ find . -name &#34;requirements.in&#34; -print0 | xargs -0 sh -c &#39;for arg in &#34;$@&#34;; do echo &#34;awscli&#34; &gt;&gt;&#34;$arg&#34;; done&#39;</summary>
    <content type="html">&lt;p&gt;❯ find . -name &amp;ldquo;requirements.in&amp;rdquo; -print0 | xargs -0 sh -c &amp;lsquo;for arg in &amp;ldquo;$@&amp;rdquo;; do echo &amp;ldquo;awscli&amp;rdquo; &amp;raquo;&amp;quot;$arg&amp;quot;; done&amp;rsquo;&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Destroying Tmux sessions with fzf</title>
    <id>https://pype.dev/destroying-tmux-sessions-with-fzf/</id>
    <updated>2022-09-15T10:27:58Z</updated>
    <published>2022-09-15T10:27:58Z</published>
    <link href="https://pype.dev/destroying-tmux-sessions-with-fzf/" rel="alternate" type="text/html"></link>
    <summary type="text">I use Tmux and Vim for most of my workflow, but I end up with a lot of dangling tmux sessions that dont&#39; really need to persist... but killing them one at a...</summary>
    <content type="html">&lt;p&gt;I use Tmux and Vim for most of my workflow, but I end up with a lot of dangling&#xA;tmux sessions that dont&amp;rsquo; really need to persist&amp;hellip; but killing them one at a&#xA;time is a pain so I wrote a little script-kitty nonsense to pipe multiple&#xA;choices from fzf into &lt;code&gt;tmux kill-session&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;I defined a little function in my &lt;code&gt;.zshrc&lt;/code&gt;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;destroy&lt;span class=&#34;o&#34;&gt;()&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;{&lt;/span&gt; &#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    tmux list-sessions -F &lt;span class=&#34;s1&#34;&gt;&amp;#39;#{session_name}&amp;#39;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; fzf -m &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; xargs -d &lt;span class=&#34;s1&#34;&gt;$&amp;#39;\n&amp;#39;&lt;/span&gt; sh -c &lt;span class=&#34;s1&#34;&gt;&amp;#39;echo &amp;#34;killing $0&amp;#34;; tmux kill-session -t &amp;#34;$0&amp;#34;; for arg;do echo &amp;#34;killing $arg&amp;#34;;tmux kill-session -t &amp;#34;$arg&amp;#34;; done&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;o&#34;&gt;}&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;bindkey -s &lt;span class=&#34;s1&#34;&gt;&amp;#39;^d&amp;#39;&lt;/span&gt; &lt;span class=&#34;s1&#34;&gt;&amp;#39;destroy \n&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;&lt;code&gt;tmux list-sessions -F &#39;#{session_name}&#39; &lt;/code&gt; prints all my active tmux sessions to the console with the format of just their name&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;pype.dev   main   ×1 via   v3.8.11&lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;pype.dev&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt;  on  &lt;span class=&#34;o&#34;&gt;(&lt;/span&gt;us-east-1&lt;span class=&#34;o&#34;&gt;)&lt;/span&gt; proxy&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;❯ tmux list-sessions -F &lt;span class=&#34;s1&#34;&gt;&amp;#39;#{session_name}&amp;#39;&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;session-01&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;session-02&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;session-03&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;...&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Pipe that to &lt;code&gt;fzf -m&lt;/code&gt; to allow multiple choices to be made using tab&lt;/p&gt;&#xA;&lt;p&gt;Then the nasty bit in &lt;code&gt;xargs&lt;/code&gt;&amp;hellip; I echo &lt;code&gt;killing @0&lt;/code&gt; and &lt;code&gt;killing $arg&lt;/code&gt; because the &lt;code&gt;sh -c&lt;/code&gt; passes the first tmux session name to &lt;code&gt;@0&lt;/code&gt; (it&amp;rsquo;s just what bash does) and then the rest get handled in the for loop.&lt;/p&gt;&#xA;&lt;p&gt;Basically then I get an fzf list to choose multiple tmux sessions to destroy to clean up some RAM!&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Remove ZFS Dataset Specific Snapshots</title>
    <id>https://pype.dev/remove-zfs-dataset-specific-snapshots/</id>
    <updated>2022-05-19T05:49:16Z</updated>
    <published>2022-05-19T05:49:16Z</published>
    <link href="https://pype.dev/remove-zfs-dataset-specific-snapshots/" rel="alternate" type="text/html"></link>
    <summary type="text">I started my homelab journey being super naive about ZFS and how to manage the filesystem... that bit me in the butt when transfering a ton of files out of...</summary>
    <content type="html">&lt;p&gt;I started my homelab journey being super naive about ZFS and how to manage the&#xA;filesystem&amp;hellip; that bit me in the butt when transfering a ton of files out of&#xA;folders and into datasets because ZFS is copy on write so I was essentially&#xA;duplicating my storage until I got a hair smarter about removing files after&#xA;they&amp;rsquo;re moved (rsync &amp;ndash;remove-source-file ftw). But I had a ton of snapshots of&#xA;child datasets with a ton of data that I just never will need, so I learned&#xA;&lt;code&gt;zfs list -H -o name -t snapshot tank/dataset1/dataset2&lt;/code&gt; will list just the&#xA;snapshots for dataset2 and if you pipe that into &lt;code&gt;xargs -n1 zfs destroy&lt;/code&gt; then&#xA;you have a way to clear out some snapshots you don&amp;rsquo;t need!&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Stow</title>
    <id>https://pype.dev/stow/</id>
    <updated>2022-03-04T00:00:00Z</updated>
    <published>2022-03-04T00:00:00Z</published>
    <link href="https://pype.dev/stow/" rel="alternate" type="text/html"></link>
    <summary type="text">Stow is a great tool for managing dotfiles. My usage looks like cloning my dotfiles to my home directory, setting some environment variables via a script,...</summary>
    <content type="html">&lt;p&gt;Stow is a great tool for managing dotfiles. My usage looks like cloning my dotfiles to my home directory, setting some environment variables via a script, then stowing relevant packages and boom my config is good to go&amp;hellip;&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;cd&lt;/span&gt; ~&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;git clone &amp;lt;my dotfiles repo&amp;gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;cd&lt;/span&gt; dotfiles&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# env variable stuff ignored here&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;stow zsh  &lt;span class=&#34;c1&#34;&gt;# This will symlink my .zshrc file which is in ~/dotfiles/zsh to ~/.zshrc&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;By default stow will stow packages up one directory from the root directory.&#xA;In this example the root directory is &lt;code&gt;~/dotfiles&lt;/code&gt; and the package is &lt;code&gt;zsh&lt;/code&gt;.&#xA;So the files in the &lt;code&gt;zsh&lt;/code&gt; package will symlinked into &lt;code&gt;~/&lt;/code&gt;.&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;stow&lt;/code&gt; makes it easy to share dotfiles across machines, or safely experiment with config changes while always being protected by &lt;code&gt;git&lt;/code&gt; since your dotfiles are in a git repo!&#xA;&amp;hellip;They are in a git repo&amp;hellip; right?&lt;/p&gt;&#xA;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
  <entry>
    <title>Stow-Target</title>
    <id>https://pype.dev/stow-target/</id>
    <updated>2022-03-04T00:00:00Z</updated>
    <published>2022-03-04T00:00:00Z</published>
    <link href="https://pype.dev/stow-target/" rel="alternate" type="text/html"></link>
    <summary type="text">Check out stow for a brief introduction to</summary>
    <content type="html">&lt;p&gt;Check out &lt;a href=&#34;/stow&#34;&gt;stow&lt;/a&gt; for a brief introduction to &lt;code&gt;stow&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;What if I want to stow a package somewhere else?&#xA;Boom, that&amp;rsquo;s where &lt;code&gt;-t&lt;/code&gt; comes in&amp;hellip;&lt;/p&gt;&#xA;&lt;p&gt;Maybe I don&amp;rsquo;t like having my &lt;code&gt;dotfiles&lt;/code&gt; repo at &lt;code&gt;$HOME&lt;/code&gt; and instead I want it in &lt;code&gt;~/git&lt;/code&gt; or &lt;code&gt;~/personal&lt;/code&gt; just to stay organized&amp;hellip;&#xA;Well then I could have the same workflow except the &lt;code&gt;stow&lt;/code&gt; command looks like this:&lt;/p&gt;&#xA;&lt;pre class=&#34;chroma&#34;&gt;&lt;code&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;stow zsh -t ~/&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;#or&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;stow zsh -t &lt;span class=&#34;nv&#34;&gt;$HOME&lt;/span&gt;&#xA;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;</content>
    <author>
      <name>Nic Payne</name>
      <uri>https://pype.dev</uri>
    </author>
  </entry>
</feed>