-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathswitch-p10k-clock.ps1
58 lines (47 loc) · 1.81 KB
/
switch-p10k-clock.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
Param(
[switch]
[Parameter(Mandatory=$false)]
$WithClock,
[switch]
[Parameter(Mandatory=$false)]
$Help
)
function Show-Usage {
Write-Output "
Usage: $(Split-Path $MyInvocation.ScriptName -Leaf) [-WithClock] [-Help]
Options:
-WithClock: This switch enables clock.
-Help: Show this message.
"
Exit 0
}
# Show usage
if ($Help -eq $true) {
Show-Usage
Exit 0
}
$poshthemes = "$HOME/.poshthemes"
if (!(Test-Path -Path $poshthemes)) {
New-Item -ItemType Directory -Path $poshthemes -Force
}
# Install p10k with clock
if ($WithClock -eq $true) {
Write-Output "[$(Get-Date -Format "yyyy-MM-dd HH:mm:ss")] Installing theme: Powerlevel10k with clock ..."
Copy-Item $HOME/oh-my-azure-cloud-shell/posh/powerlevel10k_rainbow-with-clock.omp.json $HOME/.poshthemes/powerlevel10k_rainbow.omp.json -Force
}
# Install p10 without clock
else {
Write-Output "[$(Get-Date -Format "yyyy-MM-dd HH:mm:ss")] Installing theme: Powerlevel10k without clock ..."
Copy-Item $HOME/oh-my-azure-cloud-shell/posh/powerlevel10k_rainbow-without-clock.omp.json $HOME/.poshthemes/powerlevel10k_rainbow.omp.json -Force
}
# Copy $PROFILE
if (!(Test-Path -Path $PROFILE)) {
New-Item -ItemType File -Path $PROFILE -Force
}
Write-Output "[$(Get-Date -Format "yyyy-MM-dd HH:mm:ss")] Copying `$PROFILE ..."
if ($WithClock -eq $true) {
Copy-Item $HOME/oh-my-azure-cloud-shell/posh/Microsoft.PowerShell_profile-p10k-with-clock.ps1 $HOME/.config/PowerShell/Microsoft.PowerShell_profile.ps1 -Force
} else {
Copy-Item $HOME/oh-my-azure-cloud-shell/posh/Microsoft.PowerShell_profile-p10k-without-clock.ps1 $HOME/.config/PowerShell/Microsoft.PowerShell_profile.ps1 -Force
}
Write-Output "[$(Get-Date -Format "yyyy-MM-dd HH:mm:ss")] Switch completed. Run '. `$PROFILE' to apply changes ..."