[Question]
  [
Following the [best](https://stackoverflow.com/questions/1197417/why-are-plain-text-passwords-bad-and-how-do-i-convince-my-boss-that-his-treasur) [security](http://plaintextoffenders.com/about/) [practices](http://gizmodo.com/sony-kept-thousands-of-passwords-in-a-document-marked-1666772286), I keep a plain text file with my passwords on my hard drive. In fact, I just copied and pasted one of them to access my PPCG account.
In a lucid moment, I decide that the password should better not remain in the clipboard after its use. Since this happens to me often, I could use a program to remove the clipboard contents.
## Challenge
Write a [program or function](http://meta.codegolf.stackexchange.com/a/2422/36398) that deletes or overwrites any text contained in the clipboard, using a [programming language](http://meta.codegolf.stackexchange.com/a/2073/36398) of your choice.
Additional details:
* If your system has several clipboards, you can write the program for any one of them. The only requirement is that it must be possible for the user to copy and paste text using that clipboard.
* If your clipboard keeps a history of recent copied entries, assume the most recent entry.
* If your answer is specific to an operating system or clipboard, indicate it in the title of your post, together with the used language.
* The clipboard is guaranteed to contain text when your program is run. You can either delete the contents from the clipboard, or overwrite it with something else (not necessarily text). The only requirement is that after running the program, pasting from the clipboard will not produce the original text.
* If you choose to overwrite with some fixed or randomly chosen text, you can assume that the previous clipboard contents are different from that text, so the password is effectively removed. In other words, disregard the possibility that the filler text coincides with the password.
* The program should not have any side-effects like restarting the system, closing programs, shutting down the computer, or freezing it. After your program is run, the user should be able to keep using the computer as normal, only with the password removed from the clipboard. Also, [standard loopholes](http://meta.codegolf.stackexchange.com/questions/1061/loopholes-that-are-forbidden-by-default) are forbidden.
Shortest code in bytes wins.
  
[Answer]
# PowerShell, 3 bytes
```
scb
```
That's a default alias for `Set-Clipboard`. When called with nothing piped in and no arguments supplied, it blows away the current clipboard contents.
[Answer]
# Vim, 3 bytes
```
"*Y
```
Sets the clipboard content to a newline.
By default, vim opens an empty buffer on start up. Now the program `Y`anks (copy) the entire line (including a newline) and store it in your clipboard by yanking it the text into register `"*`. The `*` can be changed to a `+` for the other clipboard.
[Answer]
# Javascript (Chrome DevTools Console), 6 bytes
```
copy``
```
Note that this is a feature of the console (which also works in the FF console) and is not part of the language standard.
[Answer]
## AppleScript, 20 bytes
```
set the clipboard to
```
Sets the clipboard to... nothing.
---
I saved a lot of bytes by removing the code to send me the contents of the clipboard ;)
[Answer]
# Batch (Windows 7 and higher version), 7 bytes
```
fc|clip
```
Note: it will response error message like "FC:..." but it works.
"clip" is a command to copy the output of another program to clipboard (available since windows 7)
"fc" is a command to compare two or more files. in this case we not input any file. it will error, then "clip" will set clipboard to an empty string.
provided that you have a file "a" in your current directory (it can be empty), you can do one better:
```
clip<a
```
---
Edit: See @Matthew Steeples comment for the shorter version (but in powershell not a batch)
[Answer]
# Bash on macOS, 8 bytes
```
:|pbcopy
```
`:` could be replaced with almost any other single character.
[Answer]
## C (on Windows), ~~65~~ ~~62~~ ~~42~~ 41 bytes
```
main(){EmptyClipboard(OpenClipboard(0));}
```
Note that the Visual C++ command-line needs `/link user32.lib` but the IDE or other compilers may automatically include this. Also this won't work in Win16 because the calling convention is incorrect.
Edit: Saved 3 bytes thanks to @Orion. Saved 20 bytes thanks to @KrzysztofSzewczyk. Saved a further byte thanks to @ceilingcat.
[Answer]
## [AHK](https://en.wikipedia.org/wiki/AutoHotkey), 10 bytes `(Windows)`
```
clipboard=
```
Clears text content of the clipboard. If `clipboardAll` is used it clears everything.
From the *[docs](https://autohotkey.com/docs/misc/Clipboard.htm#Clipboard_and_ClipboardAll)* - 
> 
> Clipboard is a built-in variable that reflects the current contents of the Windows clipboard if those contents can be expressed as text. By contrast, ClipboardAll contains everything on the clipboard, such as pictures and formatting.
> 
> 
> 
[Answer]
# Excel, 1 keystroke
`Ctrl-C`
Works because Excel, uniquely, always has a selection. Probably works in other spreadsheet applications too. As opposed to the other joking entries, Excel answers are actually somewhat frequent on PPCG.
[Answer]
# Java 8, 127 125 bytes
Golfed:
```
()->java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new java.awt.datatransfer.StringSelection(""),null)
```
Ungolfed:
```
public class ICopiedMyPasswordToTheClipboardCanYouDeleteIt {
  public static void main(String[] args) {
    f(() -> java.awt.Toolkit.getDefaultToolkit().getSystemClipboard().setContents(
      new java.awt.datatransfer.StringSelection(""), null));
  }
  private static void f(Runnable x) {
    x.run();
  }
}
```
[Answer]
# SmileBASIC 3, 10 bytes
Finally, a challenge practically *made* for SmileBASIC 3!
```
CLIPBOARD"
```
`CLIPBOARD` is a builtin that sets the environment's text clipboard to the given string. Here we give it an empty string (closing `"` isn't needed!)
[Answer]
## Excel VBA, ~~9~~ 8 bytes
```
[A1].Cut
```
Overwrites the clipboard with contents of `A1` cell in active worksheet (empty by default but may be any string/expression of your choice - just make sure it's not your password!).
Utilises the Immediate Window.
*One byte saved thanks to [Slai](https://codegolf.stackexchange.com/users/59149/slai)*
[Answer]
# Google Chrome Language, 2 keystrokes
`Ctrl-S` `Ctrl-C`
Based on [this](https://codegolf.stackexchange.com/a/111573/61904) Notepad++ answer.
Google Chrome supports Javascript (which in turn supports RegExp), so I hereby claim it to be a superset of Javascript and a language of its own.
How it works:
`Ctrl+S` will invoke the "Save Page" dialog with the "New Tab" text pre-selected, `Ctrl+C` will copy it into the clipboard, displacing the previous content.
Sidenote:
> 
> You can access the Javascript functionality in Chrome, via `javascript:` URLs and the Developer Tools console (invoked with Ctrl+Shift+J)
> 
> 
> 
[Answer]
# **Python 56 48  40 bytes (Only works on Linux)**.
8 bytes saved thanks to @wheatwizard.
```
import os as o
o.system("echo|xclip")
```
[Answer]
# Mathematica, 17 bytes
```
CopyToClipboard@0
```
Sets clipboard to the number 0.
[Answer]
## bash + xsel ~~8~~ 7bytes
```
xsel -c
```
## Explanation
~~`-b`: Works on clipboard selection~~ 
`-c`: clears the selection
[Answer]
# R (Windows) 18
```
writeClipboard("")
```
[Answer]
# Matlab, ~~19~~ 13 bytes
```
gcf;print -dm
```
Set clipboard contents to an empty figure.
[Answer]
# Bash, ~~11~~ ~~10~~ ~~8~~ 7 bytes
*2 bytes saved thanks to @seshoumara for using `ls` instead of `echo`*
*Thanks to hexafraction, isaacg and Riker for suggesting several 7-byters*
```
w|xclip
```
The clipboard is set to the result of `w`. This only works on X11 based systems. For example, on macOS, this clipboard can be accessed by using an X based application like XQuartz.
---
Old answer only for macOS (~~11~~ 9 bytes):
```
ls|pbcopy
```
This sets the clipboard content to a newline.
[Answer]
# Applescript, 23 bytes
```
set the clipboard to ""
```
[Answer]
# Notepad++, 3 Keystrokes
`a` `Ctrl-A` `Ctrl-C`
Inserts the letter a, selects it, copies it to the keyboard.
Notepad++ *is* a valid language, it supports regex and is therefore a superset of regex, and we consider regex to be a valid language.
[Answer]
# Python + tkinter, 43 bytes
Python 3:
```
from tkinter import*;Tk().clipboard_clear()
```
Python 2:
```
from Tkinter import*;Tk().clipboard_clear()
```
[Answer]
# **Python 33 bytes (Only works on Windows)**.
4 bytes saved from @hubacub version.
3 bytes switching to windows, using @Divcy solution
```
import os
os.system("fc|clip")
```
Just registered in stackexchange, so I don't have the reputation to just comment on @hubacub submition. There is no need to expend 5 bytes with " as o" in the import to save 1 byte to reduce "os.system" to "o.system".
[Answer]
# C#, 30 bytes
*Thanks to [Nat](https://codegolf.stackexchange.com/users/45619/nat), [JMD](https://codegolf.stackexchange.com/users/66095/jmd) and [BgrWorker](https://codegolf.stackexchange.com/users/61283/bgrworker) for their suggestions!*
```
System.Windows.Clipboard.Clear
```
# C# without WPF, 36 bytes
```
System.Windows.Forms.Clipboard.Clear
```
Built-in function which empties the clipboard.
Full program with test case:
```
using System;
using System.Windows.Forms;
class ClearClipboard
{
    static void Main()
    {
        Action f =
        ()=>System.Windows.Forms.Clipboard.Clear();
        // test case:
        Clipboard.SetText("SomePassword!");
        Console.WriteLine("In clipboard initially: " + Clipboard.GetText());
        f();
        Console.WriteLine("In clipboard now: " + Clipboard.GetText());
    }
}
```
[Answer]
## Haskell, 34 bytes
```
import System.Hclip
setClipboard""
```
Just a boring library function. There's also `clearClipboard` for the same byte count. 
[Answer]
## [J](http://www.jsoftware.com) (Windows), 12 bytes
```
wd'clipcopy'
```
`wd` is J's standard library for Windows. `wd 'clipcopy password'` would put the text `password` into the clipboard. Specifying nothing wipes the clipboard.
If you want a program to put your plaintext password into your clipboard, you could use the following:
```
pass =. 'abc123'
wd 'clipcopy ' , pass
```
[Answer]
# Java 8 (JavaFX), 61 bytes
`()->javafx.scene.input.Clipboard.getSystemClipboard().clear()`
The JavaFX API for manipulating the clipboard is a little more terse than AWT's ;)
[Answer]
# Tcl/Tk wish shell (REPL), 5 bytes
```
cli c
```
Wish shell (REPL) allows for the incomplete commands, as long as there is no ambiguity, the full command would be:
```
clipboard clear
```
[Answer]
# Cow, 9 bytes
```
OOOMMMOOO
```
Explanation:
```
OOO set current memory block to 0
MMM if the current memory block is 0, paste the clipboard and clear the clipboard.
OOO set it back to 0
```
[Answer]
# HTML + JavaScript, ~~175~~ ~~148~~ ~~139~~ ~~135~~ 69 Bytes
Golfed:
```
<input value="c"onclick="this.select();document.execCommand('copy')">
```
[Fiddle](https://jsfiddle.net/g0sk97ch/)
Ungolfed
Got help from [SitePoint](https://www.sitepoint.com/javascript-copy-to-clipboard/)
HTML:
```
<input style="display: none;" id="Empty" value="x">
<input id="clipclear" type="button" value="Clear The Clipboard">
```
JS:
```
function clearclip(){
empty=document.getElementById("Empty");
empty.style.display="block";
empty.select();
        document.execCommand('copy');
empty.style.display="none";
}      
document.getElementById("clipclear").addEventListener("click", clearclip, false);
```
]