Pull Powershell profile

This commit is contained in:
Roey Darwish Dror
2018-08-23 22:08:04 +03:00
parent 79c2c77bbe
commit a049de31fb
3 changed files with 26 additions and 0 deletions

View File

@@ -33,6 +33,7 @@ Just run `topgrade`. It will run the following steps:
* ~/.config/fish * ~/.config/fish
* ~/.config/nvim * ~/.config/nvim
* ~/.vim * ~/.vim
* Powershell Profile
* Custom defined paths * Custom defined paths
* *Unix*: Run [zplug](https://github.com/zplug/zplug) update * *Unix*: Run [zplug](https://github.com/zplug/zplug) update
* *Unix*: Run [fisherman](https://github.com/fisherman/fisherman) update * *Unix*: Run [fisherman](https://github.com/fisherman/fisherman) update

View File

@@ -123,6 +123,13 @@ fn run() -> Result<(), Error> {
git_repos.insert(base_dirs.home_dir().join(".config/fish")); git_repos.insert(base_dirs.home_dir().join(".config/fish"));
} }
#[cfg(windows)]
{
if let Some(profile) = powershell.profile() {
git_repos.insert(profile);
}
}
if let Some(custom_git_repos) = config.git_repos() { if let Some(custom_git_repos) = config.git_repos() {
for git_repo in custom_git_repos { for git_repo in custom_git_repos {
git_repos.insert(git_repo); git_repos.insert(git_repo);

View File

@@ -41,6 +41,24 @@ impl Powershell {
}().is_ok() }().is_ok()
} }
pub fn profile(&self) -> Option<PathBuf> {
if let Some(powershell) = &self.path {
let result = || -> Result<PathBuf, failure::Error> {
let output = Command::new(powershell).args(&["-Command", "echo $profile"]).output()?;
output.status.check()?;
Ok(PathBuf::from(
String::from_utf8_lossy(&output.stdout).trim().to_string(),
))
}();
match result {
Err(e) => error!("Error getting Powershell profile: {}", e),
Ok(path) => return Some(path),
}
}
None
}
#[must_use] #[must_use]
pub fn update_modules(&self, terminal: &mut Terminal) -> Option<(&'static str, bool)> { pub fn update_modules(&self, terminal: &mut Terminal) -> Option<(&'static str, bool)> {
if let Some(powershell) = &self.path { if let Some(powershell) = &self.path {