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

1,100 阅读1分钟

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 \

unalias z 2> /dev/null
j() {
    [ $# -gt 0 ] && zshz "$*" && return
    cd "$(zshz -l 2>&1 | fzf --height 40% --nth 2.. --reverse --inline-info +s --tac --query "${*##-* }" | sed 's/^[0-9,.]* *//')"
}

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

重启 zsh
(命令行 完。

一些主题相关的设置

www.engineeringwithutsav.com/blog/spice-…

如果你的服务器 (腾讯云)没有办法访问 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 等相应解析规则