Skip to content

Commit 83d95ea

Browse files
committed
Merge pull request #6 from pecigonzalo/development
Merge Release 0.4
2 parents 45e9d40 + 77c2fc7 commit 83d95ea

File tree

5 files changed

+37
-110
lines changed

5 files changed

+37
-110
lines changed

plugins/ll/README.md

Whitespace-only changes.

plugins/ll/ll.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Set-Alias -Name ll -Value Get-ChildItem -option AllScope -Scope Global

plugins/ls/ls.ps1

Lines changed: 11 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -3,60 +3,10 @@
33
# https://github.com/joonro/Get-ChildItem-Color
44
# Add from https://github.com/JRJurman/PowerLS/blob/master/powerls.psm1
55
###############################################################################
6-
function Get-ChildItem-Color {
7-
if ($Args[0] -eq $true) {
8-
$ifwide = $true
9-
10-
if ($Args.Length -gt 1) {
11-
$Args = $Args[1..($Args.length - 1)]
12-
} else {
13-
$Args = @()
14-
}
15-
} else {
16-
$ifwide = $false
17-
}
18-
19-
if (($Args[0] -eq "-a") -or ($Args[0] -eq "--all")) {
20-
$Args[0] = "-Force"
21-
}
6+
function Get-ChildItem-Wide {
227

238
$width = $host.UI.RawUI.WindowSize.Width
24-
$color_fore = $host.UI.RawUI.ForegroundColor
25-
26-
$compressed_list = @(".zip", ".tar", ".gz", ".rar")
27-
$executable_list = @(".exe", ".bat", ".cmd", ".py", ".pl", ".ps1",
28-
".psm1", ".vbs", ".rb", ".reg", ".fsx", ".sh")
29-
$dll_pdb_list = @(".dll", ".pdb")
30-
$text_files_list = @(".txt", ".csv", ".lg", ".log", ".packer", ".json", ".md", ".pp", ".markdown")
31-
$configs_list = @(".cfg", ".config", ".conf", ".ini", ".properties", ".gradle", ".gitignore", ".gitattributes")
32-
33-
$color_table = @{}
34-
foreach ($Extension in $compressed_list) {
35-
$color_table[$Extension] = "Yellow"
36-
}
37-
38-
foreach ($Extension in $executable_list) {
39-
$color_table[$Extension] = "Blue"
40-
}
41-
42-
foreach ($Extension in $text_files_list) {
43-
$color_table[$Extension] = "Cyan"
44-
}
45-
46-
foreach ($Extension in $dll_pdb_list) {
47-
$color_table[$Extension] = "Darkgreen"
48-
}
49-
50-
foreach ($Extension in $configs_list) {
51-
$color_table[$Extension] = "Yellow"
52-
}
53-
54-
# Handle hiddne files
55-
$hidden_files = "^\..*$"
56-
$color_table["hidden_files"] = "DarkGray"
57-
58-
$i = 0
59-
$pad = 4
9+
$pad = 2
6010

6111
# get the longest string and get the length
6212
$childs = Get-ChildItem $Args
@@ -65,65 +15,16 @@ function Get-ChildItem-Color {
6515

6616
$childs |
6717
ForEach-Object {
68-
if ($_.GetType().Name -eq 'DirectoryInfo') {
69-
$c = 'Green'
70-
} elseif ($_.Name -match $hidden_files) {
71-
$c = $color_table["hidden_files"]
72-
} else {
73-
$c = $color_table[$_.Extension]
74-
75-
if ($c -eq $none) {
76-
$c = $color_fore
77-
}
78-
}
79-
80-
if ($ifwide) {
81-
if ($i -eq -1) { # change this to `-eq 0` to show DirectoryName
82-
if ($_.GetType().Name -eq "FileInfo") {
83-
$DirectoryName = $_.DirectoryName
84-
} elseif ($_.GetType().Name -eq "DirectoryInfo") {
85-
$DirectoryName = $_.Parent.FullName
86-
}
87-
Write-Host ""
88-
Write-Host -Fore 'Green' (" Directory: " + $DirectoryName)
89-
Write-Host ""
90-
}
91-
$towrite = $_.Name + (" "*($len - $_.name.length+$pad))
92-
$count += $towrite.length
93-
94-
Write-Host $towrite -Fore $c -nonewline
18+
$output = $_.name + (" "*($len - $_.name.length+$pad))
19+
$count += $output.length
9520

96-
if ( $count -ge ($width - ($len+$pad)) ) {
97-
Write-Host ""
98-
$count = 0
99-
}
100-
} else {
101-
If ($i -eq 0) { # first item - print out the header
102-
Write-Host "`n Directory: $DirectoryName`n"
103-
Write-Host "Mode LastWriteTime Length Name"
104-
Write-Host "---- ------------- ------ ----"
105-
}
106-
$Host.UI.RawUI.ForegroundColor = $c
107-
108-
Write-Host ("{0,-7} {1,25} {2,10} {3}" -f $_.mode,
109-
([String]::Format("{0,10} {1,8}",
110-
$_.LastWriteTime.ToString("d"),
111-
$_.LastWriteTime.ToString("t"))),
112-
$length, $_.name)
113-
114-
$Host.UI.RawUI.ForegroundColor = $color_fore
115-
116-
++$i # increase the counter
117-
}
118-
}
119-
Write-Host ""
120-
}
21+
Write-Host $output -nonewline
12122

122-
function Get-ChildItem-Format-Wide {
123-
$New_Args = @($true)
124-
$New_Args += $Args
125-
Get-ChildItem-Color $New_Args
23+
if ( $count -ge ($width - ($len+$pad)) ) {
24+
Write-Host ""
25+
$count = 0
26+
}
27+
}
12628
}
12729

128-
Set-Alias -Name ll -Value Get-ChildItem-Color -option AllScope -Scope Global
129-
Set-Alias -Name ls -Value Get-ChildItem-Format-Wide -option AllScope -Scope Global
30+
Set-Alias -Name ls -Value Get-ChildItem-Wide -option AllScope -Scope Global

plugins/pscolor/README.md

Whitespace-only changes.

plugins/pscolor/pscolor.ps1

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
$global:PSColor = @{
2+
File = @{
3+
Default = @{ Color = 'White' }
4+
Directory = @{ Color = 'Green'}
5+
Reparse = @{ Color = 'Magenta'}
6+
Hidden = @{ Color = 'DarkGray'; Pattern = '^\.' }
7+
Code = @{ Color = 'Magenta'; Pattern = '\.(java|c|cpp|cs|js|css|html|Dockerfile|gradle|
8+
pp|packergitignore|gitattributes|go|)$' }
9+
Executable = @{ Color = 'Green'; Pattern = '\.(exe|bat|cmd|py|pl|ps1|psm1|vbs|rb|reg|sh|fsx|)$' }
10+
Text = @{ Color = 'Cyan'; Pattern = '\.(txt|cfg|conf|ini|csv|log|config|
11+
xml|yml|md|markdown|properties|json|todo)$' }
12+
Compressed = @{ Color = 'Yellow'; Pattern = '\.(zip|tar|gz|rar|jar|war)$' }
13+
}
14+
Service = @{
15+
Default = @{ Color = 'White' }
16+
Running = @{ Color = 'DarkGreen' }
17+
Stopped = @{ Color = 'DarkRed' }
18+
}
19+
Match = @{
20+
Default = @{ Color = 'White' }
21+
Path = @{ Color = 'Green'}
22+
LineNumber = @{ Color = 'Yellow' }
23+
Line = @{ Color = 'White' }
24+
}
25+
}

0 commit comments

Comments
 (0)