Skip to main content
anchor the carriage return regex to the EOL
Source Link
CervEd
  • 4k
  • 1
  • 36
  • 30

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

paste() {  # Add me to your .bashrc, perhaps.
    powershell.exe Get-Clipboard | sed 's/\r\r$//'
    # The `sed` will remove the unwelcome carriage-returns
}

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

paste() {  # Add me to your .bashrc, perhaps.
    powershell.exe Get-Clipboard | sed 's/\r//'
    # The `sed` will remove the unwelcome carriage-returns
}

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

paste() {  # Add me to your .bashrc, perhaps.
    powershell.exe Get-Clipboard | sed 's/\r$//'
    # The `sed` will remove the unwelcome carriage-returns
}

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532

Show how to strip carriage-returns and package this as a function.
Source Link
Stabledog
  • 3.3k
  • 2
  • 34
  • 43

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

paste() {  # Add me to your .bashrc, perhaps.
    powershell.exe Get-Clipboard | sed 's/\r//'
    # The `sed` will remove the unwelcome carriage-returns
}

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

paste() {  # Add me to your .bashrc, perhaps.
    powershell.exe Get-Clipboard | sed 's/\r//'
    # The `sed` will remove the unwelcome carriage-returns
}

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532

alias breaks trying to paste multi-line contents
Source Link
NonlinearFruit
  • 2.6k
  • 1
  • 26
  • 28

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532


Alias

Here is a helpful alias from @Gordon Bean that removes the \r\n:

alias paste.exe="powershell.exe Get-Clipboard | perl -p -e 's/\r\n$//'"

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532


Alias

Here is a helpful alias from @Gordon Bean that removes the \r\n:

alias paste.exe="powershell.exe Get-Clipboard | perl -p -e 's/\r\n$//'"

Solution

This prints the Windows' clipboard to stdout:

powershell.exe Get-Clipboard

Examples

$ echo "hello" | clip.exe
$ powershell.exe Get-Clipboard
hello

$ date +%Y-%m-%d | clip.exe
$ powershell.exe Get-Clipboard
2019-06-13

$ alias paste.exe='powershell.exe Get-Clipboard'
$ echo "world" | clip.exe
$ paste.exe
world

source: https://github.com/Microsoft/WSL/issues/1069#issuecomment-391968532

corrected typo in user name
Source Link
Gordon Bean
  • 4.5k
  • 1
  • 33
  • 52
Loading
add alias
Source Link
NonlinearFruit
  • 2.6k
  • 1
  • 26
  • 28
Loading
Source Link
NonlinearFruit
  • 2.6k
  • 1
  • 26
  • 28
Loading