tmux和zsh的个性化配置-----针对无法连接外网的机器

记录一下最近在一个不能连接外网的机器配置tmux和zsh开发环境,如果你也有这样的需求,下文应该会有所帮助

升级tmux和zsh到最新版本

针对一些插件和配置都需要将tmux和zsh升级到高于某个版本,而一般可能会遇到自己yum安装后的版本不符合要求

  • tmux升级

    我是参考这篇文章https://blog.csdn.net/gneveek/article/details/82803909
    安装前先卸载,yum remove tmux

    1. 安装依赖项:libevent,可以到github或者gitee拉取代码
    yum -y install ncurses-devel
    # libevent 2.1.8
    wget https://github.com/libevent/libevent/releases/download/release-2.1.8-stable/libevent-2.1.8-stable.tar.gz
    tar xzvf libevent-2.1.8-stable.tar.gz
    cd libevent-2.1.8-stable
    ./configure
    make -j8
    make install
    
    1. 安装ncurses
    yum install ncurses -y
    
    1. 安装tmux
    git clone https://github.com/tmux/tmux.git
    cd tmux
    sh autogen.sh
    ./configure
    make -j8
    make install
    
    1. 查看是否升级成功
    tmux -V
    
  • zsh升级

    一样的套路,github下载压缩包,安装依赖,记得安装前先卸载旧版本
    参考这里:https://blog.csdn.net/u012605514/article/details/121797773

    1. 源码下载
    # 下载
    $ wget https://jaist.dl.sourceforge.net/project/zsh/zsh/5.8/zsh-5.8.tar.xz
    
    # 解压
    $ tar xvf zsh-5.8.tar.xz
    
    1. 安装依赖项,并安装zsh
    # 安装编译工具
    $ yum install gcc perl-ExtUtils-MakeMaker
    $ yum install ncurses-devel
    
    # 进入源码目录
    $ cd zsh-5.8
    
    # 执行配置
    $ ./configure   # 默认安装在:/usr/local/bin/zsh
    
    # 编译和安装
    $ make && make install
    
    # 添加信息
    $ vim /etc/shells
    # 在最后一行加上:/usr/local/bin/zsh
    
    1. 查看是否安装成功
    # 切换shell
    $ chsh -s /usr/local/bin/zsh
    
    # 查看版本信息
    $ zsh --version
    # zsh 5.8 (x86_64-pc-linux-gnu)
    

zsh美化--离线安装oh-my-zsh

ohmyzsh默认安装的时候需要git clone它的仓库,但是我们是在不能连接外网的条件下,那么解决方式是什么呢?直接看安装代码,修改它的安装代码,详情往下看
参考这里:https://blog.csdn.net/lovedingd/article/details/124129894

  1. 下载ohmyzsh的源码包,解压后将此文件夹复制到home目录下,并改名为.oh-my-zsh,注意这里的点
  2. 修改 $HOME/.oh-my-zsh/tools 下的 install.sh 安装脚本

    可能你下载的install.sh和我这个版本的不一样,但是修改的地方主要就两个方面:删除git clone部分和删除判断.oh-my-zsh文件夹是否报错的地方,详情看代码

    481 #   if [ -d "$ZSH" ]; then
    482 #     echo "${FMT_YELLOW}The \$ZSH folder already exists ($ZSH).${FMT_RESET}"
    483 #     if [ "$custom_zsh" = yes ]; then
    484 #       cat <<EOF
    485 # 
    486 # You ran the installer with the \$ZSH setting or the \$ZSH variable is
    487 # exported. You have 3 options:
    488 # 
    489 # 1. Unset the ZSH variable when calling the installer:
    490 #    $(fmt_code "ZSH= sh install.sh")
    491 # 2. Install Oh My Zsh to a directory that doesn't exist yet:
    492 #    $(fmt_code "ZSH=path/to/new/ohmyzsh/folder sh install.sh")
    493 # 3. (Caution) If the folder doesn't contain important information,
    494 #    you can just remove it with $(fmt_code "rm -r $ZSH")
    495 # 
    496 # EOF
    497 #     else
    498 #       echo "You'll need to remove it if you want to reinstall."
    499 #     fi
    500 #     exit 1
    501 #   fi
    502 
    503 #setup_ohmyzsh
    
  3. 遇到其他情况,仍然安装不成功,请对照报错信息看代码

oh-my-zsh安装好了之后可以看到zsh已经变成了默认主题

tmux配置

https://github.com/gpakosz/.tmux, 把这里的配置文件下载下来,进入tmux后Ctrl+B :source-file file-path即可

posted @ 2022-06-17 16:23  荒唐了年少  阅读(269)  评论(0编辑  收藏  举报