配置炫酷的终端

一、MacOs系统

MacOs中终端使用Iterm2

1. 配置oh-my-zsh

Oh My Zsh的地址:https://github.com/ohmyzsh/ohmyzsh

插件的存放位置:~/.oh-my-zsh/plugins, 下载常用的插件

$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

修改配置文件

$ vim ~/.zshrc

plugins=(git zsh-syntax-highlighting)

生效配置:

$ source ~/.zshrc

2. 配置字体

安装字体:

$ brew tap homebrew/cask-fonts
$ brew cask install font-hack-nerd-font

在Iterm2中配置字体:
Iterm2->Preferences->Profiles->Text,配置Font。在这里插入图片描述

3. 配置powerlevel10

cd ~/.oh-my-zsh/themes

git clone --depth=1 https://github.com/romkatv/powerlevel10k.git powerlevel10k

~/.zshrc配置文件中的主题设置为powerlevel10k

ZSH_THEME="powerlevel10k/powerlevel10k"

配置显示的样式

$ p10k configure

4. 配置colorls

安装ruby,ruby的版本需要为2.7以上,使用ruby2.6无法安装colorls。

$ brew install ruby

配置ruby环境变量:

$ vim ~/.zshrc
export PATH="/usr/local/Cellar/ruby/2.7.2/bin:$PATH"

$ source ~./zshrc

查看ruby的版本:

$ ruby --version

ruby 2.7.2p137 (2020-10-01 revision 5445e04352) [x86_64-darwin19]

安装colorls:

$ sudo gem install colorls -n /usr/local/bin

配置~/.zshrc

$ vim ~/.zshrc

source $(dirname $(gem which colorls))/tab_complete.sh
alias ll='colorls -lA --sd --gs --group-directories-first'
alias ls='colorls --group-directories-first'
alias lc='colorls'                               # Colorls with no options
alias l='colorls -l --sort-dirs'                 # List
#alias ll='colorls -lA --git-status --sort-dirs'  # List, show almost all files (excludes ./ and ../)
alias la='colorls -la --sort-dirs'               # List, show all files
alias lt='colorls -lt  --git-status'             # List, sort by modification time (newest first)
alias lS='colorls -lS  --git-status'             # List, sort by size (largest first)
alias lr='colorls --tree=5'                      # Show tree heirarchy, capped at depth 5 just in case
alias lx='colorls -lAX --git-status'             # List, Sort by file type

5.最终效果

在这里插入图片描述

6.配置文件~/.zshrc完整内容

ZSH_DISABLE_COMPFIX=true
export ZSH="/Users/juejieli/.oh-my-zsh"
#ZSH_THEME="robbyrussell"
#ZSH_THEME="cloud"
ZSH_THEME="powerlevel10k/powerlevel10k"
#ZSH_THEME="agonster"
POWERLEVEL9K_MODE='nerdfont-complete'
plugins=(git zsh-syntax-highlighting)
source $ZSH/oh-my-zsh.sh
# To customize prompt, run `p10k configure` or edit ~/.p10k.zsh.
export PATH="/usr/local/Cellar/ruby/2.7.2/bin:$PATH"
[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
alias ll='colorls -lA --sd --gs --group-directories-first'
alias ls='colorls --group-directories-first'
alias lc='colorls'                               # Colorls with no options
alias l='colorls -l --sort-dirs'                 # List
#alias ll='colorls -lA --git-status --sort-dirs'  # List, show almost all files (excludes ./ and ../)
alias la='colorls -la --sort-dirs'               # List, show all files
alias lt='colorls -lt  --git-status'             # List, sort by modification time (newest first)
alias lS='colorls -lS  --git-status'             # List, sort by size (largest first)
alias lr='colorls --tree=5'                      # Show tree heirarchy, capped at depth 5 just in case
alias lx='colorls -lAX --git-status'             # List, Sort by file type
source $(dirname $(gem which colorls))/tab_complete.sh

二、Linux系统

系统为Debina10,终端为MATE终端

1. 配置oh-my-zsh

Oh My Zsh的地址:https://github.com/ohmyzsh/ohmyzsh

插件的存放位置:~/.oh-my-zsh/plugins, 下载常用的插件

$ git clone https://github.com/zsh-users/zsh-syntax-highlighting.git

修改配置文件

$ vim ~/.zshrc

plugins=(git zsh-syntax-highlighting)

生效配置:

$ source ~/.zshrc

2. 配置字体

下载MesloLGS NF字体:
MesloLGS NF Regular.ttf
MesloLGS NF Bold.ttf
MesloLGS NF Italic.ttf
MesloLGS NF Bold Italic.ttf

如果没有~/.local/share/fonts目录需要手动创建下

$ mkdir -p ~/.local/share/fonts

加载字体

$ fc-cache -vf ~/.local/share/fonts/

查看字体是否加载成功

$ fc-list | grep -i MesloLGS

显示结果:
/home/jjli/.local/share/fonts/MesloLGS NF Regular.ttf: MesloLGS NF:style=Regular
/home/jjli/.local/share/fonts/MesloLGS NF Bold Italic.ttf: MesloLGS NF:style=Bold Italic
/home/jjli/.local/share/fonts/MesloLGS NF Bold.ttf: MesloLGS NF:style=Bold
/home/jjli/.local/share/fonts/MesloLGS NF Regular (1).ttf: MesloLGS NF:style=Regular
/home/jjli/.local/share/fonts/MesloLGS NF Italic.ttf: MesloLGS NF:style=Italic

在终端配置中选择字体,使用MesloLGS NF Regular字体,否则终端中加载的图片有乱码。
在这里插入图片描述

3. 配置powerlevel10

$ cd ~/.oh-my-zsh/themes
$ git clone https://github.com/romkatv/powerlevel10k.git

~/.zshrc配置文件中的主题设置为powerlevel10k

ZSH_THEME="powerlevel10k/powerlevel10k"

配置主题样式

$ p10k configure

4. 配置colorls

安装相关软件包

$ sudo apt install ruby ruby-dev
$ sudo gem install colorls

~/.zshrc中添加下面配置

[[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh
if hash colorls 2>/dev/null
then
    if [ -x /usr/bin/dircolors ]; then
        test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
        alias ll='colorls -lA --sd --gs --group-directories-first'
        alias ls='colorls --group-directories-first'
        alias lc='colorls'                               # Colorls with no options
        alias l='colorls -l --sort-dirs'                 # List
        #alias ll='colorls -lA --git-status --sort-dirs'  # List, show almost all files (excludes ./ and ../)
        alias la='colorls -la --sort-dirs'               # List, show all files
        alias lt='colorls -lt  --git-status'             # List, sort by modification time (newest first)
        alias lS='colorls -lS  --git-status'             # List, sort by size (largest first)
        alias lr='colorls --tree=5'                      # Show tree heirarchy, capped at depth 5 just in case
        alias lx='colorls -lAX --git-status'             # List, Sort by file type
    fi
fi
source $(dirname $(gem which colorls))/tab_complete.sh

5.最终效果

在这里插入图片描述

6.配置colorls默认的颜色

拷贝默认的配置文件到~/.config/colorls/

mkidr -p ~/.config/colorls/
cp $(dirname $(gem which colorls))/yaml/dark_colors.yaml ~/.config/colorls/dark_colors.yaml

例如可以修改ls时显示的颜色,修改下面几项

unrecognized_file: white
recognized_file:   darkgreen
dir:               dodgerblue

colorls支持配置以下颜色:

black, red, green, yellow, blue, magenta, cyan, white, default, aqua, aquamarine, mediumaquamarine, azure, beige, bisque, black, blanchedalmond, blue, darkblue, lightblue, mediumblue, aliceblue, cadetblue, dodgerblue, midnightblue, navyblue, powderblue, royalblue, skyblue, deepskyblue, lightskyblue, slateblue, darkslateblue, mediumslateblue, steelblue, lightsteelblue, brown, rosybrown, saddlebrown, sandybrown, burlywood, chartreuse, chocolate, coral, lightcoral, cornflower, cornsilk, crimson, cyan, darkcyan, lightcyan, firebrick, fuchsia, gainsboro, gold, goldenrod, darkgoldenrod, lightgoldenrod, palegoldenrod, gray, darkgray, dimgray, lightgray, slategray, lightslategray, webgray, green, darkgreen, lightgreen, palegreen, darkolivegreen, yellowgreen, forestgreen, lawngreen, limegreen, seagreen, darkseagreen, lightseagreen, mediumseagreen, springgreen, mediumspringgreen, webgreen, honeydew, indianred, indigo, ivory, khaki, darkkhaki, lavender, lavenderblush, lemonchiffon, lime, linen, magenta, darkmagenta, maroon, webmaroon, mintcream, mistyrose, moccasin, oldlace, olive, olivedrab, orange, darkorange, orchid, darkorchid, mediumorchid, papayawhip, peachpuff, peru, pink, deeppink, lightpink, hotpink, plum, purple, mediumpurple, rebeccapurple, webpurple, red, darkred, orangered, mediumvioletred, palevioletred, salmon, darksalmon, lightsalmon, seashell, sienna, silver, darkslategray, snow, tan, teal, thistle, tomato, turquoise, darkturquoise, mediumturquoise, paleturquoise, violet, darkviolet, blueviolet, wheat, white, antiquewhite, floralwhite, ghostwhite, navajowhite, whitesmoke, yellow, lightyellow, greenyellow
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值