feat: support oh-my-bash (#425)

This commit is contained in:
SteveLauC
2023-05-18 01:17:37 +08:00
committed by GitHub
parent 14753a14e7
commit 3a1568e884
2 changed files with 26 additions and 1 deletions

View File

@@ -342,6 +342,7 @@ For more information about this issue see https://askubuntu.com/questions/110969
runner.execute(Step::Shell, "zi", || zsh::run_zi(run_type))?;
runner.execute(Step::Shell, "zim", || zsh::run_zim(run_type))?;
runner.execute(Step::Shell, "oh-my-zsh", || zsh::run_oh_my_zsh(&ctx))?;
runner.execute(Step::Shell, "oh-my-bash", || unix::run_oh_my_bash(&ctx))?;
runner.execute(Step::Shell, "fisher", || unix::run_fisher(run_type))?;
runner.execute(Step::Shell, "bash-it", || unix::run_bashit(&ctx))?;
runner.execute(Step::Shell, "oh-my-fish", || unix::run_oh_my_fish(&ctx))?;

View File

@@ -2,7 +2,10 @@ use std::fs;
use std::os::unix::fs::MetadataExt;
use std::path::PathBuf;
use std::process::Command;
use std::{env, path::Path};
use std::{
env::{self, var},
path::Path,
};
use crate::command::CommandExt;
use crate::{Step, HOME_DIR};
@@ -136,6 +139,27 @@ pub fn run_bashit(ctx: &ExecutionContext) -> Result<()> {
.status_checked()
}
pub fn run_oh_my_bash(ctx: &ExecutionContext) -> Result<()> {
require("bash")?;
let oh_my_bash = var("OSH")
// default to `~/.oh-my-bash`
.unwrap_or(
HOME_DIR
.join(".oh-my-bash")
.to_str()
.expect("should be UTF-8 encoded")
.to_string(),
)
.require()?;
print_separator("oh-my-bash");
let mut update_script = oh_my_bash;
update_script.push_str("tools/upgrade.sh");
ctx.run_type().execute("bash").arg(update_script).status_checked()
}
pub fn run_oh_my_fish(ctx: &ExecutionContext) -> Result<()> {
let fish = require("fish")?;
HOME_DIR.join(".local/share/omf/pkg/omf/functions/omf.fish").require()?;