Support antidote (#368)

This commit is contained in:
Roey Darwish Dror
2023-02-26 23:45:43 +02:00
committed by GitHub
parent a5d5d987d2
commit 7728819133
2 changed files with 23 additions and 4 deletions

View File

@@ -317,6 +317,7 @@ For more information about this issue see https://askubuntu.com/questions/110969
{
runner.execute(Step::Shell, "zr", || zsh::run_zr(&base_dirs, run_type))?;
runner.execute(Step::Shell, "antibody", || zsh::run_antibody(run_type))?;
runner.execute(Step::Shell, "antidote", || zsh::run_antidote(&ctx))?;
runner.execute(Step::Shell, "antigen", || zsh::run_antigen(&base_dirs, run_type))?;
runner.execute(Step::Shell, "zgenom", || zsh::run_zgenom(&base_dirs, run_type))?;
runner.execute(Step::Shell, "zplug", || zsh::run_zplug(&base_dirs, run_type))?;

View File

@@ -1,5 +1,5 @@
use std::env;
use std::path::{Path, PathBuf};
use std::path::PathBuf;
use std::process::Command;
use color_eyre::eyre::Result;
@@ -25,10 +25,28 @@ pub fn run_zr(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
run_type.execute(zsh).args(["-l", "-c", cmd.as_str()]).status_checked()
}
pub fn zshrc(base_dirs: &BaseDirs) -> PathBuf {
fn zdotdir(base_dirs: &BaseDirs) -> PathBuf {
env::var("ZDOTDIR")
.map(|p| Path::new(&p).join(".zshrc"))
.unwrap_or_else(|_| base_dirs.home_dir().join(".zshrc"))
.map(PathBuf::from)
.unwrap_or_else(|_| base_dirs.home_dir().to_path_buf())
}
pub fn zshrc(base_dirs: &BaseDirs) -> PathBuf {
zdotdir(base_dirs).join(".zshrc")
}
pub fn run_antidote(ctx: &ExecutionContext) -> Result<()> {
let zsh = require("zsh")?;
let mut antidote = zdotdir(ctx.base_dirs()).join(".antidote").require()?;
antidote.push("antidote.zsh");
print_separator("antidote");
ctx.run_type()
.execute(zsh)
.arg("-c")
.arg(format!("source {} && antidote update", antidote.display()))
.status_checked()
}
pub fn run_antibody(run_type: RunType) -> Result<()> {