xgqfrms™, xgqfrms® : xgqfrms's offical website of cnblogs! xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

Oh My Zsh & zsh All In One

Oh My Zsh & zsh All In One

https://ohmyz.sh/

Linux shells

Raspberry Pi

eric@rpi4b:~ $ cat /etc/shells
# /etc/shells: valid login shells
/bin/sh
/bin/bash
/usr/bin/bash
/bin/rbash
/usr/bin/rbash
/bin/dash
/usr/bin/dash
/bin/mksh
/usr/bin/mksh
/bin/mksh-static
/usr/lib/klibc/bin/mksh-static
eric@rpi4b:~ $ 

install

# CURL
$ sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

# wget
$ sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"


# chage shell 
# set zsh as default shell (this will ask for your password):
$ chsh -s /bin/zsh

for command not found bug

#!/usr/bin/env bash

echo 🎉 emoji ^-v-^
# -e 换行
echo -e "\n"

arg1=$1
arg2=$2
arg3=$3
arg4=$4
arg5=$5
arg6=$6
arg7=$7
arg8=$8
arg9=$9
# >= 10, $n => ${n} ✅
arg10=${10}
arg11=${11}
arg12=${12}

# echo $arg1
# echo $arg2
# echo $arg3
# echo $arg4
# echo $arg5
# echo $arg6
# echo $arg7
# echo $arg8
# echo $arg9
# echo $arg10
# echo $arg11
# echo $arg12
# 🚀 ✅, 参数可以为空
all=$((arg1 + arg2 + arg3 + arg4 + arg5 + arg6 + arg7 + arg8 + arg9 + arg10 + arg11 + arg12))

# -e 换行
echo -e "\n"
echo $all

# -e 换行
echo -e "\n"

# \ 转义符
echo "\$* 参数整体:" $*
echo "\$@ 参数列表:" $@
echo "\$# 参数个数:" $#


​for i in "$*"
do
  echo "\$* 参数整体, 参数 i" $i
done

​for j in "$@"
do
  echo "\$@ 参数列表, 参数 j" $j
done

# DEMO
# ./for-loop.sh 1 2 3 4 5 6 7 8 9 10 11 12

# 55 + 23 = 78
# const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12];
# arr.reduce((acc, item) => acc += item, 0);

<U+200B> for, Zero Width Space ❌

Unicode 编码问题

https://www.cnblogs.com/xgqfrms/p/14238660.html

demos

eric@rpi4b:~ $ cat  /etc/rc.local
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.

# Print the IP address
_IP=$(hostname -I) || true
if [ "$_IP" ]; then
  printf "My IP address is %s\n" "$_IP"
fi

exit 0

eric@rpi4b:~ $ cat .profile
# ~/.profile: executed by the command interpreter for login shells.
# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login
# exists.
# see /usr/share/doc/bash/examples/startup-files for examples.
# the files are located in the bash-doc package.

# the default umask is set in /etc/profile; for setting the umask
# for ssh logins, install and configure the libpam-umask package.
#umask 022

# if running bash
if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
	. "$HOME/.bashrc"
    fi
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
    PATH="$HOME/bin:$PATH"
fi

# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
    PATH="$HOME/.local/bin:$PATH"
fi

echo "每次登录自动执行脚本 ✅"
bash /home/eric/Desktop/ip-program.sh

echo "OLED 后台运行 ✅"
sudo python3 /home/eric/Desktop/oled.sh &

# echo "开启SSD1306 OLED 🖥️ 🌡️"
# sudo python3 /home/eric/OLED_Stats/stats.py &
eric@rpi4b:~ $ 

(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

#!/bin/sh

#!/usr/bin/bash vs #!/usr/bin/env bash

dd-ip-notice-robot.sh

#!/usr/bin/env bash
# coding: utf8

# 自动发送树莓派 ip 地址,到钉钉上
DD_ROBOT_TOKEN=404e996c8747ea*******6f2732f9111bd3f39ce36d17fa1202
echo $DD_ROBOT_TOKEN

WIFI=$(ifconfig | grep "192.168")

# ✅ $(可执行命令)
# $(ifconfig | grep "192.168" > ip.md)
$(ifconfig | perl -nle'/(\d+\.\d+\.\d+\.\d+)/ && print $1' | sed '1 d' > ip.md)

# ✅ read file
RPI_IP=$(cat ./ip.md)

Smbol=$(echo '$')
BR=$(echo '<br/>')
LB=$(echo '\n')

echo $RPI_IP

MARKDOWN='
{
  "msgtype": "markdown",
  "markdown": {
    "title":"🤖 树莓派开机自动发送 Wi-Fi IP 地址消息: ",
    "text": "
# 🍓 Raspberry Pi IP: ['${RPI_IP}']('$RPI_IP') \n

> 🔑 API Token: '$WIFI'

```sh
#!/usr/bin/env bash
# coding: utf8

'$Smbol' hostname -d

多行文本换行测试 ✅
缩进测试 ❌ 不好使
\n ❌ 不好使
'\(LB' n ❌ 不好使 '\)BR' br ❌ 不好使

markdown 末尾空格换行 🚀
1空格换行 ❌
2 空格换行 ✅
3 空格换行 ✅
换行测试
"
},
"at": {
"atUserIds": [
"xgqfrms"
],
"isAtAll": false
}
}'

echo $MARKDOWN

curl "https://oapi.dingtalk.com/robot/send?access_token=\(DD_ROBOT_TOKEN" \ -H "Content-Type: application/json" \ -d "\)MARKDOWN"

echo "finished ✅"

退出程序执行,exit 0 后面命令不会执行

exit 0

echo "这里的命令不会执行了,dead code 💩"





## refs

https://github.com/ohmyzsh/ohmyzsh

https://www.cnblogs.com/xgqfrms/p/10648243.html

https://divinenanny.nl/blog/2021-08-07-install-oh-my-zsh-on-raspberry-pi/

https://linuxhint.com/install-zsh-raspberry-pi/

https://linuxhint.com/prettify-raspberry-pi-shell-with-oh-my-zsh/


***

<div>
  <a href="https://info.flagcounter.com/QIXi">
    <img src="https://s11.flagcounter.com/count2/QIXi/bg_000000/txt_00FF00/border_FF00FF/columns_3/maxflags_12/viewers_0/labels_1/pageviews_1/flags_0/percent_1/" alt="Flag Counter" border="0">
  </a>
</div>


***

<blockquote style="display: flex; flex-flow: column; align-items: center; justify-content: center; text-align: center; border: none;">
  <h3><strong><span style="font-size: 16pt; color: #00ff00;">©xgqfrms 2012-<span data-uid="copyright-aside">2021</span></strong></span</h3>
  <p><span style="font-size: 18pt; color: #00ff00;"><strong>www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!</strong></span></p>
  <p><span style="font-size: 18pt; color: #00ff00;"><strong>原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!</strong></span></p>
</blockquote>

***
posted @ 2020-12-28 14:13  xgqfrms  阅读(94)  评论(7编辑  收藏  举报