From 9a91e31221e2b325b314e9c901e7f96aacbf1ffd Mon Sep 17 00:00:00 2001 From: reeink Date: Wed, 8 May 2024 00:57:08 +0800 Subject: [PATCH] add zoxide and improve init --- .../Microsoft.PowerShell_profile.ps1 | 25 ------------ .../Microsoft.PowerShell_profile.ps1.tmpl | 38 +++++++++++++++++++ 2 files changed, 38 insertions(+), 25 deletions(-) delete mode 100644 Documents/PowerShell/Microsoft.PowerShell_profile.ps1 create mode 100644 Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl diff --git a/Documents/PowerShell/Microsoft.PowerShell_profile.ps1 b/Documents/PowerShell/Microsoft.PowerShell_profile.ps1 deleted file mode 100644 index cdcff19..0000000 --- a/Documents/PowerShell/Microsoft.PowerShell_profile.ps1 +++ /dev/null @@ -1,25 +0,0 @@ -# init -Invoke-Expression (&starship init powershell) # starship - -# micromamba -#region mamba initialize -# !! Contents within this block are managed by 'mamba shell init' !! -$Env:MAMBA_ROOT_PREFIX = "C:\Users\remon\.micromamba" -$Env:MAMBA_EXE = "C:\Users\remon\AppData\Local\micromamba\micromamba.exe" -(& $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -p $Env:MAMBA_ROOT_PREFIX) | Out-String | Invoke-Expression -#endregion - -# Alias -Set-Alias -Name ls -Value eza -Set-Alias -Name mm -Value micromamba -Set-Alias -Name dotfiles -Value chezmoi - -function ya { - $tmp = [System.IO.Path]::GetTempFileName() - yazi $args --cwd-file="$tmp" - $cwd = Get-Content -Path $tmp - if (-not [String]::IsNullOrEmpty($cwd) -and $cwd -ne $PWD.Path) { - Set-Location -Path $cwd - } - Remove-Item -Path $tmp -} diff --git a/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl b/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl new file mode 100644 index 0000000..74f61b8 --- /dev/null +++ b/Documents/PowerShell/Microsoft.PowerShell_profile.ps1.tmpl @@ -0,0 +1,38 @@ +# starship +if (Get-Command starship -ErrorAction SilentlyContinue) { + Invoke-Expression (&starship init powershell) +} + +# micromamba +if (Get-Command micromamba -ErrorAction SilentlyContinue) { + $Env:MAMBA_ROOT_PREFIX = "{{ .chezmoi.homeDir }}/.micromamba" + $Env:MAMBA_EXE = "{{ .chezmoi.homeDir }}/AppData/Local/micromamba/micromamba.exe" + (& $Env:MAMBA_EXE 'shell' 'hook' -s 'powershell' -p $Env:MAMBA_ROOT_PREFIX) | Out-String | Invoke-Expression +} + +# zoxide +if (Get-Command zoxide -ErrorAction SilentlyContinue) { + Invoke-Expression (& { (zoxide init powershell | Out-String) }) +} + +# yazi +function ya { + $tmp = [System.IO.Path]::GetTempFileName() + yazi $args --cwd-file="$tmp" + $cwd = Get-Content -Path $tmp + if (-not [String]::IsNullOrEmpty($cwd) -and $cwd -ne $PWD.Path) { + Set-Location -Path $cwd + } + Remove-Item -Path $tmSp +} + + +# alias + +## eza -> ls +if (Get-Command eza -ErrorAction SilentlyContinue) { + Set-Alias -Name ls -Value eza +} + +Set-Alias -Name mm -Value micromamba +Set-Alias -Name dotfiles -Value chezmoi