-
Notifications
You must be signed in to change notification settings - Fork 3
/
Prompt.ps1
128 lines (97 loc) · 3.9 KB
/
Prompt.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
$global:COLDBOOT = $true
$NAME = "$Env:USERNAME@$Env:COMPUTERNAME"
Function Prompt {
if ($global:COLDBOOT -eq $false) {
Write-Host " "
}
if ($global:COLDBOOT) {
$global:COLDBOOT = $false
}
$ARR = @()
$MAP = [Ordered]@{
"Cargo.toml" = "🦀"
"CMakeLists.txt" = "🔺"
"deno.json" = "🦕"
"deno.jsonc" = "🦕"
"gleam.toml" = "✨"
"mix.exs" = '🩸'
"rebar.config" = '☎'
"pubspec.yaml" = '🎯'
"pubspec.yml" = '🎯'
"$(Split-Path -Leaf (Get-Location)).fsproj" = '🤖'
"$(Split-Path -Leaf (Get-Location)).csproj" = '🤖'
"go.mod" = "🐹"
"pyproject.toml" = "🐍"
"shard.yaml" = '🔮'
"shard.yml" = '🔮'
"Gemfile" = '💎'
"package.json" = '📦'
"yarn.lock" = '📦'
# Language by @TheNachoBIT
"Nucleus.toml" = '☢️'
# haskell
"stack.yaml" = "λ"
# ocaml
"dune" = "🐫"
"_opam" = "🐫"
"dune-project" = "🐫"
"esy.lock" = "🐫"
# purescript
"spago.dhall" = "<=>"
# v
"v.mod" = "V"
"vpkg.json" = "V"
".vpkg-lock.json" = "V"
# zig
".zig" = "↯"
# scala
"build.sbt" = "🆂"
".scalaenv" = "🆂"
".sbtenv" = "🆂"
".metals" = "🆂"
# lua
".lua-version" = "🌙"
"lua" = "🌙"
# elm
"elm.json" = "🌳"
"elm-package.json" = "🌳"
".elm-version" = "🌳"
}
ForEach ($KEY in $MAP.Keys) {
If (Test-Path "./$KEY") {
$ARR += $MAP[$KEY]
}
}
$ARR = $ARR | Select-Object -Unique
$LANGS = ""
if ($ARR.Count -gt 0) {
$LANGS += " via "
if ($ARR.Count -eq 1) {
$LANGS += $ARR
}
if ($ARR.Count -eq 2) {
$LANGS += $ARR[0] + " & " + $ARR[1]
}
if ($ARR.Count -eq 3) {
$LANGS += $ARR[0] + ", " + $ARR[1] + " & " + $ARR[2]
}
}
Write-Host "$NAME " -NoNewLine -ForegroundColor DarkCyan
Write-Host "in " -NoNewLine
Write-Host "$(Split-Path -Leaf (Get-Location))" -NoNewLine -ForegroundColor Blue
Write-Host $LANGS
Write-Host "$>" -NoNewline -ForegroundColor Blue
" "
}
# Overwrite Clear function to make sure it doesn't leave an extra space for prompt
# clear-host is 6x slower than /bin/clear on my phone so this is why I do this
Function clear {
[Diagnostics.CodeAnalysis.SuppressMessageAttribute("PSProvideCommentHelp", "", Justification = "/bin/clear is faster than Clear-Host")]
$global:COLDBOOT = $true
if ($IsLinux) {
& ("/bin/clear")
}
else {
Clear-Host
}
}