{"id":5798,"date":"2020-06-21T10:14:13","date_gmt":"2020-06-21T10:14:13","guid":{"rendered":"https:\/\/really.zonky.org\/?p=5798"},"modified":"2020-06-21T10:14:15","modified_gmt":"2020-06-21T10:14:15","slug":"zsh-devouring-tools-or-hiding-the-terminal","status":"publish","type":"post","link":"https:\/\/really.zonky.org\/?p=5798","title":{"rendered":"Zsh: Devouring Tools or Hiding the Terminal"},"content":{"rendered":"\n<p>There has been a bit of a rush on Youtube videos describing how to hide the terminal when running certain commands; when using the terminal as a file browser you may want to show a media file. And sometimes when showing that file, you may wish to hide the terminal &#8211; particularly on a small laptop screen.<\/p>\n\n\n\n<p>Just for fun, I decided to take one of the recipes and adapt it for my working environment which revolves around the <a href=\"https:\/\/zsh.org\" class=\"aioseop-link\">zsh<\/a> when I am in a terminal window. <\/p>\n\n\n\n<p>To start with, I need the <em>xdo<\/em> tool, which can be installed with :-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt install xdo<\/code><\/pre>\n\n\n\n<p>Once that is installed, I modified a shell script from <a href=\"https:\/\/github.com\/salman-abedin\/devour\/blob\/master\/\" class=\"aioseop-link\">https:\/\/github.com\/salman-abedin\/devour\/blob\/master\/<\/a> into a zsh function. I created a function file within my <em>FPATH<\/em> (<em>~\/lib\/zsh\/functions\/devour<\/em>) :-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>function devour {\n  id=$(xdo id)\n  xdo hide\n  . $@\n  xdo show \"$id\"\n}<\/code><\/pre>\n\n\n\n<p>Note that I have deliberately not redirected <em>stdout<\/em> and <em>stderr<\/em> away.<\/p>\n\n\n\n<p>I then added the following to my <em>.zshrc<\/em> :-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>autoload devour<\/code><\/pre>\n\n\n\n<p>The next step is to create aliases for the commands you might want to run automatically in such a way :-<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>alias mpv=\"devour mpv\"<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" width=\"695\" height=\"463\" src=\"https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?resize=695%2C463&#038;ssl=1\" alt=\"\" class=\"wp-image-3904\" srcset=\"https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?w=792&amp;ssl=1 792w, https:\/\/i0.wp.com\/really.zonky.org\/wp-content\/uploads\/damascus-unix-prompt1.png?resize=300%2C200&amp;ssl=1 300w\" sizes=\"auto, (max-width: 695px) 100vw, 695px\" \/><\/figure>\n\n\n\n<p>Although I am not sure &#8220;devour&#8221; is the right word to use for this action, but I have yet to think of a better one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There has been a bit of a rush on Youtube videos describing how to hide the terminal when running certain commands; when using the terminal as a file browser you may want to show a media file. And sometimes when showing that file, you may wish to hide the terminal &#8211; particularly on a small <a href='https:\/\/really.zonky.org\/?p=5798' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false,"_share_on_mastodon":"0"},"categories":[4,209],"tags":[1942,1943,1212],"class_list":["post-5798","post","type-post","status-publish","format-standard","hentry","category-it","category-linux-it","tag-devour","tag-hiding-the-terminal","tag-zsh","category-4-id","category-209-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"share_on_mastodon":{"url":"","error":""},"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1f2KI-1vw","_links":{"self":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5798","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5798"}],"version-history":[{"count":1,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5798\/revisions"}],"predecessor-version":[{"id":5799,"href":"https:\/\/really.zonky.org\/index.php?rest_route=\/wp\/v2\/posts\/5798\/revisions\/5799"}],"wp:attachment":[{"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5798"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5798"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/really.zonky.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5798"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}