文章目录快速linux命令行美化指南环境准备:换国内源加速ubuntu 22ubuntu 24ltsc传统格式deb格式kali-linux基础软件apt系列pacman系列Oh my zsh基础软件环境准备国外环境安装omz国内推荐安装方式一键安装omz修改默认shell(可选)oh-my-zsh 插件配置oh my zsh主题美化ls的输出其他修改系统时间主机名配置fzf快速linux命令行美化指南主要适配于Debian系的linux发行版由于不同发行版换源的动作各有差异,这里就不展开了(默认用户都搞定了,最好还搞定了ssh链接)主要介绍利用Oh my zsh来美化,并且在国内网络环境下也能够快速下载安装的开门见山的脚本集合理想情况下,不需要太多时间就可以完成部署环境准备:换国内源加速如果是国外服务器,通常不需要此环节,直接跳转到基础软件开始先更换软件镜像源(不同发行版有不同的源,另见它文),然后执行下列任务ubuntu 22# ubuntu 更换国内镜像源(清华源为例)# 备份:backup the origin source.list(or just rename(use move command))# 注意sources.list 不要拼错(带s)cd/etc/aptsudomvsources.list sources.list.bak_bySh# 切换到家目录,写入国内镜像源到一个文件中(文件名为sources.list),采用多行输入的方式写入#这里以阿里源为例cd~# 多行输入sudoteesources.listEOF #换源内容粘贴在这里面 # 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse # deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse # 预发布软件源不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse #结束文档 EOF#上面的EOF间的内容不要写入其他与源无关的内容(除了注释和源,其他命令不要写在里头)# 检查写入的内容:echocheck the conetent of the file source.list## 将家目录下的sources.list 转移到/etc/apt目录下(sodu可以作用与mv/cp等命令,## 但好像不可以直接作用于cat,所以没有直接在/etc/apt目录下创建新文件)sudomvsources.list /etc/aptcat/etc/apt/sources.list# 更新并使得apt配置文件生效echoupdating the apt...sudoaptupdate#可选的升级#sudo apt upgradeubuntu 24ltsc传统格式以ubuntu 24 ltsc为例的一键换源脚本(模板)# ubuntu 更换国内镜像源(清华源为例)# 备份:backup the origin source.list(or just rename(use move command))# 注意sources.list 不要拼错(带s)cd/etc/aptsudomvsources.list sources.list.bak_bySh# 切换到家目录,写入国内镜像源到一个文件中(文件名为sources.list),采用多行输入的方式写入#这里以阿里源为例cd~# 多行输入sudoteesources.listEOF #换源内容粘贴在这里面 # 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse # 以下安全更新软件源包含了官方源与镜像站配置如有需要可自行修改注释切换 deb http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse # deb-src http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse # 预发布软件源不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-proposed main restricted universe multiverse # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-proposed main restricted universe multiverse #结束文档 EOF#上面的EOF间的内容不要写入其他与源无关的内容(除了注释和源,其他命令不要写在里头)# 检查写入的内容:echocheck the conetent of the file source.list## 将家目录下的sources.list 转移到/etc/apt目录下(sodu可以作用与mv/cp等命令,## 但好像不可以直接作用于cat,所以没有直接在/etc/apt目录下创建新文件)sudomvsources.list /etc/aptcat/etc/apt/sources.list# 更新并使得apt配置文件生效echoupdating the apt...sudoaptupdate#可选的升级#sudo apt upgradedeb格式cd/etc/apt/sources.list.d#sudo vim tuna.sources# 多行输入sudoteetuna.sourcesEOF Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu Suites: noble noble-updates noble-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释 # Types: deb-src # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: noble noble-updates noble-backports # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 以下安全更新软件源包含了官方源与镜像站配置如有需要可自行修改注释切换 Types: deb URIs: http://security.ubuntu.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # Types: deb-src # URIs: http://security.ubuntu.com/ubuntu/ # Suites: noble-security # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 预发布软件源不建议启用 # Types: deb # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: noble-proposed # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # # Types: deb-src # # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # # Suites: noble-proposed # # Components: main restricted universe multiverse # # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg #结束文档 EOF# 最后将原来的ubuntu.sources移动到备份目录cd/etc/apt/sources.list.dsudomkdir/etc/apt/sources.list.d/baksudomvubuntu.sources ./bak#执行刷新sudoaptupdatekali-linux# 备份:backup the origin source.list(or just rename(use move command))# 注意sources.list 不要拼错(带s)cd/etc/aptsudomvsources.list sources.list.bak_bySh# 切换到家目录,写入国内镜像源到一个文件中(文件名为sources.list),采用多行输入的方式写入#这里以阿里源为例cd~# 多行输入[国内源]catsources.listEOF deb https://mirrors.aliyun.com/kali kali-rolling main non-free contrib deb-src https://mirrors.aliyun.com/kali kali-rolling main non-free contrib EOF#上面的EOF间的内容不要写入其他与源无关的内容(除了注释和源,其他命令不要写在里头)# 检查写入的内容:echocheck the conetent of the file source.list## 将家目录下的sources.list 转移到/etc/apt目录下(sodu可以作用与mv/cp等命令,## 但好像不可以直接作用与cat,所以没有直接在/etc/apt目录下创建新文件)sudomvsources.list /etc/aptcat/etc/apt/sources.list# 更新并使得apt配置文件生效echoupdating the apt...sudoaptupdate# 其他写法:探索中# sourceCN# deb https://mirrors.aliyun.com/kali kali-rolling main non-free contrib# deb-src https://mirrors.aliyun.com/kali kali-rolling main non-free contrib# # echo $sourceCN# sudo catsource.listEOF# echo $sourceCN# EOF基础软件apt系列# 工作目录设定为用户家目录cd~sudoaptupdatesudoaptinstallzshcurlgitmanwget-ypacman系列可以分别检查以下软件包,如果已经安装过的,就从列表中删除,避免重复按装浪费资源windows上msys2也使用pacman来管理软件包,pacman可以获取很新的软件包,并且换源简单,而且安装速度很快cd~ pacman-SzshcurlgitmanwgetOh my zshhttps://github.com/ohmyzsh/ohmyzsh镜像加速站:Gitee 极速下载/oh-my-zshOh My Zsh - a delightful open source framework for Zsh以下两种安装方式,如果网络环境不好,容易失败sh -c $(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)sh -c $(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)基础软件环境准备参考上一节国外环境安装omz注意,仍然要预先安装依赖软件(比如zsh,git等)如果服务器在国外,那么访问github比较快,可以不用更改源ohmyzsh/ohmyzsh basic installationsh -c $(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)国内推荐安装方式一键安装omz# 工作目录设定为用户家目录cd~wgethttps://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh# 由于国内网络问题,可能需要多尝试几次一下source 命令才可以安装成功.(我将其注释掉,采用换源后再执行clone#source install.sh#本段代码将修改install.sh中的拉取源,以便您能够冲gitee上成功将需要的文件clone下来.# 本段代码会再修改前做备份(备份文件名为install.shE)sed/(^remote)|(^repo)/I s/^#*/#/ ; /^#*remote/I a\ REPO${REPO:-mirrors/oh-my-zsh}\ REMOTE${REMOTE:-https://gitee.com/${REPO}.git} -r~/install.shgitee_install.sh# 执行安装sourcegitee_install.sh#返回到脚本所在目录(以便执行新的脚本)cd-修改默认shell(可选)使用chsh命令来修改默认shell查看可用shellchsh-l切换默认shell,例如将当前用户默认shell改为/usr/bin/zshchsh-s/usr/bin/zshoh-my-zsh 插件这里推荐2个插件zsh-users/zsh-autosuggestions: Fish-like autosuggestions for zsh (github.com)zsh-users/zsh-syntax-highlighting: Fish shell like syntax highlighting for Zsh.下载插件到对应的目录(.oh-my-zsh)使用浅克隆加速(这一步在zsh或bash下执行都可)# 将两个插件下载到指定目录下:(git 已经指定好了目录)gitclone--depth1https://gitee.com/zsh-users/zsh-autosuggestions${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionsgitclone--depth1https://gitee.com/zsh-users/zsh-syntax-highlighting.git${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting在bash下调用sed来配置.zshrc文件,将相关插件配置到zsh插件(plugins)中#bash#将工作目录转移到家目录cd~path.zshrcsed/(^plugins)/ s/^#*/#/; /^#*plugins/ a\ plugins(\ git\ z\ zsh-syntax-highlighting\ zsh-autosuggestions\ # 注意,sed命令的后续不能换行\ )-r-iE$path#检查配置文件是否有相应的行cat~/.zshrc|grep-ezsh-syntax-highlighting-ezsh-autosuggestions进入到zsh刷新~/.zshrc,让zsh的配置生效(直接输入zsh即可)#zsh(可选)source~/.zshrc4.现在到下一节配置oh my zsh主题配置oh my zsh主题进入zsh,然后执行以下内容zshrc~/.zshrcecho$zshrc# 利用sed并启用扩展正则原地修改,将Zsh主题设置为随机sed-Eis/(^ZSH_THEME)(.*)/\1random/$zshrc#设置随机选择的主题的列表为ys,junkfood,rkj-repos;具体可以改成自己喜欢的主题sed-Ei.baks/(^#*\s*)(ZSH_THEME_RANDOM.*)(.*)/\2(ys junkfood )/$zshrc#检查修改结果cat~/.zshrc|grep-E^[^#]|grep-erandom-eTHEME-eRANDOM|cat-n#刷新配置结果source$zshrc美化ls的输出使用lsd等现代化的ls来提高列举体验其他针对ubuntu修改系统时间修改为北京时间sudotimedatectl set-timezone Asia/Shanghai主机名sudohostnamectl set-hostnameNewHostName#重载日志服务(否则许多日志还是使用旧主机名,例如:/var/log/auth.log)systemctl restart rsyslog然后启动一个新shell查看变化配置fzf安装fzf(建议用brew来安装,版本比较新,apt安装的版本比较老)绑定shell
linux@提高shell命令行环境易用性@终端美化@国内网络环境友好一条龙美化(ohmyzsh)
文章目录快速linux命令行美化指南环境准备:换国内源加速ubuntu 22ubuntu 24ltsc传统格式deb格式kali-linux基础软件apt系列pacman系列Oh my zsh基础软件环境准备国外环境安装omz国内推荐安装方式一键安装omz修改默认shell(可选)oh-my-zsh 插件配置oh my zsh主题美化ls的输出其他修改系统时间主机名配置fzf快速linux命令行美化指南主要适配于Debian系的linux发行版由于不同发行版换源的动作各有差异,这里就不展开了(默认用户都搞定了,最好还搞定了ssh链接)主要介绍利用Oh my zsh来美化,并且在国内网络环境下也能够快速下载安装的开门见山的脚本集合理想情况下,不需要太多时间就可以完成部署环境准备:换国内源加速如果是国外服务器,通常不需要此环节,直接跳转到基础软件开始先更换软件镜像源(不同发行版有不同的源,另见它文),然后执行下列任务ubuntu 22# ubuntu 更换国内镜像源(清华源为例)# 备份:backup the origin source.list(or just rename(use move command))# 注意sources.list 不要拼错(带s)cd/etc/aptsudomvsources.list sources.list.bak_bySh# 切换到家目录,写入国内镜像源到一个文件中(文件名为sources.list),采用多行输入的方式写入#这里以阿里源为例cd~# 多行输入sudoteesources.listEOF #换源内容粘贴在这里面 # 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse deb http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse # deb-src http://security.ubuntu.com/ubuntu/ jammy-security main restricted universe multiverse # 预发布软件源不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-proposed main restricted universe multiverse #结束文档 EOF#上面的EOF间的内容不要写入其他与源无关的内容(除了注释和源,其他命令不要写在里头)# 检查写入的内容:echocheck the conetent of the file source.list## 将家目录下的sources.list 转移到/etc/apt目录下(sodu可以作用与mv/cp等命令,## 但好像不可以直接作用于cat,所以没有直接在/etc/apt目录下创建新文件)sudomvsources.list /etc/aptcat/etc/apt/sources.list# 更新并使得apt配置文件生效echoupdating the apt...sudoaptupdate#可选的升级#sudo apt upgradeubuntu 24ltsc传统格式以ubuntu 24 ltsc为例的一键换源脚本(模板)# ubuntu 更换国内镜像源(清华源为例)# 备份:backup the origin source.list(or just rename(use move command))# 注意sources.list 不要拼错(带s)cd/etc/aptsudomvsources.list sources.list.bak_bySh# 切换到家目录,写入国内镜像源到一个文件中(文件名为sources.list),采用多行输入的方式写入#这里以阿里源为例cd~# 多行输入sudoteesources.listEOF #换源内容粘贴在这里面 # 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释 deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-updates main restricted universe multiverse deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-backports main restricted universe multiverse # 以下安全更新软件源包含了官方源与镜像站配置如有需要可自行修改注释切换 deb http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse # deb-src http://security.ubuntu.com/ubuntu/ noble-security main restricted universe multiverse # 预发布软件源不建议启用 # deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-proposed main restricted universe multiverse # # deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ noble-proposed main restricted universe multiverse #结束文档 EOF#上面的EOF间的内容不要写入其他与源无关的内容(除了注释和源,其他命令不要写在里头)# 检查写入的内容:echocheck the conetent of the file source.list## 将家目录下的sources.list 转移到/etc/apt目录下(sodu可以作用与mv/cp等命令,## 但好像不可以直接作用于cat,所以没有直接在/etc/apt目录下创建新文件)sudomvsources.list /etc/aptcat/etc/apt/sources.list# 更新并使得apt配置文件生效echoupdating the apt...sudoaptupdate#可选的升级#sudo apt upgradedeb格式cd/etc/apt/sources.list.d#sudo vim tuna.sources# 多行输入sudoteetuna.sourcesEOF Types: deb URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu Suites: noble noble-updates noble-backports Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 默认注释了源码镜像以提高 apt update 速度如有需要可自行取消注释 # Types: deb-src # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: noble noble-updates noble-backports # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 以下安全更新软件源包含了官方源与镜像站配置如有需要可自行修改注释切换 Types: deb URIs: http://security.ubuntu.com/ubuntu/ Suites: noble-security Components: main restricted universe multiverse Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # Types: deb-src # URIs: http://security.ubuntu.com/ubuntu/ # Suites: noble-security # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # 预发布软件源不建议启用 # Types: deb # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # Suites: noble-proposed # Components: main restricted universe multiverse # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg # # Types: deb-src # # URIs: https://mirrors.tuna.tsinghua.edu.cn/ubuntu # # Suites: noble-proposed # # Components: main restricted universe multiverse # # Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg #结束文档 EOF# 最后将原来的ubuntu.sources移动到备份目录cd/etc/apt/sources.list.dsudomkdir/etc/apt/sources.list.d/baksudomvubuntu.sources ./bak#执行刷新sudoaptupdatekali-linux# 备份:backup the origin source.list(or just rename(use move command))# 注意sources.list 不要拼错(带s)cd/etc/aptsudomvsources.list sources.list.bak_bySh# 切换到家目录,写入国内镜像源到一个文件中(文件名为sources.list),采用多行输入的方式写入#这里以阿里源为例cd~# 多行输入[国内源]catsources.listEOF deb https://mirrors.aliyun.com/kali kali-rolling main non-free contrib deb-src https://mirrors.aliyun.com/kali kali-rolling main non-free contrib EOF#上面的EOF间的内容不要写入其他与源无关的内容(除了注释和源,其他命令不要写在里头)# 检查写入的内容:echocheck the conetent of the file source.list## 将家目录下的sources.list 转移到/etc/apt目录下(sodu可以作用与mv/cp等命令,## 但好像不可以直接作用与cat,所以没有直接在/etc/apt目录下创建新文件)sudomvsources.list /etc/aptcat/etc/apt/sources.list# 更新并使得apt配置文件生效echoupdating the apt...sudoaptupdate# 其他写法:探索中# sourceCN# deb https://mirrors.aliyun.com/kali kali-rolling main non-free contrib# deb-src https://mirrors.aliyun.com/kali kali-rolling main non-free contrib# # echo $sourceCN# sudo catsource.listEOF# echo $sourceCN# EOF基础软件apt系列# 工作目录设定为用户家目录cd~sudoaptupdatesudoaptinstallzshcurlgitmanwget-ypacman系列可以分别检查以下软件包,如果已经安装过的,就从列表中删除,避免重复按装浪费资源windows上msys2也使用pacman来管理软件包,pacman可以获取很新的软件包,并且换源简单,而且安装速度很快cd~ pacman-SzshcurlgitmanwgetOh my zshhttps://github.com/ohmyzsh/ohmyzsh镜像加速站:Gitee 极速下载/oh-my-zshOh My Zsh - a delightful open source framework for Zsh以下两种安装方式,如果网络环境不好,容易失败sh -c $(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)sh -c $(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)基础软件环境准备参考上一节国外环境安装omz注意,仍然要预先安装依赖软件(比如zsh,git等)如果服务器在国外,那么访问github比较快,可以不用更改源ohmyzsh/ohmyzsh basic installationsh -c $(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)国内推荐安装方式一键安装omz# 工作目录设定为用户家目录cd~wgethttps://gitee.com/mirrors/oh-my-zsh/raw/master/tools/install.sh# 由于国内网络问题,可能需要多尝试几次一下source 命令才可以安装成功.(我将其注释掉,采用换源后再执行clone#source install.sh#本段代码将修改install.sh中的拉取源,以便您能够冲gitee上成功将需要的文件clone下来.# 本段代码会再修改前做备份(备份文件名为install.shE)sed/(^remote)|(^repo)/I s/^#*/#/ ; /^#*remote/I a\ REPO${REPO:-mirrors/oh-my-zsh}\ REMOTE${REMOTE:-https://gitee.com/${REPO}.git} -r~/install.shgitee_install.sh# 执行安装sourcegitee_install.sh#返回到脚本所在目录(以便执行新的脚本)cd-修改默认shell(可选)使用chsh命令来修改默认shell查看可用shellchsh-l切换默认shell,例如将当前用户默认shell改为/usr/bin/zshchsh-s/usr/bin/zshoh-my-zsh 插件这里推荐2个插件zsh-users/zsh-autosuggestions: Fish-like autosuggestions for zsh (github.com)zsh-users/zsh-syntax-highlighting: Fish shell like syntax highlighting for Zsh.下载插件到对应的目录(.oh-my-zsh)使用浅克隆加速(这一步在zsh或bash下执行都可)# 将两个插件下载到指定目录下:(git 已经指定好了目录)gitclone--depth1https://gitee.com/zsh-users/zsh-autosuggestions${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestionsgitclone--depth1https://gitee.com/zsh-users/zsh-syntax-highlighting.git${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting在bash下调用sed来配置.zshrc文件,将相关插件配置到zsh插件(plugins)中#bash#将工作目录转移到家目录cd~path.zshrcsed/(^plugins)/ s/^#*/#/; /^#*plugins/ a\ plugins(\ git\ z\ zsh-syntax-highlighting\ zsh-autosuggestions\ # 注意,sed命令的后续不能换行\ )-r-iE$path#检查配置文件是否有相应的行cat~/.zshrc|grep-ezsh-syntax-highlighting-ezsh-autosuggestions进入到zsh刷新~/.zshrc,让zsh的配置生效(直接输入zsh即可)#zsh(可选)source~/.zshrc4.现在到下一节配置oh my zsh主题配置oh my zsh主题进入zsh,然后执行以下内容zshrc~/.zshrcecho$zshrc# 利用sed并启用扩展正则原地修改,将Zsh主题设置为随机sed-Eis/(^ZSH_THEME)(.*)/\1random/$zshrc#设置随机选择的主题的列表为ys,junkfood,rkj-repos;具体可以改成自己喜欢的主题sed-Ei.baks/(^#*\s*)(ZSH_THEME_RANDOM.*)(.*)/\2(ys junkfood )/$zshrc#检查修改结果cat~/.zshrc|grep-E^[^#]|grep-erandom-eTHEME-eRANDOM|cat-n#刷新配置结果source$zshrc美化ls的输出使用lsd等现代化的ls来提高列举体验其他针对ubuntu修改系统时间修改为北京时间sudotimedatectl set-timezone Asia/Shanghai主机名sudohostnamectl set-hostnameNewHostName#重载日志服务(否则许多日志还是使用旧主机名,例如:/var/log/auth.log)systemctl restart rsyslog然后启动一个新shell查看变化配置fzf安装fzf(建议用brew来安装,版本比较新,apt安装的版本比较老)绑定shell