From d4ab871bee1b016d8609c7ffb6b67b76f1567d66 Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Tue, 29 Oct 2024 08:25:00 +0100 Subject: [PATCH 1/3] docs: set vagrant home location --- docs/vagrant.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/vagrant.md b/docs/vagrant.md index 6df462a8..2159a06f 100644 --- a/docs/vagrant.md +++ b/docs/vagrant.md @@ -90,6 +90,15 @@ vagrant plugin install vagrant-reload .assets/scripts/vg_cacert_fix.ps1 ``` +## Vagrant home location + +The Vagrant home directory is where things such as boxes are stored, so it can actually become quite large on disk. +To change it, set the `VAGRANT_HOME` enviroment variable to some other location: + +```PowerShell +[Environment]::SetEnvironmentVariable('VAGRANT_HOME', 'F:/Virtual Machines/.vagrant.d', 'Machine') +``` + ## SSH configuration For convenience's sake, newly provisioned virtual machines are being added automatically to the SSH config and known_hosts file, so you don't need to use the `vagrant ssh` command which is much slower than the built-in `ssh` one, but also allows you to use the Remote SSH feature of the Visual Studio Code, for remote development. All the VMs should be instantly visible in the VSCode Remote SSH extension pane after provisioning. From 8fbee27911560cacd34e1a23e4e2b7dd66e7ce6b Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Mon, 4 Nov 2024 17:40:04 +0100 Subject: [PATCH 2/3] fix: oh-my-posh setup --- .assets/config/pwsh_cfg/profile.ps1 | 4 ++-- .assets/docker/Dockerfile | 1 - .assets/provision/setup_profile_allusers.sh | 11 ++++++---- .assets/provision/setup_profile_user.ps1 | 4 ---- .assets/provision/setup_profile_user.sh | 23 ++++++++++++--------- .assets/provision/setup_profile_user_zsh.sh | 23 ++++++++++++--------- 6 files changed, 35 insertions(+), 31 deletions(-) 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 From e521b859a7d770adba00bd23dc0e4c4d8823e8fa Mon Sep 17 00:00:00 2001 From: Szymon Osiecki Date: Mon, 4 Nov 2024 17:52:57 +0100 Subject: [PATCH 3/3] fix(sh): install_eza --- .assets/provision/install_eza.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.assets/provision/install_eza.sh b/.assets/provision/install_eza.sh index a5705655..15655b10 100755 --- a/.assets/provision/install_eza.sh +++ b/.assets/provision/install_eza.sh @@ -51,13 +51,13 @@ fi printf "\e[92minstalling \e[1m$APP\e[0m\n" >&2 case $SYS_ID in alpine) - apk add --no-cache $APP >&2 2>/dev/null + apk add --no-cache $APP >&2 2>/dev/null || binary=true && lib='musl' ;; arch) - pacman -Sy --needed --noconfirm $APP >&2 2>/dev/null || binary=true + pacman -Sy --needed --noconfirm $APP >&2 2>/dev/null || binary=true && lib='gnu' ;; fedora) - dnf install -y $APP >&2 2>/dev/null || binary=true + dnf install -y $APP >&2 2>/dev/null || binary=true && lib='gnu' ;; debian | ubuntu) export DEBIAN_FRONTEND=noninteractive @@ -67,13 +67,13 @@ debian | ubuntu) fi echo "deb [signed-by=/etc/apt/keyrings/gierens.gpg] http://deb.gierens.de stable main" >/etc/apt/sources.list.d/gierens.list chmod 644 /etc/apt/keyrings/gierens.gpg /etc/apt/sources.list.d/gierens.list - apt-get update >&2 && apt-get install -y $APP >&2 2>/dev/null || binary=true + apt-get update >&2 && apt-get install -y $APP >&2 2>/dev/null || binary=true && lib='gnu' ;; opensuse) - zypper in -y $APP >&2 2>/dev/null || binary=true + zypper in -y $APP >&2 2>/dev/null || binary=true && lib='gnu' ;; *) - binary=true + binary=true && lib='gnu' ;; esac