This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this snippet to your $PROFILE to make Bash's autocompletion available to PowerShell on Linux. | |
# Warning: adds ~500ms initialization time. | |
# References: https://brbsix.github.io/2015/11/29/accessing-tab-completion-programmatically-in-bash/ | |
# https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/register-argumentcompleter | |
# Find all commands | |
$commands = bash -c 'source /usr/share/bash-completion/bash_completion && complete' | awk '{ print $NF }' | |
$commands += ls /usr/share/bash-completion/completions | |
$commands | ForEach-Object { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description = Check Internet access | |
After = network-online.target | |
[Service] | |
Type = oneshot | |
ExecStart = /bin/bash -c "until ping -c 1 www.baidu.com; do sleep 1; done;" | |
[Install] | |
WantedBy = network-online.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$err = ($out = somecommand) 2>&1 | |
# Type of $out is string[] if present | |
# Type of $err is ErrorRecord if present |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param( | |
[Parameter(Mandatory)] [string] $Command, | |
[Parameter(Mandatory)] [string] $IconFile, | |
[string] $Output, | |
[switch] $Keep | |
) | |
(Get-Content -Encoding UTF8 template.c) -replace "COMMAND_PLACEHOLDER", ($Command -replace '\\', '\\') | Out-File -Encoding UTF8 temp.c | |
"icon ICON `"$($IconFile -replace '\\', '\\')`"" | Out-File -Encoding UTF8 temp.rc |