|
| 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) { |
| 7 | + error make {msg: $"($vswhere) not found" } |
| 8 | + } |
| 9 | + |
| 10 | + # https://github.com/microsoft/vswhere/wiki/Find-VC |
| 11 | + let installation_path = (^$vswhere -latest -products * -requires Microsoft.Component.MSBuild -property installationPath | str trim) |
| 12 | + let vs = $'($installation_path)\Common7\IDE\devenv.exe' |
| 13 | + if not ($vs | path exists) { |
| 14 | + error make {msg: $"($vs) not found" } |
| 15 | + } |
| 16 | + |
| 17 | + run-external $vs /Edit ($file | path expand) |
| 18 | + } |
| 19 | + |
| 20 | + def "nu-complete procs" [] { ps | select pid name | sort-by name | rename -c { pid: value, name: description } } |
| 21 | + |
| 22 | + export def "windbg attach-to-process" [ --pid(-p): int@"nu-complete procs" ] { |
| 23 | + let windbg = '~/AppData/Local/Microsoft/WindowsApps/WinDbgX.exe' |
| 24 | + if (not ($windbg | path exists)) { |
| 25 | + error make {msg: $"($windbg) not found, please edit 'windbg attach-to-process' function in ($env.CURRENT_FILE)" } |
| 26 | + } |
| 27 | + run-external $windbg "-p" $pid |
| 28 | + } |
| 29 | + |
| 30 | + # file version and signature viewer from file |
| 31 | + export def "read version" [file: path] { |
| 32 | + ^sigcheck -nobanner $file | lines | skip 1 | parse --regex '\s*(?<name>.+?):(?<value>.+)' |
| 33 | + } |
| 34 | + |
| 35 | + # application for CPU spikes, unhandled exception and hung window monitoring cli tool |
| 36 | + # |
| 37 | + # https://learn.microsoft.com/en-us/sysinternals/downloads/procdump#using-procdump |
| 38 | + # |
| 39 | + # Examples: |
| 40 | + # Install ProcDump as the (AeDebug) postmortem debugger: |
| 41 | + # procdump -ma -i c:\dumps |
| 42 | + # |
| 43 | + # Uninstall ProcDump as the (AeDebug) postmortem debugger: |
| 44 | + # procdump -u |
| 45 | + export extern "procdump" [ ...args: any ] |
| 46 | + |
| 47 | + # list logical disks |
| 48 | + export def disks [] { |
| 49 | + # TODO:integrate `wmic logicaldisk where "DeviceID='C:'" get FreeSpace, Size` |
| 50 | + # can we get something similar to df? |
| 51 | + # Filesystem Size Used Avail Use% Mounted on |
| 52 | + # /dev/sda3 233G 32G 199G 14% / |
| 53 | + # /dev/sda3 233G 32G 199G 14% /home |
| 54 | + wmic logicaldisk get deviceid, size, freespace, volumename, description | str trim | detect columns |
| 55 | + } |
| 56 | + |
| 57 | +} |
| 58 | + |
0 commit comments