持续更新-搭建一个不会掉线的服务器开发环境

1. 优化命令行

  • 检查当前可用的shell:

cat /etc/shells

# /etc/shells: valid login shells
/bin/sh
/bin/bash
/bin/rbash
/bin/dash
/usr/bin/tmux
/usr/bin/screen
复制代码
  • 查看当前使用的shell:

echo $SHELL or echo $0

~$ echo $SHELL
/bin/bash
~$ echo $0
-bash
复制代码
  • 安装zsh shell

sudo apt install zsh

  • 切换shell

chsh -s /bin/zsh

  • 退出重新登录,就可以看到 zshell

  • 安装 oh-my-zsh

访问 Oh My Zsh 官网
获取安装指令 sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

  • 配置主题

ZSH_THEME="ys"

  • 配置 plugin

/home/${usr}/.oh-my-zsh

 plugins=(
     git
     z
     zsh-autosuggestions
     zsh-syntax-highlighting
    history
 )
复制代码

安装不在初始化插件中的 zsh-autosuggestions, zsh-syntax-highlighting
1. 来到zsh的插件目录列表
cd $ZSH_CUSTOM/plugins
2. 安装
git clone https://github.com/zsh-users/zsh-autosuggestions.git
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
3. 重启 zsh
安装 fzf
junegunn/fzf: A command-line fuzzy finder (github.com) 的 git 安装方案

git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf
~/.fzf/install
复制代码

配置 j & jj \

j() {
     if [[ -z "$*" ]]; then
         cd "$(_z -l 2>&1 | fzf +s | sed 's/^[0-9,.]* *//')"
     else
          _last_z_args="$@"
         _z "$@"
     fi
}

jj() {
    cd "$(_z -l 2>&1 | sed 's/^[0-9,.]* *//' | fzf -q $_last_z_args)"
}
复制代码

重启 zsh
(命令行 完。

如果你的服务器 (腾讯云)没有办法访问 github

GitHub无法拉取库,原来是Github在国内访问速度慢的问题原因有很多,但最直接和最主要的原因是GitHub的分发加速网络的域名遭到dns污染,导致国内机器连不上仓库,安装部分服务受到影响。

打开 IPAddress.com
查询以下链接的DNS解析地址:
1. github.com
2. assets-cdn.github.com
3. github.global.ssl.fastly.net
4. codeload.github.com
5. raw.githubusercontent.com

image.png
/etc/hosts 配置 140.82.112.4 github.com 等相应解析规则