Skip to content

Proper way to paste a link #659

@joeky888

Description

@joeky888

Environment data

PS version: 5.1.16299.251
PSReadline version: 1.2
os: 10.0.16299.15 (WinBuild.160101.0800)
PS file version: 10.0.16299.15 (WinBuild.160101.0800)

Steps to reproduce or exception report

Well this is not a bug but a question.

I have this binding in profile.ps1

Set-PSReadlineKeyHandler -Chord Ctrl+V -ScriptBlock {
    $clipboard = Get-Clipboard -Raw
    $clipboard = $clipboard -replace "&","``&"
    [Microsoft.PowerShell.PSConsoleReadLine]::Insert($clipboard)
 }

When I press Ctrl-V, it will paste the data from system clipboard and & character will be escaped.

It is convenient when the clipboard data is a web link like https://example.com?a=b&c=d .

However, if the clipboard data contains double quotes like this "https://example.com?a=b&c=d" , then there is no need to escape the & character.

How can I do a smart pasting. Thanks :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-QuestionFor non-bug questions or discussion.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions