From 4c9c9ab88cec6b8c9364917564484d9170a55b3c Mon Sep 17 00:00:00 2001
From: garhve
太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~
-######################################################################
-# @author : garhve (dev@garhve.com)
-# @file : blog
-# @created : Friday Dec 09, 2022 16:09:42 CST
-#
-# @description : simplify blog publishing.
-######################################################################
-
-p="$(pwd)"
-
-cd "$HOME/Storage/data/blog"
-
-echo "Enter the blog name"
-read -r name
-
-hugo new posts/"$name"
-
-echo "1. en"
-echo "2. cn"
-echo "all option would be default to 1 except 2[1 or 2]: "
-read l
-
-if [ $l -eq 1 ]; then
- lang="en"
-elif [ $l -eq 2 ]; then
- lang="cn"
-else
- lang="en"
-fi
-[ $lang == "cn" ] && mv "content/en/posts/$name" "content/cn/posts/$name"
-vim "content/$lang/posts/$name"
-
-hugo
-cd public
-git add .
-read -r -p "commit message: " com
-git commit -m "$com"
-
-cd "$p"
-
这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 +
这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 也许可以将代码优化下以后就省心了,哈哈。
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 -> vim 找到文章 -> 保存或者发布 -> 然后到public文件夹 push出去。 太麻烦了,我就写了个简单的脚本来简化一下流程,反正是自用的,所以也不用考虑 怎么处理不同的位置,并且原先由于发布比较繁琐,草稿就都存在本地了,现在 我也可以直接将草稿发布出来,看得见,我才有动力写~ -###################################################################### # @author : garhve (dev@garhve.com) # @file : blog # @created : Friday Dec 09, 2022 16:09:42 CST # # @description : simplify blog publishing. +这片文章的出现,也只是我想确认一下能不能正确处理好中文内容。这样一说,突然想起来编辑也挺麻烦的。。 也许可以将代码优化下以后就省心了,哈哈。Due to personal interest, I didn’t choose frame to base my website. I use Nginx 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.
In order to use https instead of http, I choosed let’s encrypt, 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.
I found solutions all about using return to returning https, but it won’t work
-server {
+server {
server_name www.garhve.com;
return 301 https://www.garhve.com$request_uri
}
@@ -135,7 +135,7 @@ Due to personal interest, I didn’t choose frame to base my website. I
After searching and searching, I found where i was getting wrong.
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.
So, change to this one
-server {
+server {
listen 80;
server_name www.garhve.com garhve.com;
return 301 https://garhve.com$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
Crontab
crontab
is a useful tool, I really regret that I don’t familar it earlier.
It’s usage really simple, and these two are my frequent using:
-crontab -e #edit crontab file that reside in /var/spool/cron
+crontab -e #edit crontab file that reside in /var/spool/cron
crontab -l #list current crontab job
It basic syntax as follow, also really simple

@@ -185,7 +185,7 @@ e.g. echo path/to/most/inner/file | cut -d '/' -f1
this will give m
Daily update bt tracker
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.
-#! /bin/sh
+#! /bin/sh
#bt-tracker.txt
site=https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_all.txt
@@ -231,15 +231,15 @@ e.g. echo path/to/most/inner/file | cut -d '/' -f1
this will give m
- This will only search through those files which have .c or .h extensions:
-grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
+grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
- This will exclude searching all the files ending with .o extension:
-grep --exclude=\*.o -rnw '/path/to/somewhere/' -e "pattern"
+grep --exclude=\*.o -rnw '/path/to/somewhere/' -e "pattern"
- For directories it’s possible to exclude one or more directories using the
--exclude-dir
parameter. For example, this will exclude the dirs dir1/, dir2/ and all of them matching *.dst/:
-grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
+grep --exclude-dir={dir1,dir2,*.dst} -rnw '/path/to/somewhere/' -e "pattern"
more info could see man grep
.
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 (;)." />
Followed by the command, somtimes delimited by opening square bracket ([
), known as a Control Sequence Introducer (CSI), optionally followed by arguments and the command itself.
Arguments are delimeted by semi colon (;
).
For example:
-\x1b[1;31m # Set style to bold, red foreground.
+\x1b[1;31m # Set style to bold, red foreground.
Sequences
ESC
- sequence starting with ESC
(\x1B
)
@@ -513,7 +513,7 @@ Arguments are delimeted by semi colon (;)." />
Note: the Reset color is the reset code that resets all colors and text effects, Use Default color to reset colors only.
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 ;1
in their codes:
-# Set style to bold, red foreground.
+# Set style to bold, red foreground.
\x1b[1;31mHello
# Set style to dimmed white foreground with red background.
\x1b[2;37;41mWorld
@@ -740,7 +740,7 @@ Arguments are delimeted by semi colon (;)." />
Note: While these modes may be supported by the most terminals, some may not work in multiplexers like tmux.
Keyboard Strings
-ESC[{code};{string};{...}p
+ESC[{code};{string};{...}p
Redefines a keyboard key to a specified string.
The parameters for this escape sequence are defined as follows:
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
the connection to the stream used by FD y
is copied to FD x
curl cip.cc > result 2>&1
ping localhost > result 2>&1
-# exec can be used to change the file descriptors of bash itself,
+# exec can be used to change the file descriptors of bash itself,
# and if you use an x that doesn't yet exist,
# bash will create a new file descriptor ("plug") for you with that number.
# - in command is to close new FD 3 we'd created before.
@@ -172,13 +172,13 @@ Redirection File Redirection 0 is standard input, 1 is standard output, 2 is sta
ping localhost &>result
Here documents
-<<delimiter
+<<delimiter
Here document
delimiter
Make FD 0 read from the string between delimiter
s
Here-Documents are great for reading blocks of text to command line.
-cat << EOF
+cat << EOF
this is within here document
I can write as many lines as I like
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
Make FD 0 read from the string
Here strings are very similar to here documents but more concise. They are generally preferred over here documents.
-cat <<< "This,
+cat <<< "This,
is the here strings. tab will also be read."
Moving file decipher
@@ -197,7 +197,7 @@ Redirection File Redirection 0 is standard input, 1 is standard output, 2 is sta
Replace FD x
with FD y
and close FD y
Easy way of [x]>&y, y>&-
-# 3>&1-: copy FD 1 to FD 3 and close FD 1.
+# 3>&1-: copy FD 1 to FD 3 and close FD 1.
# >&3-: copy FD 3 to FD 1 and close FD 3.
exec 3>&1- >mylog; echo moo; exec >&3-
@@ -206,7 +206,7 @@ Redirection File Redirection 0 is standard input, 1 is standard output, 2 is sta
Open FD x
for both reading and writing to file
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. 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.
-exec 5<>aFile
+exec 5<>aFile
cat >&5 "Hello world" # make FD 1 write to where FD 5 currently writing, copy file descriptor FD 5 to FD 1
cat <&5 # 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
@@ -248,7 +248,7 @@ zsh. : setopt extendedglob
Command Substitution
we can expansion commands within commands, but must use double-quote ""
instead of ''
-# this will output contents in hello.h to screen
+# this will output contents in hello.h to screen
cat hello.h
# this will expand `cat hello.h` to real contents in
@@ -296,7 +296,7 @@ zsh. : setopt extendedglob
In addition, we can put braces ({
and }
) around our parameter, which indicates where variable is about to begin and end.
e.g. name=orange; echo there are 4 "${name}s"
there are 4 oranges
.
-name=orange
+name=orange
echo "there are 4 ${name}s." # there are 4 oranges.
echo "there are 4 $names." # there are 4 .
here, we put {}
aroundname
so that bash can be told that suffix s
is not a part of variable. otherwise, it will treat names
as parameter and looking for its value, which is none in our example.
@@ -305,7 +305,7 @@ zsh. : setopt extendedglob
While expanding a parameter, it is possible to apply an operator to the expanding value without alternate original value.
I use these mostly
-# remove string before pattern ${name#pattern} shortest ${name##pattern} longest
+# remove string before pattern ${name#pattern} shortest ${name##pattern} longest
# remove string after pattern ${name%pattern} longest ${name%%pattern} shortest
# delete first matching pattern ${name/pattern}
# delete all matching pattern ${name//pattern}
--
cgit v1.2.3-70-g09d2