<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mátyás Budavári</title>
    <description>The latest articles on DEV Community by Mátyás Budavári (@budavariam).</description>
    <link>https://dev.to/budavariam</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F194357%2F97aa9535-5c9e-447c-a2fd-212f9ac53914.jpeg</url>
      <title>DEV Community: Mátyás Budavári</title>
      <link>https://dev.to/budavariam</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/budavariam"/>
    <language>en</language>
    <item>
      <title>Supercharge your command line</title>
      <dc:creator>Mátyás Budavári</dc:creator>
      <pubDate>Thu, 18 Mar 2021 19:42:07 +0000</pubDate>
      <link>https://dev.to/budavariam/supercharge-your-command-line-2c9b</link>
      <guid>https://dev.to/budavariam/supercharge-your-command-line-2c9b</guid>
      <description>&lt;p&gt;The commmand line can be your best friend during development, if you take some time to get to know its capabilities.&lt;br&gt;
But even if you know what it can help you with, you can still extend it.&lt;br&gt;
I'd like to introduce you some of my favourite tools, &lt;code&gt;fzf&lt;/code&gt;, and &lt;code&gt;oh-my-zsh&lt;/code&gt;.&lt;br&gt;
By the end of this post I hope you'll see how well they can work together with you.&lt;/p&gt;

&lt;h2&gt;
  
  
  oh-my-zsh
&lt;/h2&gt;

&lt;p&gt;I've always enjoyed tweaking my command line configurations, but usually when I needed a functionality,&lt;br&gt;
I had to sit down and understand my code again to figure out where to put the new logic.&lt;/p&gt;

&lt;p&gt;Last year I've found &lt;a href="https://github.com/ohmyzsh/ohmyzsh" rel="noopener noreferrer"&gt;oh-my-zsh&lt;/a&gt;, and I felt relieved.&lt;br&gt;
It makes it easy to create an easily managable config, nice themes and it is easily pluginable.&lt;br&gt;
It has a nice community that creates and shares their work.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git" rel="noopener noreferrer"&gt;Install git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH" rel="noopener noreferrer"&gt;Install zsh&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/ohmyzsh/ohmyzsh#basic-installation" rel="noopener noreferrer"&gt;Install oh-my-zsh&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;My favourite feature in it, other than its simplicity, is that zsh makes tab completion navigatable,&lt;br&gt;
so you can use the arrow keys to select the appropriate value that you were searching for.&lt;/p&gt;

&lt;p&gt;An other great built-in command is &lt;code&gt;fc&lt;/code&gt;, that opens up my editor and lets me edit the previous command and run it after save.&lt;/p&gt;

&lt;p&gt;Zsh comes &lt;a href="https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins" rel="noopener noreferrer"&gt;embedded with plugins&lt;/a&gt; for commonly used commands like&lt;br&gt;
git, docker and kubernetes.&lt;br&gt;
It empowers them with aliases, command prompt information, also extends their tab completion by&lt;br&gt;
helping with available field names and lets you browse resources.&lt;/p&gt;

&lt;p&gt;New plugins can be installed usually with 2 lines of code, one of which is a &lt;code&gt;git clone&lt;/code&gt;,&lt;br&gt;
the other is editing the &lt;code&gt;plugins&lt;/code&gt; list in &lt;code&gt;.zshrc&lt;/code&gt;. Their configuration usually means to set some environmental variables.&lt;/p&gt;

&lt;h2&gt;
  
  
  fzf
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/junegunn/fzf" rel="noopener noreferrer"&gt;fzf&lt;/a&gt; is a general purpose command line fuzzy finder.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/junegunn/fzf#installation" rel="noopener noreferrer"&gt;Install guide&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It makes it easy to filter data by typing any part of the line.&lt;/p&gt;

&lt;p&gt;You can pipe data into it, or filter file content from your disk.&lt;/p&gt;

&lt;p&gt;I like the recommended settings, that way it stands out, from the other lines.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;FZF_DEFAULT_OPTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'--height 40% --layout=reverse --border'&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjdbbushcow0phxxzkek6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjdbbushcow0phxxzkek6.png" alt="Fzf in action"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Autocomplete
&lt;/h2&gt;

&lt;p&gt;Many shells come with command history navigation helper shortcut &lt;code&gt;ctrl+R&lt;/code&gt;,&lt;br&gt;
but in the past it usually confused me more than what it helped.&lt;/p&gt;

&lt;p&gt;I often just ended up using &lt;code&gt;history | less&lt;/code&gt; and search through lines with &lt;code&gt;/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Plugins for the rescue!&lt;/p&gt;

&lt;h3&gt;
  
  
  zsh-autosuggestions
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://github.com/zsh-users/zsh-autosuggestions" rel="noopener noreferrer"&gt;This plugin&lt;/a&gt; lets me see autosuggestions for my commands.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/zsh-users/zsh-autosuggestions/blob/master/INSTALL.md" rel="noopener noreferrer"&gt;Install guide&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It makes me feel super productive, when I often need to use the same set of commands in a project in order to run, build or test it.&lt;/p&gt;

&lt;p&gt;When I start to type the commands, I can accept the suggestion with a simple &lt;code&gt;right arrow&lt;/code&gt; click.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyb603r932brlidkgik3g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fyb603r932brlidkgik3g.png" alt="Fzf-autosuggestions in action"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If I need to search for a complex command there is a better way for that!&lt;/p&gt;

&lt;h3&gt;
  
  
  fzf in zsh
&lt;/h3&gt;

&lt;p&gt;Fzf can be &lt;a href="https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/fzf" rel="noopener noreferrer"&gt;integrated&lt;/a&gt; with &lt;code&gt;oh-my-zsh&lt;/code&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No further installation needed, only need to add &lt;code&gt;fzf&lt;/code&gt; to the plugin array in &lt;code&gt;.zshrc&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It is super convenient to fuzzy search for previous commands with &lt;code&gt;ctrl+R&lt;/code&gt;.&lt;br&gt;
It can find my previously typed command from just a few keystrokes.&lt;/p&gt;

&lt;p&gt;It is also useful to insert file name from the current subtree with &lt;code&gt;ctrl+T&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Enhance zsh tab completion with fzf
&lt;/h3&gt;

&lt;p&gt;As I mentioned above, zsh comes with navigatable tab completion, but unfortunately the fzf plugin do not attach in every case.&lt;br&gt;
Not so long ago I've found a great plugin, &lt;a href="https://github.com/Aloxaf/fzf-tab" rel="noopener noreferrer"&gt;fzf-tab&lt;/a&gt; that lets you use fzf in every situation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://github.com/Aloxaf/fzf-tab#install" rel="noopener noreferrer"&gt;Install guide&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You have the option to toggle it temporarily with &lt;code&gt;toggle-fzf-tab&lt;/code&gt;,&lt;br&gt;
because sometimes it might not be what you need, maybe there are too many options, or too slow in special cases.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wzrs233zab9j3q4huuv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4wzrs233zab9j3q4huuv.png" alt="Fzf-tab in action"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My zsh config
&lt;/h2&gt;

&lt;p&gt;For reference my zsh config is available &lt;a href="https://github.com/budavariam/dotfiles/blob/master/_mac/zsh/.zshrc" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;br&gt;
The interesting part is the plugins section.&lt;br&gt;
With only a few lines of code, the plugins come alive.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;

&lt;span class="c"&gt;# fzf configurations&lt;/span&gt;
&lt;span class="nb"&gt;export &lt;/span&gt;&lt;span class="nv"&gt;FZF_DEFAULT_OPTS&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'--height 40% --layout=reverse --border'&lt;/span&gt;
&lt;span class="c"&gt;# Uncomment the following line to disable fuzzy completion&lt;/span&gt;
&lt;span class="c"&gt;# export DISABLE_FZF_AUTO_COMPLETION="true"&lt;/span&gt;
&lt;span class="c"&gt;# Uncomment the following line to disable key bindings (CTRL-T, CTRL-R, ALT-C)&lt;/span&gt;
&lt;span class="c"&gt;# export DISABLE_FZF_KEY_BINDINGS="true"&lt;/span&gt;

&lt;span class="nv"&gt;plugins&lt;/span&gt;&lt;span class="o"&gt;=(&lt;/span&gt;
  fzf-tab &lt;span class="c"&gt;# to turn it on and off: toggle-fzf-tab&lt;/span&gt;
  zsh-autosuggestions
  fzf
&lt;span class="o"&gt;)&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;blockquote&gt;
&lt;p&gt;In case it may be changed this is how it looks like at the time of writing.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I've tried &lt;code&gt;zsh-syntax-highlighting&lt;/code&gt;, but is did not really like long commands, or pasted code, so I turnded it off.&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

&lt;p&gt;This post was originally posted on &lt;a href="https://budavariam.github.io/posts/2020/04/27/supercharge-your-command-line/" rel="noopener noreferrer"&gt;my blog&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>commandline</category>
      <category>zsh</category>
      <category>fzf</category>
    </item>
    <item>
      <title>Clipboard Goodies For Productivity</title>
      <dc:creator>Mátyás Budavári</dc:creator>
      <pubDate>Sun, 24 Jan 2021 20:58:18 +0000</pubDate>
      <link>https://dev.to/budavariam/clipboard-goodies-for-productivity-2ol1</link>
      <guid>https://dev.to/budavariam/clipboard-goodies-for-productivity-2ol1</guid>
      <description>&lt;p&gt;Have you ever typed ctrl-c instead of ctrl-v and had to recopy again?&lt;br&gt;
Have you ever needed to copy and paste multiple entries at once from a page causing you to switch back and forth?&lt;br&gt;
Have you ever needed to copy the output of a program running in the terminal?&lt;br&gt;
I did, and got fed up with them almost 5 years ago, I'll show you how you can eliminate these problems.&lt;/p&gt;
&lt;h2&gt;
  
  
  Clipboard History
&lt;/h2&gt;

&lt;p&gt;Most of my clipboard-related frustration came from the fact, that default clipboards in the operating systems store only one entry at a time. If I were to access the clipboard history, most of my problems were gone.&lt;br&gt;
Luckily there are apps for that.&lt;/p&gt;
&lt;h3&gt;
  
  
  OS Defaults
&lt;/h3&gt;

&lt;p&gt;The latest version of &lt;strong&gt;Windows 10&lt;/strong&gt; have a setting to make clipboard history available in the &lt;code&gt;System&lt;/code&gt; settings under &lt;code&gt;Clipboard history&lt;/code&gt;. It makes clipboard history available with &lt;code&gt;win+V&lt;/code&gt; key. Not too configurable, but perfectly usable.&lt;/p&gt;

&lt;p&gt;On &lt;strong&gt;Mac&lt;/strong&gt; you can use a secondary clipboard with &lt;code&gt;ctrl+k&lt;/code&gt; (copy) and &lt;code&gt;ctrl+y&lt;/code&gt; (paste), alongside &lt;code&gt;cmd+c&lt;/code&gt; (copy) and &lt;code&gt;cmd+v&lt;/code&gt; (paste). You can still only have 2 separate entries at once.&lt;/p&gt;
&lt;h3&gt;
  
  
  Ditto
&lt;/h3&gt;

&lt;p&gt;I started to use &lt;a href="https://ditto-cp.sourceforge.io/"&gt;Ditto&lt;/a&gt; to eliminate this problem.&lt;br&gt;
I loved that I could access my previous clips throughout the day.&lt;br&gt;
It had configurable shortcuts to access the last 10 entries separately.&lt;br&gt;
The only problem I had with it, that it &lt;strong&gt;only worked for windows&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  CopyQ
&lt;/h3&gt;

&lt;p&gt;When I started to use &lt;a href="https://ubuntu.com/"&gt;Ubuntu&lt;/a&gt; for my daily work I found &lt;a href="https://hluk.github.io/CopyQ/"&gt;CopyQ&lt;/a&gt;, a free open-source multiplatform clipboard manager. I use it daily ever since.&lt;/p&gt;

&lt;p&gt;I love that it has a configurable clipboard &lt;strong&gt;size&lt;/strong&gt;, I can &lt;strong&gt;search&lt;/strong&gt; through the entries, and it has a configurable shortcut to &lt;code&gt;Show main window under mouse cursor&lt;/code&gt; that can &lt;strong&gt;speed up work&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hRUU4AAG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cilmhkipmpjubf6y45z4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hRUU4AAG--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/cilmhkipmpjubf6y45z4.png" alt="Search through clipboard entries on mac" width="528" height="572"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In case I copy &lt;strong&gt;sensitive data&lt;/strong&gt;, I can turn off clipboard monitoring all at once with a configurable shortcut:&lt;br&gt;
&lt;code&gt;Toggle Clipboard Storing&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;My only problem with it is that it sometimes tends to &lt;strong&gt;quit unexpectedly on mac&lt;/strong&gt;. According to their &lt;a href="https://github.com/hluk/CopyQ/issues/1563"&gt;github issues&lt;/a&gt; they're working on it.&lt;/p&gt;
&lt;h2&gt;
  
  
  Clipboard in the command line
&lt;/h2&gt;

&lt;p&gt;In the command line you can take advantage of the operating system's pipeline. Imagine &lt;em&gt;copy&lt;/em&gt; as a utility that consumes text, and &lt;em&gt;paste&lt;/em&gt; as one that produce text, and when you use them the clipboard changes accordingly.&lt;/p&gt;

&lt;p&gt;Let's see what are the exact utilities that can be used for different systems.&lt;/p&gt;
&lt;h3&gt;
  
  
  Mac
&lt;/h3&gt;

&lt;p&gt;Mac has built-in utility commands to &lt;code&gt;pbcopy&lt;/code&gt; and &lt;code&gt;pbpaste&lt;/code&gt; to the clipboard.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# copy text to clipboard by piping to `pbcopy`&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Text to copy"&lt;/span&gt; | pbcopy

&lt;span class="c"&gt;# paste text from clipboard by piping from `pbpaste`&lt;/span&gt;
pbpaste | less
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Linux
&lt;/h3&gt;

&lt;p&gt;On Linux that use &lt;a href="https://en.wikipedia.org/wiki/X_window_manager"&gt;X window manager&lt;/a&gt; you can use &lt;a href="https://github.com/astrand/xclip"&gt;xclip&lt;/a&gt;.&lt;br&gt;
In case you switch between Mac and Linux often, you can use aliases to keep things consistent.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Install it with the available package manager.&lt;/span&gt;
&lt;span class="c"&gt;# Add to e.g: ~/.bash_profile to load on startup&lt;/span&gt;
&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;pbcopy&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'xclip -selection clipboard'&lt;/span&gt;
&lt;span class="nb"&gt;alias &lt;/span&gt;&lt;span class="nv"&gt;pbpaste&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s1"&gt;'xclip -selection clipboard -o'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;On linux servers that does not have window manager I did not yet see the point to investigate this further.&lt;/p&gt;

&lt;h3&gt;
  
  
  Windows
&lt;/h3&gt;

&lt;p&gt;Windows has builtin &lt;a href="https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/clip"&gt;clip.exe&lt;/a&gt;.&lt;br&gt;
Unfortunately, it can only copy TO the clipboard, can not read from it.&lt;/p&gt;

&lt;p&gt;If you need access to the clipboard you need to use &lt;a href="https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/get-clipboard?view=powershell-7.1"&gt;Get-Clipboard&lt;/a&gt; powershell module.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="c"&gt;REM copy to clipboard with clip.exe&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Text to copy"&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="nb"&gt;clip&lt;/span&gt;

&lt;span class="c"&gt;REM get data from clipboard&lt;/span&gt;
&lt;span class="kd"&gt;powershell&lt;/span&gt; &lt;span class="na"&gt;-command &lt;/span&gt;&lt;span class="s2"&gt;"Get-Clipboard"&lt;/span&gt;
&lt;span class="c"&gt;REM get data from clipboard into file&lt;/span&gt;
&lt;span class="kd"&gt;powershell&lt;/span&gt; &lt;span class="na"&gt;-command &lt;/span&gt;&lt;span class="s2"&gt;"Get-Clipboard"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="kd"&gt;file&lt;/span&gt;.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Cygwin
&lt;/h4&gt;

&lt;p&gt;If for some reason you still use &lt;a href="https://cygwin.com/cygwin-ug-net/using-specialnames.html"&gt;Cygwin&lt;/a&gt;,&lt;br&gt;
you're in luck!&lt;br&gt;
It makes Windows clipboard available as &lt;code&gt;/dev/clipboard&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# copy text to clipboard by redirecting to `/dev/clipboard`&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s2"&gt;"Text to copy"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /dev/clipboard
&lt;span class="c"&gt;# paste text from clipboard by reading from `/dev/clipboard`&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; /dev/clipboard
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Web Browsers
&lt;/h2&gt;

&lt;p&gt;In web browsers you can use the modern &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Clipboard_API"&gt;Clipboard API&lt;/a&gt; to interact with the clipboard. Previously you could use&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/execCommand"&gt;document.execCommand()&lt;/a&gt; but it's obsolete, that means it might still work, but it's discouraged.&lt;/p&gt;

&lt;p&gt;For browser support see &lt;a href="https://caniuse.com/?search=clipboard"&gt;clipboard at caniuse.com&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;For up to date and extensive examples see these pages sbove.&lt;/p&gt;
&lt;h3&gt;
  
  
  Chrome DevTools
&lt;/h3&gt;

&lt;p&gt;In Chrome developer Console you can use &lt;a href="https://developers.google.com/web/tools/chrome-devtools/console/utilities#copy"&gt;copy(object)&lt;/a&gt; builtin function to put an object to the clipboard.&lt;/p&gt;

&lt;p&gt;It can be handy during debugging. Combined with &lt;a href="https://developers.google.com/web/tools/chrome-devtools/console/utilities#dom"&gt;$0&lt;/a&gt; you can copy whole dom elements quickly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;$0&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;copy&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;myGlobalObject&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy coding!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.pexels.com/photo/coffee-notebook-writing-computer-34601/"&gt;Cover image credit&lt;/a&gt;&lt;br&gt;
Originally posted on my &lt;a href="https://budavariam.github.io/posts/2021/01/20/clipboard-goodies-for-productivity/"&gt;personal blog&lt;/a&gt;&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>tooling</category>
      <category>writing</category>
    </item>
  </channel>
</rss>
