简单的配置管理

confctl的Python项目详细描述


Package version

确认

有助于组织您的配置以及它们是如何生成、安装的。在

$ confctl configure i3 rofi

Example execution

^{pr2}$

入门

  1. 为您的配置创建一个虚拟环境(使用您喜欢的任何工具来管理/创建python虚拟环境)
$ pyenv virtualenv 3.8.2 confctl
  1. 激活并安装confctl
$ pyenv shell confctl
$ pip install confctl
$ confctl configure self --target=laptop --machine-id=dellxps

注意,我们传递--target来指定设备的“类型”,传递--machine-id来标识当前设备。 此信息将被保存在~/.config/confctl/config文件中。了解一下可能有用 在配置过程中,它应用于什么(例如,为pc和笔记本电脑呈现不同的配置 它们可能有不同的参数)。在

  1. 创建一对配置

转到~/.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。在

  1. 然后只需运行这个配置
$ confctl configure console

或者只是

$ confctl configure

它将应用所有定义的配置。在

美国石油学会

待定

内部构件

待定

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
图形Java仿射变换以旋转通用路径   IntelliJ IDEA中的java代码标记为编译器错误,在Eclipse中可以正常工作   java ArrayList的containsAll返回了错误的值   如何在安卓中的片段活动中添加java代码   java通过使用netbeans调用jbutton,将带有行的jbutton添加到jtable中   java在更新arrayAdapter/listView之前更新最终列表   java如何在另一个项目中导入包含AspectJ方面和注释的项目   为什么我的java布尔测试总是失败?   Eclipse中的java自动激活   在Bluetooth for Java(更具体地说是Android)之上是否有TCP/IP协议栈实现?   java Android Studio通过intent传递ArrayList并填充ListView