Skip to content

# cmd2.clipboard

## `` cmd2.clipboard

Module provides basic ability to copy from and paste to the clipboard/pastebuffer.

### `` get_paste_buffer

    get_paste_buffer()

Get the contents of the clipboard / paste buffer.

RETURNS | DESCRIPTION
--- | ---
`str` | contents of the clipboard

Source code in `cmd2/clipboard.py`

     8
     9
    10
    11
    12
    13

    def get_paste_buffer() -> str:
        """Get the contents of the clipboard / paste buffer.

        :return: contents of the clipboard
        """
        return typing.cast(str, pyperclip.paste())

### `` write_to_paste_buffer

    write_to_paste_buffer(txt)

Copy text to the clipboard / paste buffer.

PARAMETER | DESCRIPTION
--- | ---
`txt` | text to copy to the clipboard TYPE: `str`

Source code in `cmd2/clipboard.py`

    16
    17
    18
    19
    20
    21

    def write_to_paste_buffer(txt: str) -> None:
        """Copy text to the clipboard / paste buffer.

        :param txt: text to copy to the clipboard
        """
        pyperclip.copy(txt)