Oh My Zsh & zsh All In One
Oh My Zsh & zsh All In One
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:~ $
#!/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 ❌ 不好使 </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/
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/14201303.html
未经授权禁止转载,违者必究!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)
2019-12-28 SVG Tutorials
2019-12-28 SVG to GeoJSON All In One
2018-12-28 Fetch POST All in One
2018-12-28 old vue & scss
2018-12-28 vue shorthands
2018-12-28 tooltips & click copy
2015-12-28 使用 ReStructuredText + Sphinx + Python 开发wiki ebooks!