一六零、云服务器开发机配置zsh

切换shell

在Linux中默认使用/bin/bash,在用户创建时,会自动给用户创建用户默认的shell。
默认的shell就是/bin/bash。要修改shell将其设置为/bin/ksh,有两种方法方法

# 方法一: chsh -s /bin/ksh
chsh -s /bin/zsh 

# 方法二: usermod -s /bin/ksh root

usermod -s /bin/zsh root

# 查看当前使用的shell
echo $SHELL

# 查看所有可用的shell
cat /etc/shells

安装zsh

yum install zsh

安装 Oh My Zsh

  1. 下载安装脚本 https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh
  2. 如果开发机没有外网权限,则修改 install.sh 中 REMOTE=KaTeX parse error: Expected '}', got 'EOF' at end of input: ….baidu-int.com/{REPO}.git} 为我厂的 github mirror
  3. 一键安装
sh install.sh --skip-chsh

安装 powerlevel10k

powerlevel10k 是一款非常优秀的 zsh 主题,可直接克隆仓库:

git clone --depth=1 https://github.baidu-int.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k

在 ~/.zshrc 中修改主题 ZSH_THEME=“powerlevel10k/powerlevel10k” 后,可通过 p10k configure 命令采用问答快速定制化自己的配置,配置完成后还可以在 ~/.p10k.zsh 中自己设置,包括左右栏显示的信息等。
如果配置完成后显示有乱码或者符号显示不完全,是因为没有设置对应的字体,在 nerd-fonts 下载 Hack Nerd Font 或 Meslo Nerd Font 字体并在 iTerm2 正确设置后即可正常显示。

常用插件

Oh My Zsh 提供了非常丰富的插件,可根据自己的喜好来安装(但也不宜过多),常用的插件有 git, z, zsh-syntax-highlighting, zsh-autosuggestions
需要在 ~/.zshrc 中修改 plugins 为 plugins=(git z zsh-syntax-highlighting zsh-autosuggestions)

VSCode 终端字体修改

在 settings 中搜索 terminal font,修改为之前设置的 iTerm2 相同的字体即可。

效果图

image.png

tmux 配置

安装及配置

使用 jumbo 安装 tmux 新版:

jumbo install tmux2

使用以下配置覆盖 ~/.tmux.conf:
.tmux.conf

# ------ general ------------------------------------
set -g prefix C-s
unbind C-b
bind C-s send-prefix

set -g escape-time 0
set -g base-index 1
set -g renumber-windows on
set -g mouse on
set -wg pane-base-index 1

# rename-window
set -wg allow-rename off
set -wg automatic-rename off

set -wg mode-keys vi

# last-window
bind a last

# retain current path
bind c new-window -c "#{pane_current_path}"
bind _ split-window -h -c "#{pane_current_path}"
bind - split-window -c "#{pane_current_path}"

# restart and edit
bind r source ~/.tmux.conf\; display "tmux config sourced"
bind e neww -n tmux-config "\${EDITOR:-vim} ~/.tmux.conf"

# ------ move around --------------------------------
bind -r h select-pane -L
bind l select-pane -R        # remove repeat, because of ls
bind -r j select-pane -D
bind -r k select-pane -U

# ------ status theme -------------------------------
set -g message-style "bg=#00346e, fg=#ffffd7"        # tomorrow night blue, base3

set -g status-style "bg=#00346e, fg=#ffffd7"   # tomorrow night blue, base3
set -g status-left "#[bg=#0087ff] ❐ #S "       # blue
set -g status-left-length 400
set -g status-right "#{?client_prefix, ⌨ , } #[bg=#0087ff] #(whoami)@#h #[bg=red] %Y-%m-%d %H:%M "
set -g status-right-length 600

set -g set-clipboard on
set -g history-limit 10000

set -wg window-status-format " #I #W "
set -wg window-status-current-format " #I #W "
set -wg window-status-separator ""
set -wg window-status-current-style "bg=red" # red
set -wg window-status-last-style "fg=red"

set -wg pane-active-border-style "fg=blue"
set -wg pane-border-style "fg=#585858"       # base01

set -g default-terminal "screen-256color"

# ------- copy to clipboard ------------------------
# bind -t vi-copy y copy-pipe 'xclip -selection clipboard > /dev/null'
# bind -t vi-copy y copy-pipe "reattach-to-user-namespace pbcopy"

将快捷键更新为 C-s,设置鼠标开启,配置我厂的蓝红配色等。

vim 配置

安装插件

安装 vim-plug 管理插件:

curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
    https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

使用如下代码覆盖 ~/.vimrc 来安装 vim-airlinevim-airline-themesvim-onenerdtree 插件(使用 :PlugInstall 来安装)以及一些简单的 vim 配置
.vimrc

call plug#begin('~/.vim/plugged')

Plug 'https://github.baidu-int.com/vim-airline/vim-airline'
Plug 'https://github.baidu-int.com/vim-airline/vim-airline-themes'
Plug 'https://github.baidu-int.com/preservim/nerdtree'

call plug#end()

set number
set cursorline
set cursorcolumn
set noshowmode

" airline
let g:airline_theme='dracula'
let g:one_allow_italics=1
let g:airline_powerline_fonts=1
let g:airline#extensions#tabline#enabled=1
let g:airline#extensions#tabline#left_sep=' '
let g:airline#extensions#tabline#left_alt_sep='|'
let g:airline#extensions#tabline#buffer_nr_show=1

" NERDTree
map <C-n> :NERDTreeToggle<CR>
  • 33
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值