# Just copy and paste following to ~/.bashrc
alias scb="set_clipboard"
alias gcb="get_clipboard"
set_clipboard() {
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
cat <<'EOF'
Usage:
set_clipboard "text"
echo "text" | set_clipboard
Description:
Copies the text to the Windows clipboard.
Examples:
set_clipboard "Hello, world!"
echo "Hello, world!" | set_clipboard
EOF
return
fi
if [ -t 0 ]; then
echo "$1" | clip.exe
else
cat | clip.exe
fi
}
get_clipboard() {
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
cat <<'EOF'
Usage:
get_clipboard
Description:
Prints the contents of the Windows clipboard.
Example:
get_clipboard > file.txt
EOF
return
fi
powershell.exe -NoProfile -Command 'Get-Clipboard'
}
Created
June 17, 2025 01:56
-
-
Save FOBshippingpoint/3d7e8f27b3e2d322f77090ffcabb01c9 to your computer and use it in GitHub Desktop.
PowerShell-Like WSL Clipboard Aliases
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment