1
1
2
- <#
3
- . SYNOPSIS
4
- Set the prompt to a colorized string customized by elevation
5
- #>
2
+ # override the prompt function
6
3
function prompt {
7
4
$saveCode = $LASTEXITCODE
8
5
if (Confirm-Elevated ) {
@@ -18,119 +15,41 @@ function prompt {
18
15
}
19
16
20
17
21
- # =======================================================================================
22
18
# Aliases
23
- # ---------------------------------------------------------------------------------------
24
19
25
20
New-Alias ep Invoke-EditProfile
26
21
New-Alias su Invoke-SuperUser
27
22
New-Alias vs Invoke-VsDevCmd
28
23
New-Alias cc Show-ColorizedContent
29
24
25
+ . $PSScriptRoot \Modules\Scripts\Set-OutDefaultOverride.ps1
26
+ Set-Alias ls Get-ChildItemColorized - Force - Option AllScope
27
+
28
+ function Invoke-Wilma { & ' C:\Program Files\Tools\WiLMa\WinLayoutManager.exe' }
29
+ New-Alias wilma Invoke-Wilma
30
+
30
31
# Docker helpers
31
32
New-Alias doc Invoke-DockerClean
32
33
New-Alias dos Invoke-DockerShow
33
34
35
+ # OK, Go!
34
36
35
- # =======================================================================================
36
- # Get-ColorDir (ls)
37
- # ---------------------------------------------------------------------------------------
38
-
39
- New-CommandWrapper Out-Default - Process {
40
- $nocase = ([Text.RegularExpressions.RegexOptions ]::IgnoreCase)
41
- $compressed = New-Object Text.RegularExpressions.Regex(' \.(zip|tar|gz|iso)$' , $nocase )
42
- $executable = New-Object Text.RegularExpressions.Regex(' \.(exe|bat|cmd|msi|ps1|psm1)$' , $nocase )
43
-
44
- if (($_ -is [IO.DirectoryInfo ]) -or ($_ -is [IO.FileInfo ])) {
45
- if (-not ($notfirst )) {
46
- $parent = [IO.Path ]::GetDirectoryName($_.FullName )
47
- Write-Host " `n Directory: $parent `n "
48
- Write-Host " Mode Last Write Time Length Name"
49
- Write-Host " ---- --------------- ------ ----"
50
- $notfirst = $true
51
- }
52
-
53
- if ($_ -is [IO.DirectoryInfo ]) {
54
- Write-Host (" {0} {1} " -f $_.mode , ([String ]::Format(" {0,10} {1,8}" , $_.LastWriteTime.ToString (" d" ), $_.LastWriteTime.ToString (" t" )))) - NoNewline
55
- Write-Host $_.name - ForegroundColor " Blue"
56
- }
57
- else {
58
- if ($compressed.IsMatch ($_.Name )) {
59
- $color = " Magenta"
60
- }
61
- elseif ($executable.IsMatch ($_.Name )) {
62
- $color = " DarkGreen"
63
- }
64
- else {
65
- $color = " Gray"
66
- }
67
- Write-Host (" {0} {1} {2,10} " -f $_.mode , ([String ]::Format(" {0,10} {1,8}" , $_.LastWriteTime.ToString (" d" ), $_.LastWriteTime.ToString (" t" ))), $_.length ) - NoNewline
68
- Write-Host $_.name - ForegroundColor $color
69
- }
70
-
71
- $_ = $null
72
- }
73
- } - end {
74
- Write-Host
75
- }
76
-
77
- function Get-DirSize {
78
- param ($dir ,
79
- [System.Management.Automation.SwitchParameter ] $la )
80
-
81
- $bytes = 0
82
- $count = 0
83
-
84
- Get-Childitem $dir - force:$la | Foreach-Object `
85
- {
86
- if ($_ -is [IO.FileInfo ]) {
87
- $bytes += $_.Length
88
- $count ++
89
- }
90
- }
91
-
92
- Write-Host " `n " - NoNewline
93
-
94
- if ($bytes -ge 1 KB -and $bytes -lt 1 MB ) {
95
- Write-Host (" " + [Math ]::Round(($bytes / 1 KB ), 2 ) + " KB" ) - NoNewLine
96
- }
97
- elseif ($bytes -ge 1 MB -and $bytes -lt 1 GB ) {
98
- Write-Host (" " + [Math ]::Round(($bytes / 1 MB ), 2 ) + " MB" ) - NoNewLine
99
- }
100
- elseif ($bytes -ge 1 GB ) {
101
- Write-Host (" " + [Math ]::Round(($bytes / 1 GB ), 2 ) + " GB" ) - NoNewLine
102
- }
103
- else {
104
- Write-Host (" " + $bytes + " bytes" ) - NoNewLine
105
- }
106
- Write-Host " in $count files"
107
- }
108
-
109
- function Get-ColorDir {
110
- param ($dir , [System.Management.Automation.SwitchParameter ] $la )
111
- Get-Childitem $dir - force:$la
112
- Get-DirSize $dir - la:$la
37
+ # run vsdevcmd.bat if $env:vsdev is set; this is done by conemu task definition
38
+ if ($env: vsdev -eq ' 1' ) {
39
+ Invoke-VsDevCmd
113
40
}
114
41
115
- Remove-Item alias:dir
116
- Remove-Item alias:ls
117
- Set-Alias dir Get-ColorDir
118
- Set-Alias ls Get-ColorDir
119
-
120
- # =======================================================================================
121
- # OK, Go!
122
-
123
42
# Chocolatey profile (added by Chocolatey installer)
124
43
$ChocolateyProfile = " $env: ChocolateyInstall \helpers\chocolateyProfile.psm1"
125
44
if (Test-Path ($ChocolateyProfile )) {
126
45
Import-Module " $ChocolateyProfile "
127
46
}
128
47
129
- # run vsdevcmd.bat if $env:vsdev is set; this is done by conemu task definition
130
- if ($env: vsdev -eq ' 1' ) {
131
- Invoke-VsDevCmd
132
- }
133
-
134
48
# Win-X-I and Win-X-A will open in %userprofile% and %systemrootm%\system32 respectively
135
- # instead set location to root of current drive
136
- Set-Location \
49
+ # instead set location to a reasonable place
50
+ if (Test-Path ' D:\Code' ) { Set-Location ' D:\Code' ; }
51
+ elseif (Test-Path ' D:\Development' ) { Set-Location ' D:\Development' ; }
52
+ elseif (Test-Path ' D:\Dev' ) { Set-Location ' D:\Dev' ; }
53
+ elseif (Test-Path ' C:\Development' ) { Set-Location ' C:\Development' ; }
54
+ elseif (Test-Path ' C:\Dev' ) { Set-Location ' C:\Dev' ; }
55
+ else { Set-Location ' \' ; }
0 commit comments