/usr/share/doc/copyq/html/command-examples.html is in copyq-doc 3.2.0-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 | <!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Command Examples — CopyQ documentation</title>
<link rel="shortcut icon" href="_static/icon_32x32.png"/>
<link rel="stylesheet" href="_static/css/theme.css" type="text/css" />
<link rel="index" title="Index"
href="genindex.html"/>
<link rel="search" title="Search" href="search.html"/>
<link rel="top" title="CopyQ documentation" href="index.html"/>
<link rel="next" title="Backup" href="backup.html"/>
<link rel="prev" title="Scripting" href="scripting.html"/>
<script src="_static/js/modernizr.min.js"></script>
</head>
<body class="wy-body-for-nav" role="document">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search">
<a href="index.html" class="icon icon-home"> CopyQ
<img src="_static/icon_64x64.png" class="logo" />
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<p class="caption"><span class="caption-text">The Basics</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="installation.html">Installation</a></li>
<li class="toctree-l1"><a class="reference internal" href="basic-usage.html">Basic Usage</a></li>
<li class="toctree-l1"><a class="reference internal" href="tabs-and-items.html">Tabs and Items</a></li>
<li class="toctree-l1"><a class="reference internal" href="keyboard.html">Keyboard</a></li>
<li class="toctree-l1"><a class="reference internal" href="images.html">Images</a></li>
<li class="toctree-l1"><a class="reference internal" href="tags.html">Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq.html">FAQ - Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="glossary.html">Glossary</a></li>
</ul>
<p class="caption"><span class="caption-text">Advanced Topics</span></p>
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="command-line.html">Command Line</a></li>
<li class="toctree-l1"><a class="reference internal" href="sessions.html">Sessions</a></li>
<li class="toctree-l1"><a class="reference internal" href="pin-items.html">Pin Items</a></li>
<li class="toctree-l1"><a class="reference internal" href="password-protection.html">Password Protection</a></li>
<li class="toctree-l1"><a class="reference internal" href="synchronize.html">Synchronize with Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="writing-commands-and-adding-functionality.html">Writing Commands and Adding Functionality</a></li>
<li class="toctree-l1"><a class="reference internal" href="scripting.html">Scripting</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Command Examples</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#join-selected-items">Join Selected Items</a></li>
<li class="toctree-l2"><a class="reference internal" href="#paste-current-date-and-time">Paste Current Date and Time</a></li>
<li class="toctree-l2"><a class="reference internal" href="#play-sound-when-copying-to-clipboard">Play Sound when Copying to Clipboard</a></li>
<li class="toctree-l2"><a class="reference internal" href="#edit-and-paste">Edit and Paste</a></li>
<li class="toctree-l2"><a class="reference internal" href="#ignore-images-when-text-is-available">Ignore Images when Text is Available</a></li>
<li class="toctree-l2"><a class="reference internal" href="#remove-background-and-text-colors">Remove Background and Text Colors</a></li>
<li class="toctree-l2"><a class="reference internal" href="#linkify">Linkify</a></li>
<li class="toctree-l2"><a class="reference internal" href="#highlight-text">Highlight Text</a></li>
<li class="toctree-l2"><a class="reference internal" href="#render-html">Render HTML</a></li>
<li class="toctree-l2"><a class="reference internal" href="#translate-to-english">Translate to English</a></li>
<li class="toctree-l2"><a class="reference internal" href="#paste-and-forget">Paste and Forget</a></li>
<li class="toctree-l2"><a class="reference internal" href="#render-math-equations">Render Math Equations</a></li>
<li class="toctree-l2"><a class="reference internal" href="#move-images-to-other-tab">Move Images to Other Tab</a></li>
<li class="toctree-l2"><a class="reference internal" href="#copy-clipboard-to-window-tabs">Copy Clipboard to Window Tabs</a></li>
<li class="toctree-l2"><a class="reference internal" href="#quickly-show-current-clipboard-content">Quickly Show Current Clipboard Content</a></li>
<li class="toctree-l2"><a class="reference internal" href="#replace-all-occurrences-in-selected-text">Replace All Occurrences in Selected Text</a></li>
<li class="toctree-l2"><a class="reference internal" href="#copy-nth-item">Copy Nth Item</a></li>
<li class="toctree-l2"><a class="reference internal" href="#edit-file">Edit File</a></li>
<li class="toctree-l2"><a class="reference internal" href="#change-monitoring-state-permanently">Change Monitoring State Permanently</a></li>
<li class="toctree-l2"><a class="reference internal" href="#show-window-title">Show Window Title</a></li>
<li class="toctree-l2"><a class="reference internal" href="#show-copy-time">Show Copy Time</a></li>
<li class="toctree-l2"><a class="reference internal" href="#mark-selected-items">Mark Selected Items</a></li>
<li class="toctree-l2"><a class="reference internal" href="#change-upper-lower-case-of-selected-text">Change Upper/Lower Case of Selected Text</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="backup.html">Backup</a></li>
<li class="toctree-l1"><a class="reference internal" href="writing-raw-data.html">Writing Raw Data</a></li>
<li class="toctree-l1"><a class="reference internal" href="scripting-api.html">Scripting API</a></li>
</ul>
<p class="caption"><span class="caption-text">Development</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="build-source-code.html">Build from Source Code</a></li>
<li class="toctree-l1"><a class="reference internal" href="fixing-bugs.html">Fixing Bugs and Adding Features</a></li>
<li class="toctree-l1"><a class="reference internal" href="source-code-overview.html">Source Code Overview</a></li>
<li class="toctree-l1"><a class="reference internal" href="translations.html">Translations</a></li>
<li class="toctree-l1"><a class="reference internal" href="text-encoding.html">Text Encoding</a></li>
<li class="toctree-l1"><a class="reference internal" href="customize-and-build-the-windows-installer.html">Customize and Build the Windows Installer</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" role="navigation" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">CopyQ</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html">Docs</a> »</li>
<li>Command Examples</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/command-examples.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="command-examples">
<span id="id1"></span><h1>Command Examples<a class="headerlink" href="#command-examples" title="Permalink to this headline">¶</a></h1>
<p>Here are some useful commands for creating custom menu items, global
shortcuts and automatically process new clipboard content in CopyQ.</p>
<p>If you want to use any of the commands below, copy it to clipboard and
paste it to the command list in Command dialog (opened with F6
shortcut). For detailed info see <a class="reference internal" href="faq.html#faq-share-commands"><span class="std std-ref">How to load shared commands and share them?</span></a>.</p>
<p>All these and more commands are available at
<a class="reference external" href="https://github.com/hluk/copyq-commands">CopyQ command repository</a>.</p>
<div class="section" id="join-selected-items">
<h2>Join Selected Items<a class="headerlink" href="#join-selected-items" title="Permalink to this headline">¶</a></h2>
<p>Creates new item containing concatenated text of selected items.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Join Selected Items</span>
<span class="na">Command</span><span class="o">=</span><span class="s">copyq add %1</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf066</span>
<span class="na">Shortcut</span><span class="o">=</span><span class="s">Space</span>
</pre></div>
</div>
</div>
<div class="section" id="paste-current-date-and-time">
<h2>Paste Current Date and Time<a class="headerlink" href="#paste-current-date-and-time" title="Permalink to this headline">¶</a></h2>
<p>Copies current date/time text to clipboard and pastes to current window
on global shortcut Win+Alt+T.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var time = dateString('yyyy-MM-dd hh:mm:ss')</span>
<span class="s"> copy('Current date/time is ' + time)</span>
<span class="s"> paste()"</span>
<span class="na">GlobalShortcut</span><span class="o">=</span><span class="s">meta+alt+t</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf017</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Paste Current Time</span>
</pre></div>
</div>
</div>
<div class="section" id="play-sound-when-copying-to-clipboard">
<h2>Play Sound when Copying to Clipboard<a class="headerlink" href="#play-sound-when-copying-to-clipboard" title="Permalink to this headline">¶</a></h2>
<p>Following command will play an audio file whenever something is copied
clipboard.</p>
<p>On Windows:</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Play Sound on Copy</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> powershell:</span>
<span class="s"> (New-Object Media.SoundPlayer \"C:\\Users\\copy.wav\").PlaySync()"</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf028</span>
</pre></div>
</div>
<p>On Linux (requires VLC multimedia player):</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Play Sound on Copy</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> bash:</span>
<span class="s"> cvlc --play-and-exit ~/audio/example.mp3"</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf028</span>
</pre></div>
</div>
</div>
<div class="section" id="edit-and-paste">
<h2>Edit and Paste<a class="headerlink" href="#edit-and-paste" title="Permalink to this headline">¶</a></h2>
<p>Following command allows to edit current clipboard text before pasting
it. If the editing is canceled the text won’t be pasted.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var text = dialog('paste', str(clipboard()))</span>
<span class="s"> if (text) {</span>
<span class="s"> copy(text)</span>
<span class="s"> copySelection(text)</span>
<span class="s"> paste()</span>
<span class="s"> }"</span>
<span class="na">GlobalShortcut</span><span class="o">=</span><span class="s">ctrl+shift+v</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf0ea</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Edit and Paste</span>
</pre></div>
</div>
</div>
<div class="section" id="ignore-images-when-text-is-available">
<h2>Ignore Images when Text is Available<a class="headerlink" href="#ignore-images-when-text-is-available" title="Permalink to this headline">¶</a></h2>
<p>This is useful for ignoring cells copied as images from Microsoft Excel
and LibreOffice Calc.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var text = data('text/plain')</span>
<span class="s"> copy(text)</span>
<span class="s"> add(text)"</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf031</span>
<span class="na">Input</span><span class="o">=</span><span class="s">image/bmp</span>
<span class="na">MatchCommand</span><span class="o">=</span><span class="s">"copyq: if ( str(data('text/plain')) == '' ) fail()"</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Ignore Images when Text Copied</span>
<span class="na">Remove</span><span class="o">=</span><span class="s">true</span>
</pre></div>
</div>
</div>
<div class="section" id="remove-background-and-text-colors">
<h2>Remove Background and Text Colors<a class="headerlink" href="#remove-background-and-text-colors" title="Permalink to this headline">¶</a></h2>
<p>Removes background and text colors from rich text (e.g. text copied from
web pages).</p>
<p>Command can be both automatically applied on text copied to clipboard
and invoked from menu (or using custom shortcut).</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var html = str(input())</span>
<span class="s"> html = html.replace(/color\\s*:/g, 'xxx:')</span>
<span class="s"> setData('text/html', html)"</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf042</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
<span class="na">Input</span><span class="o">=</span><span class="s">text/html</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Remove Background and Text Colors</span>
</pre></div>
</div>
</div>
<div class="section" id="linkify">
<h2>Linkify<a class="headerlink" href="#linkify" title="Permalink to this headline">¶</a></h2>
<p>Creates interactive link from plain text.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Linkify</span>
<span class="na">Match</span><span class="o">=</span><span class="s">^(https?|ftps?|file|mailto)://</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var link = str(input());</span>
<span class="s"> var href = '<a href=\"###\">###</a>';</span>
<span class="s"> write(</span>
<span class="s"> 'text/plain', link,</span>
<span class="s"> 'text/html', href.replace(/###/g, link)</span>
<span class="s"> );"</span>
<span class="na">Input</span><span class="o">=</span><span class="s">text/plain</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Remove</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf127</span>
</pre></div>
</div>
</div>
<div class="section" id="highlight-text">
<h2>Highlight Text<a class="headerlink" href="#highlight-text" title="Permalink to this headline">¶</a></h2>
<p>Highlight all occurrences of a text (change <code class="docutils literal"><span class="pre">x</span> <span class="pre">=</span> <span class="pre">"text"</span></code> to match
something else than <code class="docutils literal"><span class="pre">text</span></code>).</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Highlight Text</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> x = 'text'</span>
<span class="s"> style = 'background: yellow; text-decoration: underline'</span>
<span class="na">text</span> <span class="o">=</span> <span class="s">str(input())</span>
<span class="s"> x = x.toLowerCase()</span>
<span class="s"> lowertext = text.toLowerCase()</span>
<span class="s"> html = ''</span>
<span class="s"> a = 0</span>
<span class="s"> esc = function(a, b) {</span>
<span class="s"> return escapeHTML( text.substr(a, b - a) )</span>
<span class="s"> }</span>
<span class="na">while (1) {</span>
<span class="na">b</span> <span class="o">=</span> <span class="s">lowertext.indexOf(x, a)</span>
<span class="s"> if (b != -1) {</span>
<span class="s"> html += esc(a, b) + '<span>' + esc(b, b + x.length) + '</span>'</span>
<span class="s"> } else {</span>
<span class="s"> html += esc(a, text.length)</span>
<span class="s"> break</span>
<span class="s"> }</span>
<span class="s"> a = b + x.length;</span>
<span class="s"> }</span>
<span class="na">tab( selectedtab() )</span>
<span class="na">write(</span>
<span class="na">index(),</span>
<span class="na">'text/plain', text,</span>
<span class="na">'text/html',</span>
<span class="na">'<html><head><style>span{'</span>
<span class="na">+ style +</span>
<span class="na">'}</style></head><body>'</span>
<span class="na">+ html +</span>
<span class="na">'</body></html>'</span>
<span class="na">)"</span>
<span class="na">Input</span><span class="o">=</span><span class="s">text/plain</span>
<span class="na">Wait</span><span class="o">=</span><span class="s">true</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
</pre></div>
</div>
</div>
<div class="section" id="render-html">
<h2>Render HTML<a class="headerlink" href="#render-html" title="Permalink to this headline">¶</a></h2>
<p>Render HTML code.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Render HTML</span>
<span class="na">Match</span><span class="o">=</span><span class="s">^\\s*<(!|html)</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> tab(selectedtab())</span>
<span class="s"> write(index() + 1, 'text/html', input())"</span>
<span class="na">Input</span><span class="o">=</span><span class="s">text/plain</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
</pre></div>
</div>
</div>
<div class="section" id="translate-to-english">
<h2>Translate to English<a class="headerlink" href="#translate-to-english" title="Permalink to this headline">¶</a></h2>
<p>Pass to text to <a class="reference external" href="https://translate.google.com/">Google Translate</a>.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Translate to English</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> text = str(input())</span>
<span class="s"> url = \"https://translate.google.com/#auto/en/???\"</span>
<span class="na">x</span> <span class="o">=</span> <span class="s">url.replace(\"???\", encodeURIComponent(text))</span>
<span class="s"> html = '<html><head><meta http-equiv=\"refresh\" content=\"0;url=' + x + '\" /></head></html>'</span>
<span class="na">tab(selectedtab())</span>
<span class="na">write(index() + 1, \"text/html\", html)"</span>
<span class="na">Input</span><span class="o">=</span><span class="s">text/plain</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
</pre></div>
</div>
</div>
<div class="section" id="paste-and-forget">
<h2>Paste and Forget<a class="headerlink" href="#paste-and-forget" title="Permalink to this headline">¶</a></h2>
<p>Paste selected items and clear clipboard.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Paste and Forget</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> tab(selectedtab())</span>
<span class="s"> items = selecteditems()</span>
<span class="s"> if (items.length > 1) {</span>
<span class="s"> text = ''</span>
<span class="s"> for (i in items)</span>
<span class="s"> text += read(items[i]);</span>
<span class="s"> copy(text)</span>
<span class="s"> } else {</span>
<span class="s"> select(items[0])</span>
<span class="s"> }</span>
<span class="na">hide()</span>
<span class="na">paste()</span>
<span class="na">copy('')"</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf0ea</span>
<span class="na">Shortcut</span><span class="o">=</span><span class="s">Ctrl+Return</span>
</pre></div>
</div>
</div>
<div class="section" id="render-math-equations">
<h2>Render Math Equations<a class="headerlink" href="#render-math-equations" title="Permalink to this headline">¶</a></h2>
<p>Render math equations using <a class="reference external" href="http://www.mathjax.org/">MathJax</a> (e.g.
<code class="docutils literal"><span class="pre">$$x</span> <span class="pre">=</span> <span class="pre">{-b</span> <span class="pre">\pm</span> <span class="pre">\sqrt{b^2-4ac}</span> <span class="pre">\over</span> <span class="pre">2a}$$</span></code>).</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Render Math Equations</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> text = str(input())</span>
<span class="s"> js = 'http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'</span>
<span class="na">html</span> <span class="o">=</span> <span class="s">'<html><head><script type=\"text/javascript\" src=\"' + js + '\"></script></head><body>' + escapeHTML(text) + '</body></html>';</span>
<span class="na">tab(selectedtab())</span>
<span class="na">write(index() + 1, 'text/html', html)"</span>
<span class="na">Input</span><span class="o">=</span><span class="s">text/plain</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf12b</span>
</pre></div>
</div>
</div>
<div class="section" id="move-images-to-other-tab">
<h2>Move Images to Other Tab<a class="headerlink" href="#move-images-to-other-tab" title="Permalink to this headline">¶</a></h2>
<p>With this command active, images won’t be saved in the first tab. This
can make application a bit more snappier since big image data won’t need
to be loaded when main window is displayed or clipboard is stored for
the first time.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Move Images to Other Tab</span>
<span class="na">Input</span><span class="o">=</span><span class="s">image/png</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Remove</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf03e</span>
<span class="na">Tab</span><span class="o">=</span><span class="s">&Images</span>
</pre></div>
</div>
</div>
<div class="section" id="copy-clipboard-to-window-tabs">
<h2>Copy Clipboard to Window Tabs<a class="headerlink" href="#copy-clipboard-to-window-tabs" title="Permalink to this headline">¶</a></h2>
<p>Following command automatically adds new clipboard to tab with same name
as title of the window where copy operation was performed.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Window Tabs</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"copyq:</span>
<span class="s"> item = unpack(input())</span>
<span class="s"> window_title = item[\"application/x-copyq-owner-window-title\"]</span>
<span class="s"> if (window_title) {</span>
<span class="s"> // Remove the part of window title before dash</span>
<span class="s"> // (it's usually document name or URL).</span>
<span class="s"> tabname = str(window_title).replace(/.* (-|\x2013) /, \"\")</span>
<span class="s"> tab(\"Windows/\" + tabname)</span>
<span class="s"> write(\"application/x-copyq-item\", input())</span>
<span class="s"> }</span>
<span class="s"> "</span>
<span class="na">Input</span><span class="o">=</span><span class="s">application/x-copyq-item</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf009</span>
</pre></div>
</div>
</div>
<div class="section" id="quickly-show-current-clipboard-content">
<h2>Quickly Show Current Clipboard Content<a class="headerlink" href="#quickly-show-current-clipboard-content" title="Permalink to this headline">¶</a></h2>
<p>Quickly pop up notification with text in clipboard using <code class="docutils literal"><span class="pre">Win+Alt+C</span></code>
system shortcut.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Show clipboard</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> seconds = 2;</span>
<span class="s"> popup(\"\", clipboard(), seconds * 1000)"</span>
<span class="na">GlobalShortcut</span><span class="o">=</span><span class="s">Meta+Alt+C</span>
</pre></div>
</div>
</div>
<div class="section" id="replace-all-occurrences-in-selected-text">
<h2>Replace All Occurrences in Selected Text<a class="headerlink" href="#replace-all-occurrences-in-selected-text" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Replace in Selection</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> // Copy without changing X11 selection (on Windows you can use "copy" instead).</span>
<span class="s"> function copy2() {</span>
<span class="s"> try {</span>
<span class="s"> var x = config('copy_clipboard')</span>
<span class="s"> config('copy_clipboard', false)</span>
<span class="s"> try {</span>
<span class="s"> copy.apply(this, arguments)</span>
<span class="s"> } finally {</span>
<span class="s"> config('copy_clipboard', x)</span>
<span class="s"> }</span>
<span class="s"> } catch(e) {</span>
<span class="s"> copy.apply(this, arguments)</span>
<span class="s"> }</span>
<span class="s"> }</span>
<span class="na">copy2()</span>
<span class="na">var text</span> <span class="o">=</span> <span class="s">str(clipboard())</span>
<span class="na">if (text) {</span>
<span class="na">var r1</span> <span class="o">=</span> <span class="s">'Text'</span>
<span class="s"> var r2 = 'Replace with'</span>
<span class="s"> var reply = dialog(r1, '', r2, '')</span>
<span class="na">if (reply) {</span>
<span class="na">copy2(text.replace(new RegExp(reply[r1], 'g'), reply[r2]))</span>
<span class="na">paste()</span>
<span class="na">}</span>
<span class="na">}"</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf040</span>
<span class="na">GlobalShortcut</span><span class="o">=</span><span class="s">Meta+Alt+R</span>
</pre></div>
</div>
</div>
<div class="section" id="copy-nth-item">
<h2>Copy Nth Item<a class="headerlink" href="#copy-nth-item" title="Permalink to this headline">¶</a></h2>
<p>Copy item in row depending on which shortcut was pressed. E.g. Ctrl+2
for item in row “2”.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Copy Nth Item</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var shortcut = str(data(\"application/x-copyq-shortcut\"))</span>
<span class="s"> var number = shortcut ? shortcut.replace(/^\\D+/g, '') : currentItem();</span>
<span class="s"> selectItems(number)</span>
<span class="s"> copy(\"application/x-copyq-item\", pack(getItem(number)))"</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf0cb</span>
<span class="na">Shortcut</span><span class="o">=</span><span class="s">ctrl+1, ctrl+2, ctrl+3, ctrl+4, ctrl+5, ctrl+6, ctrl+7, ctrl+8, ctrl+9, ctrl+0</span>
<span class="na">GlobalShortcut</span><span class="o">=</span><span class="s">meta+shift+w, meta+shift+e, meta+shift+q, DISABLED</span>
</pre></div>
</div>
</div>
<div class="section" id="edit-file">
<h2>Edit File<a class="headerlink" href="#edit-file" title="Permalink to this headline">¶</a></h2>
<p>Opens file referenced by selected item in external editor (uses
“External editor command” from “History” config tab).</p>
<p>Works with following path formats (some editors may not support all of
these).</p>
<ul class="simple">
<li><code class="docutils literal"><span class="pre">C:/...</span></code></li>
<li><code class="docutils literal"><span class="pre">file://...</span></code></li>
<li><code class="docutils literal"><span class="pre">~...</span></code> (some shells)</li>
<li><code class="docutils literal"><span class="pre">%...%...</span></code> (Windows environment variables)</li>
<li><code class="docutils literal"><span class="pre">$...</span></code> (environment variables)</li>
<li><code class="docutils literal"><span class="pre">/c/...</span></code> (gitbash)</li>
</ul>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Edit File</span>
<span class="na">Match</span><span class="o">=</span><span class="s">^([a-zA-Z]:[\\\\/]|~|file://|%\\w+%|$\\w+|/)</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var editor = config('editor')</span>
<span class="na">var fileName</span> <span class="o">=</span> <span class="s">str(input())</span>
<span class="s"> .replace(/^\\/([a-zA-Z])\\//, '$1:/')</span>
<span class="s"> .replace(/^file:\\/\\//, '')</span>
<span class="na">hide()</span>
<span class="na">execute(editor, fileName)"</span>
<span class="na">Input</span><span class="o">=</span><span class="s">text/plain</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf040</span>
<span class="na">Shortcut</span><span class="o">=</span><span class="s">f4</span>
</pre></div>
</div>
</div>
<div class="section" id="change-monitoring-state-permanently">
<h2>Change Monitoring State Permanently<a class="headerlink" href="#change-monitoring-state-permanently" title="Permalink to this headline">¶</a></h2>
<p>Disables clipboard monitoring permanently, i.e. the state is restored
when clipboard changes even after application is restarted.</p>
<p>Should be the first automatic command in the list of commands so other
commands are not invoked.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var option = 'disable_monitoring'</span>
<span class="s"> var disabled = str(settings(option)) === 'true'</span>
<span class="na">if (str(data('application/x-copyq-shortcut'))) {</span>
<span class="na">disabled</span> <span class="o">=</span> <span class="s">!disabled</span>
<span class="s"> settings(option, disabled)</span>
<span class="s"> popup('', disabled ? 'Monitoring disabled' : 'Monitoring enabled')</span>
<span class="s"> }</span>
<span class="na">if (disabled) {</span>
<span class="na">disable()</span>
<span class="na">ignore()</span>
<span class="na">} else {</span>
<span class="na">enable()</span>
<span class="na">}"</span>
<span class="na">GlobalShortcut</span><span class="o">=</span><span class="s">meta+alt+x</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf05e</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Toggle Monitoring</span>
</pre></div>
</div>
</div>
<div class="section" id="show-window-title">
<h2>Show Window Title<a class="headerlink" href="#show-window-title" title="Permalink to this headline">¶</a></h2>
<p>Shows source application window title for new items in tag (“Tags”
plugin must be enabled in “Items” config tab).</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var window = str(data('application/x-copyq-owner-window-title'))</span>
<span class="s"> var tagsMime = 'application/x-copyq-tags'</span>
<span class="s"> var tags = str(data(tagsMime)) + ', ' + window</span>
<span class="s"> setData(tagsMime, tags)"</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf009</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Store Window Title</span>
</pre></div>
</div>
</div>
<div class="section" id="show-copy-time">
<h2>Show Copy Time<a class="headerlink" href="#show-copy-time" title="Permalink to this headline">¶</a></h2>
<p>Shows copy time of new items in tag (“Tags” plugin must be enabled in
“Items” config tab).</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Automatic</span><span class="o">=</span><span class="s">true</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var time = dateString('yyyy-MM-dd hh:mm:ss')</span>
<span class="s"> setData('application/x-copyq-user-copy-time', time)</span>
<span class="na">var tagsMime</span> <span class="o">=</span> <span class="s">'application/x-copyq-tags'</span>
<span class="s"> var tags = str(data(tagsMime)) + ', ' + time</span>
<span class="s"> setData(tagsMime, tags)"</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf017</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Store Copy Time</span>
</pre></div>
</div>
</div>
<div class="section" id="mark-selected-items">
<h2>Mark Selected Items<a class="headerlink" href="#mark-selected-items" title="Permalink to this headline">¶</a></h2>
<p>Toggles highlighting of selected items.</p>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> var color = 'rgba(255, 255, 0, 0.5)'</span>
<span class="s"> var mime = 'application/x-copyq-color'</span>
<span class="na">var firstSelectedItem</span> <span class="o">=</span> <span class="s">selectedItems()[0]</span>
<span class="s"> var currentColor = str(read(mime, firstSelectedItem))</span>
<span class="s"> if (currentColor != color)</span>
<span class="s"> setData(mime, color)</span>
<span class="s"> else</span>
<span class="s"> removeData(mime)"</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf1fc</span>
<span class="na">InMenu</span><span class="o">=</span><span class="s">true</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Mark/Unmark Items</span>
<span class="na">Shortcut</span><span class="o">=</span><span class="s">ctrl+m</span>
</pre></div>
</div>
</div>
<div class="section" id="change-upper-lower-case-of-selected-text">
<h2>Change Upper/Lower Case of Selected Text<a class="headerlink" href="#change-upper-lower-case-of-selected-text" title="Permalink to this headline">¶</a></h2>
<div class="highlight-ini"><div class="highlight"><pre><span></span><span class="k">[Command]</span>
<span class="na">Command</span><span class="o">=</span><span class="s">"</span>
<span class="s"> copyq:</span>
<span class="s"> if (!copy())</span>
<span class="s"> abort()</span>
<span class="na">var text</span> <span class="o">=</span> <span class="s">str(clipboard())</span>
<span class="na">var newText</span> <span class="o">=</span> <span class="s">text.toUpperCase()</span>
<span class="s"> if (text == newText)</span>
<span class="s"> newText = text.toLowerCase()</span>
<span class="na">if (text</span> <span class="o">=</span><span class="s">= newText)</span>
<span class="s"> abort();</span>
<span class="na">copy(newText)</span>
<span class="na">paste()"</span>
<span class="na">GlobalShortcut</span><span class="o">=</span><span class="s">meta+ctrl+u</span>
<span class="na">Icon</span><span class="o">=</span><span class="s">\xf034</span>
<span class="na">Name</span><span class="o">=</span><span class="s">Toggle Upper/Lower Case</span>
</pre></div>
</div>
</div>
</div>
</div>
<div class="articleComments">
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="backup.html" class="btn btn-neutral float-right" title="Backup" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="scripting.html" class="btn btn-neutral" title="Scripting" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2018, Lukas Holecek.
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT:'./',
VERSION:'',
COLLAPSE_INDEX:false,
FILE_SUFFIX:'.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: '.txt'
};
</script>
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/js/theme.js"></script>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.StickyNav.enable();
});
</script>
</body>
</html>
|