简单的配置管理
confctl的Python项目详细描述
确认
有助于组织您的配置以及它们是如何生成、安装的。在
$ confctl configure i3 rofi^{pr2}$
入门
- 为您的配置创建一个虚拟环境(使用您喜欢的任何工具来管理/创建python虚拟环境)
$ pyenv virtualenv 3.8.2 confctl
- 激活并安装
confctl
$ pyenv shell confctl $ pip install confctl $ confctl configure self --target=laptop --machine-id=dellxps
注意,我们传递--target
来指定设备的“类型”,传递--machine-id
来标识当前设备。
此信息将被保存在~/.config/confctl/config
文件中。了解一下可能有用
在配置过程中,它应用于什么(例如,为pc和笔记本电脑呈现不同的配置
它们可能有不同的参数)。在
- 创建一对配置
转到~/.config/confctl/user-configs
并在那里创建一个包含__init__.py
的文件夹。
__init__.py
必须定义Configuration
类(继承自Base
,btw还提供了一些方便的实用工具来运行sh命令、呈现模板等)。在
# ~/.config/confctl/user-configs/console/__init__.pyfromconfctlimportBase,ParamclassConfiguration(Base):HOME=Param.PATH("~")TARGET=Param()tmux_plugin_manager_dir=Param.PATH("~/.tmux/plugins/tpm")tpm_repo="https://github.com/tmux-plugins/tpm"fonts_repo="https://github.com/ryanoasis/nerd-fonts"prezto_repo="https://github.com/sorin-ionescu/prezto"defconfigure(self):# patched fontsfonts_dir=self.CACHE_DIR/"fonts"ifnot(fonts_dir/".git").exists():self.run_sh(f"git clone --depth 1 {self.fonts_repo}{fonts_dir}")self.run_sh(f'bash {fonts_dir/"install.sh"}')# tmuxself.ensure_folders(self.tmux_plugin_manager_dir)ifnot(self.tmux_plugin_manager_dir/".git").exists():self.run_sh(f"git clone {self.tpm_repo}{self.tmux_plugin_manager_dir}")self.template("tmux.conf.j2",symlink=self.HOME/".tmux.conf")# preztoprezto_dir=self.HOME/".zprezto"ifnot(prezto_dir/".git").exists():self.run_sh(f'git clone --recursive {self.prezto_repo} "{prezto_dir}"')ifnot(self.HOME/".zpreztorc").exists():init_zprezto="""setopt EXTENDED_GLOBfor rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); doln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}"done"""self.warning(f"You may need to manually setup `zprezto`: \n{init_zprezto}")
具有配置的文件夹可以包含配置期间使用的任何资源/模板。
在这个例子中,应该有tmux.conf.j2
。在
- 然后只需运行这个配置
$ confctl configure console
或者只是
$ confctl configure
它将应用所有定义的配置。在
美国石油学会
待定
内部构件
待定
- 项目
标签: