Skip to content

Commit

Permalink
Merge pull request #175 from szymonos/dev
Browse files Browse the repository at this point in the history
Merge dev to main
  • Loading branch information
szymonos authored Nov 5, 2024
2 parents 7e95efd + e521b85 commit 0066649
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 37 deletions.
4 changes: 2 additions & 2 deletions .assets/config/pwsh_cfg/profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion .assets/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
12 changes: 6 additions & 6 deletions .assets/provision/install_eza.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down
11 changes: 7 additions & 4 deletions .assets/provision/setup_profile_allusers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,24 @@ fi

# *bash profile
# add common bash aliases
grep -qw 'd/aliases.sh' ~/.bashrc 2>/dev/null || cat <<EOF >>~/.bashrc
grep -qw 'd/aliases.sh' $HOME/.bashrc 2>/dev/null || cat <<EOF >>$HOME/.bashrc
# common aliases
if [ -f "$PROFILE_PATH/aliases.sh" ]; then
source "$PROFILE_PATH/aliases.sh"
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 <<EOF >>~/.bashrc
if ! grep -qw 'oh-my-posh' $HOME/.bashrc 2>/dev/null && type oh-my-posh &>/dev/null; then
cat <<EOF >>$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
Expand Down
4 changes: 0 additions & 4 deletions .assets/provision/setup_profile_user.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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...'
Expand Down
23 changes: 13 additions & 10 deletions .assets/provision/setup_profile_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,16 @@ 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 <<EOF >>~/.bashrc
grep -qw 'd/aliases.sh' $HOME/.bashrc 2>/dev/null || cat <<EOF >>$HOME/.bashrc
# common aliases
if [ -f "$PROFILE_PATH/aliases.sh" ]; then
source "$PROFILE_PATH/aliases.sh"
fi
EOF

# add git aliases
if ! grep -qw 'd/aliases_git.sh' ~/.bashrc 2>/dev/null && type git &>/dev/null; then
cat <<EOF >>~/.bashrc
if ! grep -qw 'd/aliases_git.sh' $HOME/.bashrc 2>/dev/null && type git &>/dev/null; then
cat <<EOF >>$HOME/.bashrc
# git aliases
if [ -f "$PROFILE_PATH/aliases_git.sh" ] && type git &>/dev/null; then
source "$PROFILE_PATH/aliases_git.sh"
Expand All @@ -25,16 +25,16 @@ EOF
fi

# add custom functions
grep -qw 'd/functions.sh' ~/.bashrc 2>/dev/null || cat <<EOF >>~/.bashrc
grep -qw 'd/functions.sh' $HOME/.bashrc 2>/dev/null || cat <<EOF >>$HOME/.bashrc
# custom functions
if [ -f "$PROFILE_PATH/functions.sh" ]; then
source "$PROFILE_PATH/functions.sh"
fi
EOF

# add kubectl autocompletion and aliases
if ! grep -qw 'kubectl' ~/.bashrc 2>/dev/null && type -f kubectl &>/dev/null; then
cat <<EOF >>~/.bashrc
if ! grep -qw 'kubectl' $HOME/.bashrc 2>/dev/null && type -f kubectl &>/dev/null; then
cat <<EOF >>$HOME/.bashrc
# kubectl autocompletion and aliases
if type -f kubectl &>/dev/null; then
source <(kubectl completion bash)
Expand All @@ -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 <<EOF >>~/.bashrc
if ! grep -qw 'oh-my-posh' $HOME/.bashrc 2>/dev/null && type oh-my-posh &>/dev/null; then
cat <<EOF >>$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
23 changes: 13 additions & 10 deletions .assets/provision/setup_profile_user_zsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -46,15 +46,15 @@ fi

# *aliases
# add common zsh aliases
grep -qw 'd/aliases.sh' ~/.zshrc 2>/dev/null || cat <<EOF >>$HOME/.zshrc
grep -qw 'd/aliases.sh' $HOME/.zshrc 2>/dev/null || cat <<EOF >>$HOME/.zshrc
# *aliases
if [ -f "$PROFILE_PATH/aliases.sh" ]; then
source "$PROFILE_PATH/aliases.sh"
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 <<EOF >>$HOME/.zshrc
# git aliases
if [ -f "$PROFILE_PATH/aliases_git.sh" ] && type git &>/dev/null; then
Expand All @@ -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 <<EOF >>$HOME/.zshrc
# kubectl autocompletion and aliases
if type -f kubectl &>/dev/null; then
Expand All @@ -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 <<EOF >>~/.zshrc
if ! grep -qw 'oh-my-posh' $HOME/.zshrc 2>/dev/null && type oh-my-posh &>/dev/null; then
cat <<EOF >>$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
9 changes: 9 additions & 0 deletions docs/vagrant.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 0066649

Please sign in to comment.