Skip to content

Commit 0eda6b1

Browse files
authored
feature: past-to-clip: add
1 parent 252fa15 commit 0eda6b1

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

menu/paste-to-clip.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
export const pasteToClip = async ({CloudCmd, DOM}) => {
2+
const value = await navigator.clipboard.readText();
3+
const encoded = btoa(encodeURIComponent(`${value}\n`));
4+
5+
const command = [
6+
'export $CLIP=',
7+
'node',
8+
'-e',
9+
`'process.stdout.write(decodeURIComponent(atob("${encoded}")));'`,
10+
'>',
11+
].join(' ');
12+
13+
const {TerminalRun, config} = CloudCmd;
14+
const cwd = config('root') + DOM.CurrentInfo.dirPath;
15+
16+
return await TerminalRun.show({
17+
cwd,
18+
command,
19+
closeMessage: 'Press any key to close Terminal',
20+
autoClose: false,
21+
});
22+
};

0 commit comments

Comments
 (0)