Skip to content

Commit 82aacd5

Browse files
windows nushell stuff (#1105)
Sometimes I have to use windows, I would like to have a place were I can find useful nushell stuff making my easier and maybe eventually copy stuff other people might contribute. Would you see this fit? **NOTE**: I will gladly remove editorconfig if you prefer a separate pr or you don't want it at all.
1 parent b442c96 commit 82aacd5

File tree

2 files changed

+59
-0
lines changed

2 files changed

+59
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# windows completions
2+
3+
Completions for [Windows](https://www.microsoft.com/en-gb/windows)
4+
5+
## Usage
6+
7+
```nushell
8+
use windows-completions.nu *
9+
```
10+
11+
Afterwards, when you enter `win` and then press tab, the available commands will be displayed.
12+
13+
If you don't want to have all commands under the `win` prefix you could use the following instead.
14+
```nushell
15+
use windows-completions win *
16+
```
17+
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
export module win {
2+
3+
# open in visual studio
4+
export def "open in visual-studio" [file: path] {
5+
let vswhere = $'($env."ProgramFiles(x86)")\Microsoft Visual Studio\Installer\vswhere.exe'
6+
if not ($vswhere | path exists) { error make {msg: $"($vswhere) not found" } }
7+
8+
# https://github.com/microsoft/vswhere/wiki/Find-VC
9+
let latest = ^$vswhere -latest | parse "{property}: {value}"
10+
let installation_path = $latest | transpose --header-row | get installationPath.0
11+
let vs = $'($installation_path)\Common7\IDE\devenv.exe'
12+
if not ($vs | path exists) { error make {msg: $"($vs) not found" } }
13+
14+
run-external $vs /Edit ($file | path expand)
15+
}
16+
17+
# file version and signature viewer from file
18+
export def "read version" [file: path] {
19+
^sigcheck -nobanner $file | lines | skip 1 | parse --regex '\s*(?<name>.+?):(?<value>.+)'
20+
}
21+
22+
# application for CPU spikes, unhandled exception and hung window monitoring cli tool
23+
#
24+
# https://learn.microsoft.com/en-us/sysinternals/downloads/procdump#using-procdump
25+
#
26+
# Examples:
27+
# Install ProcDump as the (AeDebug) postmortem debugger:
28+
# procdump -ma -i c:\dumps
29+
#
30+
# Uninstall ProcDump as the (AeDebug) postmortem debugger:
31+
# procdump -u
32+
export extern "procdump" [ ...args: any ]
33+
34+
# list logical disks somehing akin to unix's df command
35+
export def "disk free" [] {
36+
(wmic logicaldisk get deviceid,size,freespace,volumename,description | str trim
37+
| detect columns
38+
| insert Use% { ($in.freespace|into int) / ($in.size|into int) * 100 }
39+
)
40+
}
41+
42+
}

0 commit comments

Comments
 (0)