diff options
author | garhve <git@garhve.com> | 2022-12-10 08:59:16 +0800 |
---|---|---|
committer | garhve <git@garhve.com> | 2022-12-10 08:59:16 +0800 |
commit | 4c9c9ab88cec6b8c9364917564484d9170a55b3c (patch) | |
tree | c0fc1072ab252b6429c3fd9cf6126a14943a4f7b | |
parent | 8f33ededea7a01c230b842b4772496f7e2d99bf6 (diff) |
change blog content and add font
-rw-r--r-- | cn/index.xml | 2 | ||||
-rw-r--r-- | cn/posts/2/index.html | 47 | ||||
-rw-r--r-- | cn/posts/index.xml | 2 | ||||
-rw-r--r-- | fonts/ssbb.ttf | bin | 0 -> 5132344 bytes | |||
-rw-r--r-- | posts/1/index.html | 4 | ||||
-rw-r--r-- | posts/3/index.html | 10 | ||||
-rw-r--r-- | posts/5/index.html | 6 | ||||
-rw-r--r-- | posts/6/index.html | 18 |
8 files changed, 25 insertions, 64 deletions
diff --git a/cn/index.xml b/cn/index.xml index 24e09d2..8e78943 100644 --- a/cn/index.xml +++ b/cn/index.xml @@ -25,7 +25,7 @@ Linux端呢,则暂时没有什么好办法,只能老老实实打开网页上 原先,发布一篇博客我的流程为, hugo new post -&gt; vim 找到文章 -&gt; 保存或者发布 -&gt; 然后到public文件夹 push出去。 太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~ -###################################################################### # @author : garhve (dev@garhve.com) # @file : blog # @created : Friday Dec 09, 2022 16:09:42 CST # # @description : simplify blog publishing.</description> +这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 也许可以将代码优化下以后就省心了,哈哈。</description> </item> <item> diff --git a/cn/posts/2/index.html b/cn/posts/2/index.html index 92eb216..3c37d26 100644 --- a/cn/posts/2/index.html +++ b/cn/posts/2/index.html @@ -23,7 +23,7 @@ "articleSection" : "posts", "name" : "测试自动创建博客", "headline" : "测试自动创建博客", - "description" : "hugo挺不错的,就是太麻烦了。以下几点都是在使用时遇到的一些问题:\n写作 编辑器随便用个支持MD的就行了,这句陈述挺好。\n但现实是,我家里一台MacBook,一台arch Linux的Thinkpad,公司一台MacBook。 所以跨平台对我来说就很重要了。我有点洁癖,家目录我都在努力的把config和local 文件整合在各自不同的区域名以至于不那么乱。在每台电脑上下个markdown editor, 同步文件再在每台电脑上额外加个云,想想我都受不了。\n不过目前我试过了一个软件marktext,功能和UI都很不错,但由于同步 问题我不太想用。\n其实我比较倾向于下载个web app搭在我raspberry pi上,再通过公网挂出去, 达到我在任意地方都能使用的目的来着,但目前的app总有这样那样的问题 使我不是很满意,也就一直耽搁着了,现在也就是通过ssh直接到我的arch里 直接使用vim写文章,有点别扭\u0026hellip; 用vim写markdown。\n图片 图片怎么管理原本也是个问题,我买入了一个存储桶并配置好了nginx, 但这比较适合fetch图片,当我截了新图要上传时,要么登录存储桶要么scp到 服务器去上传,而且传好后的url也是一个麻烦事。试了各种方法都不太行之后。\n在Mac端我用了uPic,这个比较方便的是不止可以传图片,其他文件需要 保存了也可以通过它上传,并且,它支持上传后直接拿到自定义对url,对于 我自定义了域名去匹配nginx的规则很方便。而且只需第一次配置好, 后面使用即可。\nLinux端呢,则暂时没有什么好办法,只能老老实实打开网页上传了~\n发布 Hugo的发布其实也是一个问题。在上面说过,我有洁癖,其实我还有一些强迫症。 自从GitHub被微软收购后,我很少使用了。虽然我只是一介平民,但我还是希望 尽可能将我不同的指纹分散隔离开来。我用了我自有的服务器去托管我的一些服务, 其中便包括这个博客。 Hugo我是安装在我的Linux上,我并没有让它接入公网。我有在服务器上托管了一个 cgit来当我的私人仓库,于是理所当然的,我把public给git到服务器上了。\n原先,发布一篇博客我的流程为,\nhugo new post -\u0026gt; vim 找到文章 -\u0026gt; 保存或者发布 -\u0026gt; 然后到public文件夹 push出去。\n太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~\n###################################################################### # @author : garhve (dev@garhve.com) # @file : blog # @created : Friday Dec 09, 2022 16:09:42 CST # # @description : simplify blog publishing.", + "description" : "hugo挺不错的,就是太麻烦了。以下几点都是在使用时遇到的一些问题:\n写作 编辑器随便用个支持MD的就行了,这句陈述挺好。\n但现实是,我家里一台MacBook,一台arch Linux的Thinkpad,公司一台MacBook。 所以跨平台对我来说就很重要了。我有点洁癖,家目录我都在努力的把config和local 文件整合在各自不同的区域名以至于不那么乱。在每台电脑上下个markdown editor, 同步文件再在每台电脑上额外加个云,想想我都受不了。\n不过目前我试过了一个软件marktext,功能和UI都很不错,但由于同步 问题我不太想用。\n其实我比较倾向于下载个web app搭在我raspberry pi上,再通过公网挂出去, 达到我在任意地方都能使用的目的来着,但目前的app总有这样那样的问题 使我不是很满意,也就一直耽搁着了,现在也就是通过ssh直接到我的arch里 直接使用vim写文章,有点别扭\u0026hellip; 用vim写markdown。\n图片 图片怎么管理原本也是个问题,我买入了一个存储桶并配置好了nginx, 但这比较适合fetch图片,当我截了新图要上传时,要么登录存储桶要么scp到 服务器去上传,而且传好后的url也是一个麻烦事。试了各种方法都不太行之后。\n在Mac端我用了uPic,这个比较方便的是不止可以传图片,其他文件需要 保存了也可以通过它上传,并且,它支持上传后直接拿到自定义对url,对于 我自定义了域名去匹配nginx的规则很方便。而且只需第一次配置好, 后面使用即可。\nLinux端呢,则暂时没有什么好办法,只能老老实实打开网页上传了~\n发布 Hugo的发布其实也是一个问题。在上面说过,我有洁癖,其实我还有一些强迫症。 自从GitHub被微软收购后,我很少使用了。虽然我只是一介平民,但我还是希望 尽可能将我不同的指纹分散隔离开来。我用了我自有的服务器去托管我的一些服务, 其中便包括这个博客。 Hugo我是安装在我的Linux上,我并没有让它接入公网。我有在服务器上托管了一个 cgit来当我的私人仓库,于是理所当然的,我把public给git到服务器上了。\n原先,发布一篇博客我的流程为,\nhugo new post -\u0026gt; vim 找到文章 -\u0026gt; 保存或者发布 -\u0026gt; 然后到public文件夹 push出去。\n太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~\n这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 也许可以将代码优化下以后就省心了,哈哈。", "inLanguage" : "en-US", "author" : "garhve", "creator" : "garhve", @@ -52,7 +52,7 @@ Linux端呢,则暂时没有什么好办法,只能老老实实打开网页上 原先,发布一篇博客我的流程为, hugo new post -&gt; vim 找到文章 -&gt; 保存或者发布 -&gt; 然后到public文件夹 push出去。 太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~ -###################################################################### # @author : garhve (dev@garhve.com) # @file : blog # @created : Friday Dec 09, 2022 16:09:42 CST # # @description : simplify blog publishing." /> +这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 也许可以将代码优化下以后就省心了,哈哈。" /> <meta name="description" content="hugo挺不错的,就是太麻烦了。以下几点都是在使用时遇到的一些问题: 写作 编辑器随便用个支持MD的就行了,这句陈述挺好。 但现实是,我家里一台MacBook,一台arch Linux的Thinkpad,公司一台MacBook。 所以跨平台对我来说就很重要了。我有点洁癖,家目录我都在努力的把config和local 文件整合在各自不同的区域名以至于不那么乱。在每台电脑上下个markdown editor, 同步文件再在每台电脑上额外加个云,想想我都受不了。 @@ -65,7 +65,7 @@ Linux端呢,则暂时没有什么好办法,只能老老实实打开网页上 原先,发布一篇博客我的流程为, hugo new post -&gt; vim 找到文章 -&gt; 保存或者发布 -&gt; 然后到public文件夹 push出去。 太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~ -###################################################################### # @author : garhve (dev@garhve.com) # @file : blog # @created : Friday Dec 09, 2022 16:09:42 CST # # @description : simplify blog publishing." /> +这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 也许可以将代码优化下以后就省心了,哈哈。" /> <meta property="og:locale" content="en-us" /><meta property="og:image" content="https://assets.garhve.com/pictures/assets/images/favicon/favicon.ico" /> @@ -177,46 +177,7 @@ push出去。</p> <p>太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic">######################################################################</span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># @author : garhve (dev@garhve.com)</span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># @file : blog</span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># @created : Friday Dec 09, 2022 16:09:42 CST</span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># </span> -</span></span><span style="display:flex;"><span><span style="font-style:italic"># @description : simplify blog publishing. </span> -</span></span><span style="display:flex;"><span><span style="font-style:italic">######################################################################</span> -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>p=<span style="font-style:italic">"</span><span style="font-weight:bold">$(</span>pwd<span style="font-weight:bold">)</span><span style="font-style:italic">"</span> -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>cd <span style="font-style:italic">"</span>$HOME<span style="font-style:italic">/Storage/data/blog"</span> -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>echo <span style="font-style:italic">"Enter the blog name"</span> -</span></span><span style="display:flex;"><span>read -r name -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>hugo new posts/<span style="font-style:italic">"</span>$name<span style="font-style:italic">"</span> -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>echo <span style="font-style:italic">"1. en"</span> -</span></span><span style="display:flex;"><span>echo <span style="font-style:italic">"2. cn"</span> -</span></span><span style="display:flex;"><span>echo <span style="font-style:italic">"all option would be default to 1 except 2[1 or 2]: "</span> -</span></span><span style="display:flex;"><span>read l -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span><span style="font-weight:bold">if</span> [ $l -eq 1 ]; <span style="font-weight:bold">then</span> -</span></span><span style="display:flex;"><span> lang=<span style="font-style:italic">"en"</span> -</span></span><span style="display:flex;"><span><span style="font-weight:bold">elif</span> [ $l -eq 2 ]; <span style="font-weight:bold">then</span> -</span></span><span style="display:flex;"><span> lang=<span style="font-style:italic">"cn"</span> -</span></span><span style="display:flex;"><span><span style="font-weight:bold">else</span> -</span></span><span style="display:flex;"><span> lang=<span style="font-style:italic">"en"</span> -</span></span><span style="display:flex;"><span><span style="font-weight:bold">fi</span> -</span></span><span style="display:flex;"><span>[ $lang == <span style="font-style:italic">"cn"</span> ] && mv <span style="font-style:italic">"content/en/posts/</span>$name<span style="font-style:italic">"</span> <span style="font-style:italic">"content/cn/posts/</span>$name<span style="font-style:italic">"</span> -</span></span><span style="display:flex;"><span>vim <span style="font-style:italic">"content/</span>$lang<span style="font-style:italic">/posts/</span>$name<span style="font-style:italic">"</span> -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>hugo -</span></span><span style="display:flex;"><span>cd public -</span></span><span style="display:flex;"><span>git add . -</span></span><span style="display:flex;"><span>read -r -p <span style="font-style:italic">"commit message: "</span> com -</span></span><span style="display:flex;"><span>git commit -m <span style="font-style:italic">"</span>$com<span style="font-style:italic">"</span> -</span></span><span style="display:flex;"><span> -</span></span><span style="display:flex;"><span>cd <span style="font-style:italic">"</span>$p<span style="font-style:italic">"</span> -</span></span></code></pre></div><p>这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 +<p>这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 也许可以将代码优化下以后就省心了,哈哈。</p> </div> diff --git a/cn/posts/index.xml b/cn/posts/index.xml index 5f5f341..cbf44da 100644 --- a/cn/posts/index.xml +++ b/cn/posts/index.xml @@ -25,7 +25,7 @@ Linux端呢,则暂时没有什么好办法,只能老老实实打开网页上 原先,发布一篇博客我的流程为, hugo new post -&gt; vim 找到文章 -&gt; 保存或者发布 -&gt; 然后到public文件夹 push出去。 太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~ -###################################################################### # @author : garhve (dev@garhve.com) # @file : blog # @created : Friday Dec 09, 2022 16:09:42 CST # # @description : simplify blog publishing.</description> +这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 也许可以将代码优化下以后就省心了,哈哈。</description> </item> <item> diff --git a/fonts/ssbb.ttf b/fonts/ssbb.ttf Binary files differnew file mode 100644 index 0000000..9673db1 --- /dev/null +++ b/fonts/ssbb.ttf diff --git a/posts/1/index.html b/posts/1/index.html index 12dacc9..1839247 100644 --- a/posts/1/index.html +++ b/posts/1/index.html @@ -127,7 +127,7 @@ Due to personal interest, I didn&rsquo;t choose frame to base my website. I <p>Due to personal interest, I didn’t choose frame to base my website. I use <strong>Nginx</strong> but I don’t familiar with it. making it shows my content is not that difficult even that I don’t know much fancy state, but I stucked on SSL.</p> <p>In order to use https instead of http, I choosed <strong>let’s encrypt</strong>, which is good for me and it’s free. However, I can only getting my non-www domain working. when it comes to www domain, it still http.</p> <p>I found solutions all about using return to returning https, but it won’t work</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="font-weight:bold">server</span> { +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="font-weight:bold">server</span> { </span></span><span style="display:flex;"><span> <span style="font-weight:bold">server_name</span> <span style="font-style:italic">www.garhve.com</span>; </span></span><span style="display:flex;"><span> <span style="font-weight:bold">return</span> 301 <span style="font-style:italic">https://www.garhve.com</span>$request_uri </span></span><span style="display:flex;"><span><span style="">}</span> @@ -135,7 +135,7 @@ Due to personal interest, I didn&rsquo;t choose frame to base my website. I <p>After searching and searching, I found where i was getting wrong.</p> <p>Above statement only return https-www which doesn’t hold any contents, all I need is to redirect the https-www to https-non-www.</p> <p>So, change to this one</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="font-weight:bold">server</span> { +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-nginx" data-lang="nginx"><span style="display:flex;"><span><span style="font-weight:bold">server</span> { </span></span><span style="display:flex;"><span> <span style="font-weight:bold">listen</span> 80; </span></span><span style="display:flex;"><span> <span style="font-weight:bold">server_name</span> <span style="font-style:italic">www.garhve.com</span> <span style="font-style:italic">garhve.com</span>; </span></span><span style="display:flex;"><span> <span style="font-weight:bold">return</span> 301 <span style="font-style:italic">https://garhve.com</span>$request_uri; diff --git a/posts/3/index.html b/posts/3/index.html index 1a5acd0..bef5f11 100644 --- a/posts/3/index.html +++ b/posts/3/index.html @@ -125,7 +125,7 @@ delete file foo every minute * * * * * rm foo delete file foo every 15 minutes 1 <h3 id="crontab">Crontab</h3> <p><code>crontab</code> is a useful tool, I really regret that I don’t familar it earlier.</p> <p>It’s usage really simple, and these two are my frequent using:</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>crontab -e <span style="font-style:italic">#edit crontab file that reside in /var/spool/cron</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>crontab -e <span style="font-style:italic">#edit crontab file that reside in /var/spool/cron</span> </span></span><span style="display:flex;"><span>crontab -l <span style="font-style:italic">#list current crontab job</span> </span></span></code></pre></div><p>It basic syntax as follow, also really simple <img src="https://assets.garhve.com/pictures/screenshots/2022/08/1857817000.jpg" alt="crontab-layout.jpg"></p> @@ -185,7 +185,7 @@ e.g. <code>echo path/to/most/inner/file | cut -d '/' -f1</code> this will give m </blockquote> <h3 id="daily-update-bt-tracker">Daily update bt tracker</h3> <p>I already learn shell script for a while.. so I wrote a simple script to test whether I really got used to it, but result is obviously, I need more and more practice to memorize commands.</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="">#! /bin/sh +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="">#! /bin/sh </span></span></span><span style="display:flex;"><span><span style=""></span><span style="font-style:italic">#bt-tracker.txt</span> </span></span><span style="display:flex;"><span>site=https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt </span></span><span style="display:flex;"><span> @@ -231,15 +231,15 @@ e.g. <code>echo path/to/most/inner/file | cut -d '/' -f1</code> this will give m <ul> <li>This will only search through those files which have .c or .h extensions:</li> </ul> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --include=<span style="font-weight:bold;font-style:italic">\*</span>.{c,h} -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --include=<span style="font-weight:bold;font-style:italic">\*</span>.{c,h} -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> </span></span></code></pre></div><ul> <li>This will exclude searching all the files ending with .o extension:</li> </ul> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --exclude=<span style="font-weight:bold;font-style:italic">\*</span>.o -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --exclude=<span style="font-weight:bold;font-style:italic">\*</span>.o -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> </span></span></code></pre></div><ul> <li>For directories it’s possible to exclude one or more directories using the <code>--exclude-dir</code> parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:</li> </ul> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --exclude-dir={dir1,dir2,*.dst} -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>grep --exclude-dir={dir1,dir2,*.dst} -rnw <span style="font-style:italic">'/path/to/somewhere/'</span> -e <span style="font-style:italic">"pattern"</span> </span></span></code></pre></div><p>more info could see <a href="https://ss64.com/bash/grep.html"><code>man grep</code></a>.</p> </blockquote> diff --git a/posts/5/index.html b/posts/5/index.html index b66075b..ee99aa3 100644 --- a/posts/5/index.html +++ b/posts/5/index.html @@ -140,7 +140,7 @@ Arguments are delimeted by semi colon (;)." /> <p>Followed by the command, somtimes delimited by opening square bracket (<code>[</code>), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.</p> <p>Arguments are delimeted by semi colon (<code>;</code>).</p> <p>For example:</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="font-weight:bold;font-style:italic">\x</span>1b[1;31m <span style="font-style:italic"># Set style to bold, red foreground.</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="font-weight:bold;font-style:italic">\x</span>1b[1;31m <span style="font-style:italic"># Set style to bold, red foreground.</span> </span></span></code></pre></div><h2 id="sequences">Sequences</h2> <ul> <li><code>ESC</code> - sequence starting with <code>ESC</code> (<code>\x1B</code>)</li> @@ -513,7 +513,7 @@ Arguments are delimeted by semi colon (;)." /> <p><strong>Note:</strong> the <em>Reset</em> color is the reset code that resets <em>all</em> colors and text effects, Use <em>Default</em> color to reset colors only.</p> </blockquote> <p>Most terminals, apart from the basic set of 8 colors, also support the “bright” or “bold” colors. These have their own set of codes, mirroring the normal colors, but with an additional <code>;1</code> in their codes:</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="font-style:italic"># Set style to bold, red foreground.</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span><span style="font-style:italic"># Set style to bold, red foreground.</span> </span></span><span style="display:flex;"><span><span style="font-weight:bold;font-style:italic">\x</span>1b[1;31mHello </span></span><span style="display:flex;"><span><span style="font-style:italic"># Set style to dimmed white foreground with red background.</span> </span></span><span style="display:flex;"><span><span style="font-weight:bold;font-style:italic">\x</span>1b[2;37;41mWorld @@ -740,7 +740,7 @@ Arguments are delimeted by semi colon (;)." /> <p>Note: While these modes may be supported by the most terminals, some may not work in multiplexers like tmux.</p> </blockquote> <h3 id="keyboard-strings">Keyboard Strings</h3> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ESC[{code};{string};{...}p +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-sh" data-lang="sh"><span style="display:flex;"><span>ESC[{code};{string};{...}p </span></span></code></pre></div><p>Redefines a keyboard key to a specified string.</p> <p>The parameters for this escape sequence are defined as follows:</p> <ul> diff --git a/posts/6/index.html b/posts/6/index.html index 2828d15..4baa0c6 100644 --- a/posts/6/index.html +++ b/posts/6/index.html @@ -149,7 +149,7 @@ Redirection File Redirection 0 is standard input, 1 is standard output, 2 is sta <p>the connection to the stream used by FD <code>y</code> is copied to FD <code>x</code></p> <p><code>curl cip.cc > result 2>&1</code></p> <p><code>ping localhost > result 2>&1</code></p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"># exec can be used to change the file descriptors of bash itself,</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"># exec can be used to change the file descriptors of bash itself,</span> </span></span><span style="display:flex;"><span><span style="font-style:italic"># and if you use an x that doesn't yet exist,</span> </span></span><span style="display:flex;"><span><span style="font-style:italic"># bash will create a new file descriptor ("plug") for you with that number.</span> </span></span><span style="display:flex;"><span><span style="font-style:italic"># - in command is to close new FD 3 we'd created before.</span> @@ -172,13 +172,13 @@ Redirection File Redirection 0 is standard input, 1 is standard output, 2 is sta <p><code>ping localhost &>result</code></p> </blockquote> <h3 id="here-documents">Here documents</h3> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"><<delimiter +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"><<delimiter </span></span></span><span style="display:flex;"><span><span style="font-style:italic"> Here document </span></span></span><span style="display:flex;"><span><span style="font-style:italic">delimiter</span> </span></span></code></pre></div><p>Make FD 0 read from the string between <code>delimiter</code>s</p> <blockquote> <p>Here-Documents are great for reading blocks of text to command line.</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>cat <span style="font-style:italic"><< EOF +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>cat <span style="font-style:italic"><< EOF </span></span></span><span style="display:flex;"><span><span style="font-style:italic">this is within here document </span></span></span><span style="display:flex;"><span><span style="font-style:italic">I can write as many lines as I like </span></span></span><span style="display:flex;"><span><span style="font-style:italic">and terminate with line of demiliter only @@ -189,7 +189,7 @@ Redirection File Redirection 0 is standard input, 1 is standard output, 2 is sta <p>Make FD 0 read from the <code>string</code></p> <blockquote> <p>Here strings are very similar to here documents but more concise. They are generally preferred over here documents.</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>cat <<< <span style="font-style:italic">"This, +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>cat <<< <span style="font-style:italic">"This, </span></span></span><span style="display:flex;"><span><span style="font-style:italic">is the here strings. tab will also be read."</span> </span></span></code></pre></div></blockquote> <h3 id="moving-file-decipher">Moving file decipher</h3> @@ -197,7 +197,7 @@ Redirection File Redirection 0 is standard input, 1 is standard output, 2 is sta <p>Replace FD <code>x</code> with FD <code>y</code> and close FD <code>y</code></p> <blockquote> <p>Easy way of <code>[x]>&y, y>&-</code></p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"># 3>&1-: copy FD 1 to FD 3 and close FD 1.</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"># 3>&1-: copy FD 1 to FD 3 and close FD 1.</span> </span></span><span style="display:flex;"><span><span style="font-style:italic"># >&3-: copy FD 3 to FD 1 and close FD 3.</span> </span></span><span style="display:flex;"><span>exec 3>&1- >mylog; echo moo; exec >&3- </span></span></code></pre></div></blockquote> @@ -206,7 +206,7 @@ Redirection File Redirection 0 is standard input, 1 is standard output, 2 is sta <p>Open FD <code>x</code> for both reading and writing to <code>file</code></p> <blockquote> <p>The file descriptor at x is opened with a stream to the file that can be used for writing as well as reading bytes. Usually you’ll use two file descriptors for this. <strong>One of the rare cases where this is useful is when setting up a stream with a read/write device such as a network socket</strong>.</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>exec 5<>aFile +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>exec 5<>aFile </span></span><span style="display:flex;"><span>cat >&5 <span style="font-style:italic">"Hello world"</span> <span style="font-style:italic"># make FD 1 write to where FD 5 currently writing, copy file descriptor FD 5 to FD 1</span> </span></span><span style="display:flex;"><span>cat <&5 <span style="font-style:italic"># make FD 0 read from where FD 5 currently reading, copy file descriptor FD 5 to FD 0, then cat will send content to FD 1</span> </span></span></code></pre></div></blockquote> @@ -248,7 +248,7 @@ zsh. : <code>setopt extendedglob</code> </ol> <h3 id="command-substitution">Command Substitution</h3> <p>we can expansion commands within commands, but must use double-quote <code>""</code> instead of <code>''</code></p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"># this will output contents in hello.h to screen</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"># this will output contents in hello.h to screen</span> </span></span><span style="display:flex;"><span>cat hello.h </span></span><span style="display:flex;"><span> </span></span><span style="display:flex;"><span><span style="font-style:italic"># this will expand `cat hello.h` to real contents in </span> @@ -296,7 +296,7 @@ zsh. : <code>setopt extendedglob</code> <p>In addition, we can put braces (<code>{</code> and <code>}</code>) around our parameter, which indicates where variable is about to begin and end.</p> <blockquote> <p>e.g. <code>name=orange; echo there are 4 "${name}s"</code> <code>there are 4 oranges</code>.</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>name=orange +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span>name=orange </span></span><span style="display:flex;"><span>echo <span style="font-style:italic">"there are 4 </span><span style="font-weight:bold;font-style:italic">${</span>name<span style="font-weight:bold;font-style:italic">}</span><span style="font-style:italic">s."</span> <span style="font-style:italic"># there are 4 oranges.</span> </span></span><span style="display:flex;"><span>echo <span style="font-style:italic">"there are 4 </span>$names<span style="font-style:italic">."</span> <span style="font-style:italic"># there are 4 .</span> </span></span></code></pre></div><p>here, we put <code>{}</code>around<code>name</code>so that bash can be told that suffix <code>s</code> is not a part of variable. otherwise, it will treat <code>names</code> as parameter and looking for its value, which is none in our example.</p> @@ -305,7 +305,7 @@ zsh. : <code>setopt extendedglob</code> <blockquote> <p>While expanding a parameter, it is possible to apply an operator to the expanding value without alternate original value.</p> <p>I use these mostly</p> -<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:2;-o-tab-size:2;tab-size:2;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"># remove string before pattern ${name#pattern} shortest ${name##pattern} longest</span> +<div class="highlight"><pre tabindex="0" style="background-color:#fff;-moz-tab-size:4;-o-tab-size:4;tab-size:4;"><code class="language-bash" data-lang="bash"><span style="display:flex;"><span><span style="font-style:italic"># remove string before pattern ${name#pattern} shortest ${name##pattern} longest</span> </span></span><span style="display:flex;"><span><span style="font-style:italic"># remove string after pattern ${name%pattern} longest ${name%%pattern} shortest</span> </span></span><span style="display:flex;"><span><span style="font-style:italic"># delete first matching pattern ${name/pattern}</span> </span></span><span style="display:flex;"><span><span style="font-style:italic"># delete all matching pattern ${name//pattern}</span> |