diff --git a/.assets/config/pwsh_cfg/profile.ps1 b/.assets/config/pwsh_cfg/profile.ps1 index 443efbd8..94f8d100 100644 --- a/.assets/config/pwsh_cfg/profile.ps1 +++ b/.assets/config/pwsh_cfg/profile.ps1 @@ -68,8 +68,8 @@ Remove-Variable path #endregion #region prompt -if (-not $isWSL1 -and (Test-Path '/usr/bin/oh-my-posh')) { - oh-my-posh --init --shell pwsh --config "$(Resolve-Path $env:OMP_PATH/theme.omp.json -ErrorAction Stop)" | Invoke-Expression | Out-Null +if (-not $isWSL1 -and (Test-Path /usr/bin/oh-my-posh -PathType Leaf) -and (Test-Path "$env:OMP_PATH/theme.omp.json" -PathType Leaf)) { + oh-my-posh init pwsh --config "$env:OMP_PATH/theme.omp.json" | Invoke-Expression | Out-Null # disable venv prompt as it is handled in oh-my-posh theme [Environment]::SetEnvironmentVariable('VIRTUAL_ENV_DISABLE_PROMPT', $true) } else { diff --git a/.assets/docker/Dockerfile b/.assets/docker/Dockerfile index 462bf4f6..71d35607 100644 --- a/.assets/docker/Dockerfile +++ b/.assets/docker/Dockerfile @@ -39,7 +39,6 @@ RUN \ # install and setup oh-my-posh theme && mkdir -p /usr/local/share/oh-my-posh \ && install -m 0644 /tmp/cfg/base.omp.json /usr/local/share/oh-my-posh/theme.omp.json \ - && oh-my-posh disable notice \ # cleanup && apt-get autoremove -y \ && apt-get clean -y \ diff --git a/.assets/provision/setup_profile_allusers.sh b/.assets/provision/setup_profile_allusers.sh index 901e0a18..59249cc9 100755 --- a/.assets/provision/setup_profile_allusers.sh +++ b/.assets/provision/setup_profile_allusers.sh @@ -58,7 +58,7 @@ fi # *bash profile # add common bash aliases -grep -qw 'd/aliases.sh' ~/.bashrc 2>/dev/null || cat <>~/.bashrc +grep -qw 'd/aliases.sh' $HOME/.bashrc 2>/dev/null || cat <>$HOME/.bashrc # common aliases if [ -f "$PROFILE_PATH/aliases.sh" ]; then source "$PROFILE_PATH/aliases.sh" @@ -66,13 +66,16 @@ fi EOF # add oh-my-posh invocation -if ! grep -qw 'oh-my-posh' ~/.bashrc 2>/dev/null && type oh-my-posh &>/dev/null; then - cat <>~/.bashrc +if ! grep -qw 'oh-my-posh' $HOME/.bashrc 2>/dev/null && type oh-my-posh &>/dev/null; then + cat <>$HOME/.bashrc # initialize oh-my-posh prompt if [ -f "$OMP_PATH/theme.omp.json" ] && type oh-my-posh &>/dev/null; then - eval "\$(oh-my-posh --init --shell bash --config "$OMP_PATH/theme.omp.json")" + eval "\$(oh-my-posh init bash --config "$OMP_PATH/theme.omp.json")" fi EOF +elif grep -qw 'oh-my-posh --init' $HOME/.bashrc 2>/dev/null; then + # convert oh-my-posh initialization to the new API + sed -i 's/oh-my-posh --init --shell bash/oh-my-posh init bash/' $HOME/.bashrc &>/dev/null fi # make path autocompletion case insensitive diff --git a/.assets/provision/setup_profile_user.ps1 b/.assets/provision/setup_profile_user.ps1 index cbc6ea0e..7fce9ffe 100755 --- a/.assets/provision/setup_profile_user.ps1 +++ b/.assets/provision/setup_profile_user.ps1 @@ -29,10 +29,6 @@ if (Get-Module -Name Microsoft.PowerShell.PSResourceGet -ListAvailable) { .assets/provision/update_psresources.ps1 } } -# disable oh-my-posh update notice -if (Get-Command oh-my-posh -CommandType Application) { - oh-my-posh disable notice | Out-Null -} # install PSReadLine for ($i = 0; ((Get-Module PSReadLine -ListAvailable).Count -eq 1) -and $i -lt 5; $i++) { Write-Host 'installing PSReadLine...' diff --git a/.assets/provision/setup_profile_user.sh b/.assets/provision/setup_profile_user.sh index 03ba1304..cb291d26 100755 --- a/.assets/provision/setup_profile_user.sh +++ b/.assets/provision/setup_profile_user.sh @@ -7,7 +7,7 @@ PROFILE_PATH='/etc/profile.d' OMP_PATH='/usr/local/share/oh-my-posh' # add common bash aliases -grep -qw 'd/aliases.sh' ~/.bashrc 2>/dev/null || cat <>~/.bashrc +grep -qw 'd/aliases.sh' $HOME/.bashrc 2>/dev/null || cat <>$HOME/.bashrc # common aliases if [ -f "$PROFILE_PATH/aliases.sh" ]; then source "$PROFILE_PATH/aliases.sh" @@ -15,8 +15,8 @@ fi EOF # add git aliases -if ! grep -qw 'd/aliases_git.sh' ~/.bashrc 2>/dev/null && type git &>/dev/null; then - cat <>~/.bashrc +if ! grep -qw 'd/aliases_git.sh' $HOME/.bashrc 2>/dev/null && type git &>/dev/null; then + cat <>$HOME/.bashrc # git aliases if [ -f "$PROFILE_PATH/aliases_git.sh" ] && type git &>/dev/null; then source "$PROFILE_PATH/aliases_git.sh" @@ -25,7 +25,7 @@ EOF fi # add custom functions -grep -qw 'd/functions.sh' ~/.bashrc 2>/dev/null || cat <>~/.bashrc +grep -qw 'd/functions.sh' $HOME/.bashrc 2>/dev/null || cat <>$HOME/.bashrc # custom functions if [ -f "$PROFILE_PATH/functions.sh" ]; then source "$PROFILE_PATH/functions.sh" @@ -33,8 +33,8 @@ fi EOF # add kubectl autocompletion and aliases -if ! grep -qw 'kubectl' ~/.bashrc 2>/dev/null && type -f kubectl &>/dev/null; then - cat <>~/.bashrc +if ! grep -qw 'kubectl' $HOME/.bashrc 2>/dev/null && type -f kubectl &>/dev/null; then + cat <>$HOME/.bashrc # kubectl autocompletion and aliases if type -f kubectl &>/dev/null; then source <(kubectl completion bash) @@ -51,16 +51,19 @@ EOF fi # add conda initialization -if ! grep -qw '__conda_setup' ~/.bashrc 2>/dev/null && [ -f $HOME/miniconda3/bin/conda ]; then +if ! grep -qw '__conda_setup' $HOME/.bashrc 2>/dev/null && [ -f $HOME/miniconda3/bin/conda ]; then $HOME/miniconda3/bin/conda init bash >/dev/null fi # add oh-my-posh invocation -if ! grep -qw 'oh-my-posh' ~/.bashrc 2>/dev/null && type oh-my-posh &>/dev/null; then - cat <>~/.bashrc +if ! grep -qw 'oh-my-posh' $HOME/.bashrc 2>/dev/null && type oh-my-posh &>/dev/null; then + cat <>$HOME/.bashrc # initialize oh-my-posh prompt if [ -f "$OMP_PATH/theme.omp.json" ] && type oh-my-posh &>/dev/null; then - eval "\$(oh-my-posh --init --shell bash --config "$OMP_PATH/theme.omp.json")" + eval "\$(oh-my-posh init bash --config "$OMP_PATH/theme.omp.json")" fi EOF +elif grep -qw 'oh-my-posh --init' $HOME/.bashrc 2>/dev/null; then + # convert oh-my-posh initialization to the new API + sed -i 's/oh-my-posh --init --shell bash/oh-my-posh init bash/' $HOME/.bashrc fi diff --git a/.assets/provision/setup_profile_user_zsh.sh b/.assets/provision/setup_profile_user_zsh.sh index 01026768..b4e0859d 100755 --- a/.assets/provision/setup_profile_user_zsh.sh +++ b/.assets/provision/setup_profile_user_zsh.sh @@ -14,7 +14,7 @@ if [ -d $HOME/.zsh/zsh-autocomplete ]; then else git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $HOME/.zsh/zsh-autocomplete fi -if ! grep -w 'zsh-autocomplete.plugin.zsh' ~/.zshrc 2>/dev/null; then +if ! grep -w 'zsh-autocomplete.plugin.zsh' $HOME/.zshrc 2>/dev/null; then cat <<'EOF' >>$HOME/.zshrc # *plugins source $HOME/.zsh/zsh-autocomplete/zsh-autocomplete.plugin.zsh @@ -27,7 +27,7 @@ if [ -d $HOME/.zsh/zsh-autosuggestions ]; then else git clone https://github.com/zsh-users/zsh-autosuggestions $HOME/.zsh/zsh-autosuggestions fi -if ! grep -w 'zsh-autosuggestions.zsh' ~/.zshrc 2>/dev/null; then +if ! grep -w 'zsh-autosuggestions.zsh' $HOME/.zshrc 2>/dev/null; then echo 'source $HOME/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh' >>$HOME/.zshrc fi # ~zsh-syntax-highlighting @@ -37,7 +37,7 @@ if [ -d $HOME/.zsh/zsh-syntax-highlighting ]; then else git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $HOME/.zsh/zsh-syntax-highlighting fi -if ! grep -w 'zsh-syntax-highlighting.zsh' ~/.zshrc 2>/dev/null; then +if ! grep -w 'zsh-syntax-highlighting.zsh' $HOME/.zshrc 2>/dev/null; then echo 'source $HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh' >>$HOME/.zshrc fi if ! grep -q '^bindkey .* autosuggest-accept' $HOME/.zshrc; then @@ -46,7 +46,7 @@ fi # *aliases # add common zsh aliases -grep -qw 'd/aliases.sh' ~/.zshrc 2>/dev/null || cat <>$HOME/.zshrc +grep -qw 'd/aliases.sh' $HOME/.zshrc 2>/dev/null || cat <>$HOME/.zshrc # *aliases if [ -f "$PROFILE_PATH/aliases.sh" ]; then source "$PROFILE_PATH/aliases.sh" @@ -54,7 +54,7 @@ fi EOF # add git aliases -if ! grep -qw 'd/aliases_git.sh' ~/.zshrc 2>/dev/null && type git &>/dev/null; then +if ! grep -qw 'd/aliases_git.sh' $HOME/.zshrc 2>/dev/null && type git &>/dev/null; then cat <>$HOME/.zshrc # git aliases if [ -f "$PROFILE_PATH/aliases_git.sh" ] && type git &>/dev/null; then @@ -64,7 +64,7 @@ EOF fi # add kubectl autocompletion and aliases -if ! grep -qw 'kubectl' ~/.zshrc 2>/dev/null && type -f kubectl &>/dev/null; then +if ! grep -qw 'kubectl' $HOME/.zshrc 2>/dev/null && type -f kubectl &>/dev/null; then cat <>$HOME/.zshrc # kubectl autocompletion and aliases if type -f kubectl &>/dev/null; then @@ -76,16 +76,19 @@ EOF fi # *add conda initialization -if ! grep -qw '__conda_setup' ~/.zshrc 2>/dev/null && [ -f $HOME/miniconda3/bin/conda ]; then +if ! grep -qw '__conda_setup' $HOME/.zshrc 2>/dev/null && [ -f $HOME/miniconda3/bin/conda ]; then $HOME/miniconda3/bin/conda init zsh >/dev/null fi # *add oh-my-posh invocation -if ! grep -qw 'oh-my-posh' ~/.zshrc 2>/dev/null && type oh-my-posh &>/dev/null; then - cat <>~/.zshrc +if ! grep -qw 'oh-my-posh' $HOME/.zshrc 2>/dev/null && type oh-my-posh &>/dev/null; then + cat <>$HOME/.zshrc # initialize oh-my-posh prompt if [ -f "$OMP_PATH/theme.omp.json" ] && type oh-my-posh &>/dev/null; then - eval "\$(oh-my-posh --init --shell zsh --config "$OMP_PATH/theme.omp.json")" + eval "\$(oh-my-posh init zsh --config "$OMP_PATH/theme.omp.json")" fi EOF +elif grep -qw 'oh-my-posh --init' $HOME/.zshrc 2>/dev/null; then + # convert oh-my-posh initialization to the new API + sed -i 's/oh-my-posh --init --shell zsh/oh-my-posh init zsh/' $HOME/.zshrc fi