<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: alephalpha0</title>
    <description>The latest articles on DEV Community by alephalpha0 (@alephalpha0).</description>
    <link>https://dev.to/alephalpha0</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F418599%2Fb7125555-7337-4cc7-a48d-105cf4bdc21b.jpeg</url>
      <title>DEV Community: alephalpha0</title>
      <link>https://dev.to/alephalpha0</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alephalpha0"/>
    <language>en</language>
    <item>
      <title>Building A CLI Flow - 01</title>
      <dc:creator>alephalpha0</dc:creator>
      <pubDate>Wed, 11 Nov 2020 16:45:31 +0000</pubDate>
      <link>https://dev.to/alephalpha0/building-a-cli-flow-01-597f</link>
      <guid>https://dev.to/alephalpha0/building-a-cli-flow-01-597f</guid>
      <description>&lt;h1&gt;
  
  
  Building a cli program flow in order to archive a single webpage or article.
&lt;/h1&gt;

&lt;h3&gt;
  
  
  The problem to be solved:
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;I have a desire to be able to, through the command line, download a single webpage into a self-contained &lt;code&gt;.html&lt;/code&gt; file with the option to convert it to (or save alongside) other formats such as &lt;code&gt;PDF&lt;/code&gt;, &lt;code&gt;EPUB&lt;/code&gt;, or even &lt;code&gt;md&lt;/code&gt; if possible. There are &lt;strong&gt;two&lt;/strong&gt; main use-cases I want to offer: 1) get the entire webpage, strip out the ads/useless shit, and save the new version locally &amp;amp; 2) for journal/website articles, blog entries, or tutorials: simply save the main content and discard every other element from the source. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  The initial idea for solution:
&lt;/h3&gt;

&lt;p&gt;A bash script that takes in a URL and, through menu redirection, outputs the desired file(s) into a standard directory. &lt;/p&gt;

&lt;h3&gt;
  
  
  Why not use currently available methods:
&lt;/h3&gt;

&lt;p&gt;I've come across quite a few programs and scripts that seem like they would be perfect for what I want to do, but unfortunately I'm using termux on an Android and most of them do not work for one reason or the other in this enviromment.  &lt;/p&gt;

&lt;h6&gt;
  
  
  CLIs that I have tried with no luck to get working on Termux:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;hget&lt;/code&gt; - &lt;a href="https://github.com/bevacqua/hget"&gt;hget&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;monolith&lt;/code&gt; - &lt;a href="https://github.com/Y2Z/monolith"&gt;monolith&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;erised&lt;/code&gt; - &lt;a href="https://github.com/marvelm/erised"&gt;erised&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;percollate&lt;/code&gt; - &lt;a href="https://github.com/danburzo/percollate"&gt;percollate&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ferret&lt;/code&gt; - &lt;a href="https://github.com/MontFerret/ferret"&gt;ferret&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  The semi-focused detailing of my initial mind thoughts:
&lt;/h3&gt;

&lt;p&gt;So, I feel like my grasp of scripting and pipelines is decent enough to cobble together a functioning bash script using programs and sources at my disposal that should take care of what I want to do. Namely, a locally saved, single file &lt;code&gt;.html&lt;/code&gt; and have the option/ability to convert to &lt;code&gt;PDF&lt;/code&gt;, &lt;code&gt;md&lt;/code&gt;, or &lt;code&gt;EPUB&lt;/code&gt; if desired. In my mind, there will be several working pieces of this script that could and should be broken down into smaller modules\functions . &lt;/p&gt;

&lt;p&gt;I'm designing and planning on a menu-driven interface so creating menu-building and menu-displaying functions will be two individual tasks. Directory checking, creation, and manipulation should be another set of tasks. Error handling, logging and graceful failures are another set. And finally, the actual downloading and parsing into files will be a set of functions. &lt;/p&gt;

&lt;p&gt;I'm aware that bash scripting might not be the optimal route to go with this idea, due to processing times, data handling and manipulation, and the fact that other languages come with the advantage of libraries and support modules that cover just about every detail and "feature" I could possibly come up against. However, it will serve as a basis for laying out the flow and main ideas of what I want my script to do as well as help prototype and get a working product to use as proof of concept. &lt;/p&gt;

&lt;p&gt;From the get-go, there are several options that I can and will be utilizing to achieve my end-goal. I'm hoping that using and offering several options of methods will not over-complicate the road ahead. The ability to write code that can be easily extended and has the ability to easily have options added to it is something that I am working towards. The thought that I should focus on one (one method for obtaining the webpage, one method for processing the downloaded data, one method for saving, and one method for file conversion) is there, and it has validity. However, I am blockheaded when it comes to ambitions, and throwing caution to the wind is the name of the game right now. &lt;/p&gt;

&lt;h6&gt;
  
  
  Options in consideration for scraping/downloading/getting source:
&lt;/h6&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;wget&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cURL&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;httpie&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ferret&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;w3m&lt;/code&gt; &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is as far as I have gotten, planning and layout wise. The next part of this session of brain-vomitting will cover the logic trains, process flow, and possible ways of brainstorming the layout of the script. &lt;/p&gt;

&lt;h4&gt;
  
  
  TODO:
&lt;/h4&gt;

&lt;ul&gt;
&lt;li&gt;research the methods of using &lt;code&gt;ferret&lt;/code&gt; to scrape websites and obtain the contents. &lt;/li&gt;
&lt;li&gt;look into flags and options of &lt;code&gt;wget&lt;/code&gt; &lt;code&gt;cURL&lt;/code&gt; &lt;code&gt;httpie&lt;/code&gt; and &lt;code&gt;w3m&lt;/code&gt;. &lt;/li&gt;
&lt;li&gt;Sketch out the menus and brainstorm ways for it to work.&lt;/li&gt;
&lt;li&gt;For processing... HTML2JSON? HTML2MD? HTML2????? &lt;/li&gt;
&lt;li&gt;File conversion should be PANDOC, but of course, the perfect tool doesn't work under termux. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Originally posted on my &lt;a href="http://rootofpi.me/2020/11/10/Building-A-CLI-Flow-01/"&gt;blog&lt;/a&gt; and on a &lt;a href="https://gist.github.com/alephalpha0/c8c8a11c77bf4c3e45e959f653af58d0"&gt;gist&lt;/a&gt;&lt;/p&gt;

</description>
      <category>codenewbie</category>
      <category>cli</category>
      <category>terminal</category>
      <category>bash</category>
    </item>
    <item>
      <title>Mini conceptual breakthrough re: ln</title>
      <dc:creator>alephalpha0</dc:creator>
      <pubDate>Sun, 23 Aug 2020 05:01:52 +0000</pubDate>
      <link>https://dev.to/alephalpha0/mini-conceptual-breakthrough-re-ln-3dpi</link>
      <guid>https://dev.to/alephalpha0/mini-conceptual-breakthrough-re-ln-3dpi</guid>
      <description>&lt;h1&gt;
  
  
  mind. blown.
&lt;/h1&gt;

&lt;p&gt;i do not use the typical laptop or desktop setup to muck around on the linux cli, to use text editors [micro, my babe], or futz around in image and video editors. i rely mainly on my android phones rocking termux and other various apps.&lt;/p&gt;

&lt;p&gt;one of the pains in my keister lately, as far as getting the files to my site host's server goes, has been in the quite convoluted steps i take to do a quite simple task. these are mainly, mostly in fact, done as a direct result of a) i am scared of &lt;code&gt;ssh&lt;/code&gt;/&lt;code&gt;sftp&lt;/code&gt; via a cli still, and b) im self teaching on every aspect of my growth so far. the process is roughly:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;commit&lt;/code&gt; the updates via &lt;code&gt;git&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;rsync&lt;/code&gt; copy the files from the termux app storage into android storage proper &lt;code&gt;/data/data/com.termux/.&lt;/code&gt;.. to the usual &lt;code&gt;/storage/emulated/0&lt;/code&gt; &lt;/li&gt;
&lt;li&gt;use TotalCommander as visual ftp client and send those badboys up to the server.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now the point of this post. &lt;code&gt;ln&lt;/code&gt; and &lt;strong&gt;hard links&lt;/strong&gt;. I was reading some articles and the die.net MAN pages on &lt;code&gt;ln&lt;/code&gt; tonight and it finally sank in, what makes a hard link so incredibly valuable. especially in arenas like where i dwell. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;a file name simply points the OS to the data bits and bytes that are written on the disk that make up what i conceptualize as a &lt;code&gt;.html&lt;/code&gt; or &lt;code&gt;.mp3&lt;/code&gt; file. if the file name is erased (this happens when i &lt;em&gt;delete&lt;/em&gt; the file) only the pointer to the specific bits is removed. the bits an bytes remain and are written over, etc etc. there is nothing that says that multiple file names cannot point to and access the same range of bytes from the OS. that multiple file pointers cant reference the same data. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;😲😲😲😲😲😲&lt;/p&gt;

&lt;p&gt;i can, through termux, access my &lt;code&gt;/storage/emulated/0/&lt;/code&gt; file system and create hard links, via &lt;code&gt;ln&lt;/code&gt;, to the html, liquid, css, etc files i edit and manipulate in termux and be able to upload them from android os. takes out constant &lt;code&gt;rsync&lt;/code&gt; and &lt;code&gt;mkdir&lt;/code&gt; and &lt;code&gt;cp&lt;/code&gt; and &lt;code&gt;mv&lt;/code&gt; shenanigans. makes my workflow leaner, tighter, more tiger like.&lt;br&gt;
📱🔗🔗⛓️🔗⌨️&lt;/p&gt;

&lt;p&gt;🐯&lt;/p&gt;

&lt;p&gt;&lt;a href="https://shapeshed.com/unix-ln/"&gt;main article that brought on the ah hah moment&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--DI1tE78c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ehrn2huoljgpga6i9p3s.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--DI1tE78c--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ehrn2huoljgpga6i9p3s.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>terminal</category>
    </item>
    <item>
      <title>zshLoadOrder</title>
      <dc:creator>alephalpha0</dc:creator>
      <pubDate>Fri, 07 Aug 2020 12:22:08 +0000</pubDate>
      <link>https://dev.to/alephalpha0/zshloadorder-458g</link>
      <guid>https://dev.to/alephalpha0/zshloadorder-458g</guid>
      <description>&lt;h1&gt;
  
  
  ZSH shell startup/shutdown files.
&lt;/h1&gt;

&lt;p&gt;This is really just for my own reference, as ZSH loads its config in its own order and I can never seem to remember it. The global files (which shouldn't really be tampered with by users) will be mentioned and put into larger font than the user files. However, I won't be expounding upon them, as that is outside the purpose of this writing.&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;/etc/zshenv&lt;/code&gt; above all else. The alpha, the omega, the genesis.
&lt;/h1&gt;

&lt;h3&gt;
  
  
  .zshenv (req to be in &lt;code&gt;$HOME&lt;/code&gt;)
&lt;/h3&gt;

&lt;p&gt;Here there be environmental variables. &lt;br&gt;
Place here anything I'm going to &lt;code&gt;export&lt;/code&gt; so that it can be referenced later. &lt;br&gt;
Good candidates include &lt;code&gt;XDG_*&lt;/code&gt; and changes to program defaults. &lt;br&gt;
Set up your $PATH &amp;amp; $PAGER &amp;amp; etc etc etc.&lt;br&gt;&lt;br&gt;
Quality of life: &lt;code&gt;export ZDOTDIR="$XDG_CONFIG_HOME/zsh"&lt;/code&gt; &lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;/etc/zprofile&lt;/code&gt; &lt;em&gt;ONLY&lt;/em&gt; if the shell is a login shell.
&lt;/h1&gt;

&lt;h3&gt;
  
  
  .zprofile (&lt;code&gt;$ZDOTDIR/.zprofile&lt;/code&gt;) &lt;em&gt;ONLY&lt;/em&gt; if shell is login.
&lt;/h3&gt;

&lt;p&gt;Any commands you want happening on every login. &lt;br&gt;
Start daemons, set a new MOTD, start a SSH tunnel. &lt;br&gt;
The possibilities are endless. &lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;/etc/zshrc&lt;/code&gt; &lt;em&gt;ONLY&lt;/em&gt;  if the shell is interactive.
&lt;/h1&gt;

&lt;h2&gt;
  
  
  .zshrc (&lt;code&gt;$ZDOTDIR/.zshrc&lt;/code&gt;) &lt;em&gt;ONLY&lt;/em&gt; if the shell is interactive.
&lt;/h2&gt;

&lt;p&gt;Used for shell options and various commands. &lt;br&gt;
There should be a loooong list of &lt;code&gt;setopt&lt;/code&gt; and &lt;code&gt;unsetopt&lt;/code&gt; going on here. &lt;br&gt;
Shell modules and the ZSH prompt go here, as well as history config.&lt;br&gt;&lt;br&gt;
Source your scripts and set your aliases. &lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;code&gt;/etc/zlogin&lt;/code&gt; &lt;em&gt;ONLY&lt;/em&gt; if shell is login.
&lt;/h1&gt;

&lt;h2&gt;
  
  
  .zlogin (&lt;code&gt;$ZDOTDIR/.zlogin&lt;/code&gt;) &lt;em&gt;ONLY&lt;/em&gt;  if shell is login.
&lt;/h2&gt;

&lt;p&gt;Almost same purpose as &lt;code&gt;.zprofile&lt;/code&gt; but you know, not really different. Use only one or the other if you're flying by the book. &lt;/p&gt;

&lt;h2&gt;
  
  
  .zlogout (&lt;code&gt;$ZDOTDIR/.zlogout&lt;/code&gt;)  &lt;em&gt;ONLY&lt;/em&gt; if shell is login.
&lt;/h2&gt;

&lt;p&gt;Can be used to execute commands when a shell exits. &lt;br&gt;
Good time to clean up caches or tmp files/folders. &lt;br&gt;
Logout of sessions, set the environment back to how you like it when you login.&lt;br&gt;&lt;br&gt;
Send an email to yourself of temp logs and an email to your mom telling her you love her. &lt;/p&gt;

&lt;h4&gt;
  
  
  References, sources &amp;amp; points of interest.
&lt;/h4&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="http://zsh.sourceforge.net/Doc/Release/Files.html#Files"&gt;http://zsh.sourceforge.net/Doc/Release/Files.html#Files&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://unix.stackexchange.com/questions/71253/what-should-shouldnt-go-in-zshenv-zshrc-zlogin-zprofile-zlogout#71258"&gt;https://unix.stackexchange.com/questions/71253/what-should-shouldnt-go-in-zshenv-zshrc-zlogin-zprofile-zlogout#71258&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://thevaluable.dev/zsh-install-configure/"&gt;https://thevaluable.dev/zsh-install-configure/&lt;/a&gt; &lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>zsh</category>
      <category>commandline</category>
      <category>configuration</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
