Skip to content

Commit

Permalink
Merge pull request #171 from szymonos/dev
Browse files Browse the repository at this point in the history
Merge dev to main
  • Loading branch information
szymonos authored Sep 16, 2024
2 parents c0ea1ae + f8d4331 commit a206653
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 30 deletions.
8 changes: 4 additions & 4 deletions .assets/provision/distro_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ declare -A state=(
["conda"]=$([ -d $HOME/miniconda3 ] && echo "true" || echo "false")
["git_user"]=$([ -n "$(git config --global --get user.name 2>/dev/null)" ] && echo "true" || echo "false")
["git_email"]=$([ -n "$(git config --global --get user.email 2>/dev/null)" ] && echo "true" || echo "false")
["gtkd"]=$([ grep -Fqw "dark" /etc/profile.d/gtk_theme.sh 2>/dev/null ] && echo "true" || echo "false")
["gtkd"]=$(grep -Fqw "dark" /etc/profile.d/gtk_theme.sh 2>/dev/null && echo "true" || echo "false")
["k8s_base"]=$([ -f /usr/bin/kubectl ] && echo "true" || echo "false")
["k8s_ext"]=$([ -f /usr/local/bin/k3d ] && echo "true" || echo "false")
["omp"]=$([ -f /usr/bin/oh-my-posh ] && echo "true" || echo "false")
["pwsh"]=$([ -f /usr/bin/pwsh ] && echo "true" || echo "false")
["shell"]=$([ -f /usr/bin/rg ] && echo "true" || echo "false")
["ssh_key"]=$([ -f $HOME/.ssh/id_ed25519 ] && echo "true" || echo "false")
["systemd"]=$([ grep -qw "systemd.*true" /etc/wsl.conf 2>/dev/null ] && echo "true" || echo "false")
["tf"]=$([ -f /usr/local/bin/tfswitch ] && echo "true" || echo "false")
["wsl_boot"]=$([ grep -qw "autoexec\.sh" /etc/wsl.conf 2>/dev/null ] && echo "true" || echo "false")
["systemd"]=$(grep -qw "systemd.*true" /etc/wsl.conf 2>/dev/null && echo "true" || echo "false")
["tf"]=$([ -f /usr/bin/terraform ] && echo "true" || echo "false")
["wsl_boot"]=$(grep -Fqw "autoexec.sh" /etc/wsl.conf 2>/dev/null && echo "true" || echo "false")
["wslg"]=$([ -d /mnt/wslg ] && echo "true" || echo "false")
["zsh"]=$([ -f /usr/bin/zsh ] && echo "true" || echo "false")
)
Expand Down
3 changes: 0 additions & 3 deletions .assets/provision/install_azurecli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,3 @@ conda deactivate
# make symbolic link to az cli
mkdir -p "$HOME/.local/bin"
ln -sf "$HOME/miniconda3/envs/azurecli/bin/az" "$HOME/.local/bin/"

# restore working directory
popd >/dev/null
4 changes: 2 additions & 2 deletions .assets/provision/install_terraform.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ retry_count=0
# return latest release
echo $REL

if type $APP &>/dev/null; then
VER=$($APP --version | sed -En 's/Terraform v([0-9\.]+)/\1/p')
if [ -x /usr/bin/terraform ]; then
VER=$(/usr/bin/terraform --version | sed -En 's/Terraform v([0-9\.]+)/\1/p')
if [ "$REL" = "$VER" ]; then
printf "\e[32m$APP v$VER is already latest\e[0m\n" >&2
exit 0
Expand Down
10 changes: 8 additions & 2 deletions .assets/provision/setup_profile_user.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ if (Get-Module -Name Microsoft.PowerShell.PSResourceGet -ListAvailable) {
}
# disable oh-my-posh update notice
if (Get-Command oh-my-posh -CommandType Application) {
oh-my-posh disable notice
oh-my-posh disable notice | Out-Null
}
# install PSReadLine
for ($i = 0; ((Get-Module PSReadLine -ListAvailable).Count -eq 1) -and $i -lt 5; $i++) {
Expand All @@ -43,7 +43,13 @@ for ($i = 0; ((Get-Module PSReadLine -ListAvailable).Count -eq 1) -and $i -lt 5;
$kubectlSet = try { Select-String '__kubectl_debug' -Path $PROFILE -Quiet } catch { $false }
if ((Test-Path /usr/bin/kubectl) -and -not $kubectlSet) {
Write-Host 'adding kubectl auto-completion...'
(/usr/bin/kubectl completion powershell).Replace("'kubectl'", "'k'") >$PROFILE
# build completer text
$completer = [string]::Join("`n",
(/usr/bin/kubectl completion powershell) -join "`n",
"Register-ArgumentCompleter -CommandName 'k' -ScriptBlock `${__kubectlCompleterBlock}"
)
# add additional ArgumentCompleter at the end of the profile
[System.IO.File]::WriteAllText($PROFILE, $completer)
}

# setup conda initialization
Expand Down
9 changes: 0 additions & 9 deletions .assets/provision/setup_profile_user.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,6 @@ fi
EOF
fi

# add terraform using tfswitch
if [ -f /usr/local/bin/tfswitch ] && ! command -v terraform &>/dev/null; then
LOCAL_BIN="$HOME/.local/bin"
# create local bin directory if it does not exist
[ -d $LOCAL_BIN ] && true || mkdir -p $LOCAL_BIN
printf '\e[92minstalling Terraform using tfswitch\e[0m\n' >&2
tfswitch --bin="$LOCAL_BIN/terraform" --latest
fi

# add conda initialization
if ! grep -qw '__conda_setup' ~/.bashrc 2>/dev/null && [ -f $HOME/miniconda3/bin/conda ]; then
$HOME/miniconda3/bin/conda init bash >/dev/null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,26 @@ Install latest CascadaCode fonts.
https://github.com/microsoft/cascadia-code
.EXAMPLE
.assets/scripts/cascadia_code_install.ps1
.assets/scripts/fonts_install_cascadia_code.ps1
# :check installed fonts
[Drawing.Text.InstalledFontCollection]::new().Families | Select-String 'cascadia' -Raw
#>
[CmdletBinding()]
param ()

begin {
$ErrorActionPreference = 'Stop'

$tmp = New-Item "tmp.$(Get-Random)" -ItemType Directory
$fontArchive = [IO.Path]::Combine($tmp, 'CascadiaCode.zip')

# latest release api endpoint for the cascadia-code repo
$urlGHRel = 'https://api.github.com/repos/microsoft/cascadia-code/releases/latest'
}

process {
# get latest version
$rel = (Invoke-RestMethod https://api.github.com/repos/microsoft/cascadia-code/releases/latest).tag_name -replace '^v'
$rel = (Invoke-RestMethod $urlGHRel).tag_name -replace '^v'
# download font
try {
$uri = "https://github.com/microsoft/cascadia-code/releases/download/v${REL}/CascadiaCode-${REL}.zip"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Specified font extension.
.EXAMPLE
$Font = 'FiraCode'
.assets/scripts/nerd_fonts_install.ps1 $Font
.assets/scripts/fonts_install_nerd.ps1 $Font
# :check installed fonts
[Drawing.Text.InstalledFontCollection]::new().Families | Select-String $Font
#>
Expand Down
2 changes: 1 addition & 1 deletion docs/wsl_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ There are three themes included in the repository:
![omp_base.png](images/omp_base.png)
- `powerline` - using extended, powerline fonts, e.g. **Cascadia Code PL** fonts, to be downloaded from [microsoft/cascadia-code](https://github.com/microsoft/cascadia-code)
![omp_base.png](images/omp_powerline.png)
- `nerd` - using nerd fonts - can be downloaded manually from [ryanoasis/nerd-fonts](https://github.com/ryanoasis/nerd-fonts) or installed using the script [install_fonts_nerd.ps1](../.assets/scripts/nerd_fonts_install.ps1)
- `nerd` - using nerd fonts - can be downloaded manually from [ryanoasis/nerd-fonts](https://github.com/ryanoasis/nerd-fonts) or installed using the script [install_fonts_nerd.ps1](../.assets/scripts/fonts_install_nerd.ps1)
![omp_base.png](images/omp_nerd.png)

You can also specify any other theme name from [Themes | Oh My Posh](https://ohmyposh.dev/docs/themes) - it will be downloaded and installed automatically during the provisioning.
Expand Down
13 changes: 7 additions & 6 deletions wsl/wsl_setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,18 @@ process {
$rel_bat = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_bat.sh $Script:rel_bat
$rel_rg = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_ripgrep.sh $Script:rel_rg
$rel_yq = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_yq.sh $Script:rel_yq
# *setup bash profiles
Write-Host 'setting up profile for all users...' -ForegroundColor Cyan
wsl.exe --distribution $Distro --user root --exec .assets/provision/setup_profile_allusers.sh $chk.user
Write-Host 'setting up profile for current user...' -ForegroundColor Cyan
wsl.exe --distribution $Distro --exec .assets/provision/setup_profile_user.sh
continue
}
terraform {
Write-Host 'installing terraform utils...' -ForegroundColor Cyan
$rel_tfs = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_tfswitch.sh $Script:rel_tfs
$rel_tf = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_terraform.sh $Script:rel_tf
$rel_trs = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_terrascan.sh $Script:rel_trs
$rel_tfs = wsl.exe --distribution $Distro --user root --exec .assets/provision/install_tfswitch.sh $Script:rel_tfs
continue
}
zsh {
Expand All @@ -431,11 +437,6 @@ process {
continue
}
}
# *setup bash profiles
Write-Host 'setting up profile for all users...' -ForegroundColor Cyan
wsl.exe --distribution $Distro --user root --exec .assets/provision/setup_profile_allusers.sh $chk.user
Write-Host 'setting up profile for current user...' -ForegroundColor Cyan
wsl.exe --distribution $Distro --exec .assets/provision/setup_profile_user.sh
# *set gtk theme for wslg
if ($lx.Version -eq 2 -and $chk.wslg) {
$GTK_THEME = if ($GtkTheme -eq 'light') {
Expand Down

0 comments on commit a206653

Please sign in to comment.