加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 寻找更好的自动化工作环境的方法

发布时间:2020-12-13 22:58:19 所属栏目:Linux 来源:网络整理
导读:我正在研究虚拟机(虚拟机).我使用虚拟机进行测试,并且经常创建虚拟机或交换虚拟机.问题是我每次创建/切换VM时都需要重新创建我的工作环境.我的工作环境包括文件(.bashrc,.emacs,.emacs.d,. vimrc,.gitconfig等).因为我需要这些文件来创建我自己灵活的 linux
我正在研究虚拟机(虚拟机).我使用虚拟机进行测试,并且经常创建虚拟机或交换虚拟机.问题是我每次创建/切换VM时都需要重新创建我的工作环境.我的工作环境包括文件(.bashrc,.emacs,.emacs.d,. vimrc,.gitconfig等).因为我需要这些文件来创建我自己灵活的 linux环境.但每次都要继续复制这些文件很头疼.
请建议一个更好的方法来快速重建我的环境.

解决方法

您可以创建bash脚本来执行此操作.根据我的理解,你知道git.我建议你根据你的env文件的分类创建几个git repos(可能在github上).以下是快速重新创建env的示例.
在vm中共享git repos的路径.您可以使用您的repo文件链接文件.例如.bashrc – >到/你/ .bashrc中

#!/bin/bash
        declare -a repos=('repo1.git' 'repo2.git' 'repo3.git')

        err=0

        err_sts()
        {
        if [ 0 -ne $? ]; then
            err=$1
            echo above step failed exiting.. err code: $err
            exit $err              
        fi
        }

        gclone()
        {
        echo path=$1 
        echo repo=$2
        path=$1
        repo=$2
        echo "cd $hmdir"
        cd $hmdir
        echo "git clone $path/$repo"
        git clone $path/$repo
        }

        main()
        {
        echo enter the path to repos:
        read pth

        ls $pth
        err_sts 1

        #path where you want your repos 
        echo enter home dir for repos:
        read hmdir

    ls $hmdir
    err_sts 2

    err=3
    for ((i = 0; i < ${#repos[@]}; i++))
    do
    echo "ls $pth/${repos[$i]}"
    ls $pth/${repos[$i]}
    err_sts $(($err + $i))
    gclone $pth ${repos[$i]}
    done
    }

    main

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读