terminal https://michaelwelford.com/ en More tmux scripting https://michaelwelford.com/post/more-tmux-scripting <span class="field field--name-title field--type-string field--label-hidden">More tmux scripting</span> <div class="field field--name-field-series-listing field--type-viewfield field--label-hidden"> <div class="field__item field__item-label-hidden"> <div class="views-element-container"><div class="view view-series-listing view-id-series_listing view-display-id-block_3 js-view-dom-id-f18fc1e418fcbc7f509b470a911216d6f2e9fc584f4d2b0e2695f47c8e85a70b"> <div class="view-header"> This is part of the series: <a href="/series/customising-tmux" hreflang="en">Customising Tmux</a> </div> <div class="view-content"> <div class="item-list"> <ol> <li><a href="/post/more-tmux-scripting" hreflang="en">More tmux scripting</a></li> <li><a href="/post/saving-time-preset-tmux-setup" hreflang="en">Saving time with a preset tmux setup</a></li> <li><a href="/post/lets-put-current-itunes-track-tmux-status-line" hreflang="en">Let&#039;s put the current iTunes track into the Tmux status line</a></li> </ol> </div> </div> </div> </div> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">admin</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sun, 15/09/2019 - 17:02</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Following on from <a href="/post/saving-time-preset-tmux-setup" rel="nofollow">Saving time with a preset tmux setup</a> I recently created a more <del>convoluted</del> indepth setup.</p> <h2>The Script</h2> <p><code>setup.sh</code>:</p> <pre><code class="language-bash">#!/bin/zsh # Note that this assumes base index of 1 CWD=$(pwd) SESSION_NAME=&quot;$1&quot; # detach from a tmux session if in one tmux detach &gt; /dev/null # Create a new session, -d means detached itself set -- $(stty size) # $1 = rows $2 = columns tmux new-session -d -s $SESSION_NAME -x &quot;$2&quot; -y &quot;$(($1 - 1))&quot; tmux new-window -t $SESSION_NAME:1 -n 'code' tmux new-window -t $SESSION_NAME:2 -n 'test' tmux new-window -t $SESSION_NAME:3 -n 'php' tmux new-window -t $SESSION_NAME:4 -n 'vim' tmux new-window -t $SESSION_NAME:5 -n 'falcon' tmux new-window -t $SESSION_NAME:5 -n 'task' ## Test Window tmux select-window -t $SESSION_NAME:2 tmux split-window -h -l70 tmux split-window -v -l50 tmux select-pane -t 1 tmux send-keys &quot;~pct&quot; C-m tmux send-keys &quot;v&quot; C-m tmux select-pane -t 2 tmux send-keys &quot;~pct&quot; C-m tmux send-keys &quot;/usr/local/bin/chromedriver --url-base=/wd/hub&quot; C-m tmux select-pane -t 3 tmux send-keys &quot;~pct&quot; C-m ## PHP Window tmux select-window -t $SESSION_NAME:3 tmux split-window -h -l70 tmux select-pane -t 1 tmux send-keys &quot;~pcp&quot; C-m tmux send-keys &quot;vl ep&quot; C-m tmux select-pane -t 2 tmux send-keys &quot;~pcp&quot; C-m tmux send-keys &quot;php -a&quot; C-m ## Vim Window tmux select-window -t $SESSION_NAME:4 tmux send-keys &quot;cd ~/.config&quot; C-m ## Falcon Window tmux select-window -t $SESSION_NAME:5 tmux split-window -h -p50 tmux select-pane -t 1 tmux send-keys &quot;~falcon&quot; C-m tmux select-pane -t 2 tmux send-keys &quot;~falcon&quot; C-m ## Taskwarrior tmux select-window -t $SESSION_NAME:6 tmux send-keys &quot;~/.config&quot; C-m tmux send-keys &quot;t&quot; C-m ## Main Window tmux select-window -t $SESSION_NAME:1 tmux rename-window 'code' tmux split-window -h -l70 tmux split-window -v -l50 tmux select-pane -t 2 tmux send-keys &quot;~pcp&quot; C-m tmux select-pane -t 3 tmux send-keys &quot;~pcp&quot; C-m tmux send-keys &quot;figlet -f roman Ready! | lolcat -t&quot; C-m tmux select-pane -t 1 tmux send-keys &quot;~pcp&quot; C-m tmux send-keys &quot;v&quot; C-m # Finally attach to it tmux attach -t $SESSION_NAME </code></pre> <p>Now this is mostly standard fare (covered in the linked post) but I think there are a few additions worth jumping into.</p> <h2>Directory hashes</h2> <p>Zsh has a wonderful feature called a directory hash which looks like the following:</p> <pre><code class="language-bash">hash -d dir=~/dir </code></pre> <p>This will then allow you to put <code>~dir</code> in the place of any shell command where a directory could be used and also you just type in <code>~dir</code> to cd into it.</p> <h2>Triggering a leader command on Vim startup</h2> <p>It’s quite usual to have a number of common config files editable via some Vim mappings. e.g. <code>&lt;leader&gt;ev</code> to edit the Vim config, <code>&lt;leader&gt;et</code> to edit the Tmux config etc. But what if you wanted to directly trigger such a mapping on Vim startup?</p> <p>One way to achieve this is with the following in your <code>.zshrc</code>:</p> <pre><code class="language-bash">run_vim_leader() { com=&quot;NormLead $1&quot; nvim -c &quot;$com&quot; } alias vl='run_vim_leader' </code></pre> <p>…paired with the following vimscript in my <code>.vimrc</code>:</p> <pre><code class="language-vim">function! ExecuteLeader(suffix) let l:leader = get(g:,&quot;mapleader&quot;,&quot;\\&quot;) if l:leader == ' ' let l:leader = '1' . l:leader endif execute &quot;normal &quot;.l:leader.a:suffix endfunction command! -nargs=1 NormLead call ExecuteLeader(&lt;f-args&gt;) nnoremap &lt;leader&gt;ev :edit $MYVIMRC&lt;cr&gt; </code></pre> <p>Now you can simply do <code>vl ev</code> to edit your <code>.vimrc</code> from your shell. At this point, you may be saying to yourself <em>ahem, I could just make an alias in <insert shell of choice></em> …but then how would you use that when you are in Vim itself? and what if you want to run <em>other</em> leader commands on startup? huh?! tenuous / contrived? I think not.</p> <h2>Starting up slime and a PHP REPL</h2> <p>Having a local REPL to try out random snippets is a great time saver. An easy enough way to do this with Vim is using the <a rel="nofollow noopener noreferrer" target="_blank" href="https://github.com/jpalardy/vim-slime">Slime</a> plugin. In my case I setup a Tmux split on the right running php in interactive mode (<code>php -a</code>) which I can send test code to from Vim with just a <c-c><c-c> (either from visual mode or of the current paragraph). To get Vim to startup ready to go I have the following in my <code>.vimrc</code>:</p> <pre><code class="language-vim">nnoremap &lt;leader&gt;ep :call StartSlime()&lt;cr&gt; function! StartSlime() execute 'bd' let g:startify_disable_at_vimenter=1 execute 'new' execute 'only' execute 'set ft=php' call append(0, &quot;&lt;?php&quot;) endfunction </code></pre> <p>Essentially this will:</p> <ul> <li>destroy the Startify buffer</li> <li>make a new buffer</li> <li>make it the only buffer</li> <li>set the filetype to php</li> <li>append <code>&lt;?php</code> to the top of the buffer</li> </ul> <p>I then start this up via the <code>run_vim_leader</code> bash function via <code>vl ep</code> (see above).</p> <h2>The complete PHP window</h2> <p>Just to bring that all together here is the complete PHP window part of the Tmux setup script:</p> <pre><code class="language-bash">tmux select-window -t $SESSION_NAME:3 tmux split-window -h -l70 tmux select-pane -t 1 tmux send-keys &quot;~pcp&quot; C-m tmux send-keys &quot;vl ep&quot; C-m tmux select-pane -t 2 tmux send-keys &quot;~pcp&quot; C-m tmux send-keys &quot;php -a&quot; C-m </code></pre> <p>…sweet!</p></div> <div class="field field--name-field-series field--type-entity-reference field--label-above"> <div class="field__label">// @Series</div> <div class="field__item"><a href="/series/customising-tmux" hreflang="en">Customising Tmux</a></div> </div> <div class="field field--name-field-category field--type-entity-reference field--label-above"> <div class="field__label">// @Category</div> <div class="field__items"> <div class="field__item"><a href="/category/code" hreflang="en">code</a></div> </div> </div> <div class="field field--name-field-blog-tags field--type-entity-reference field--label-above"> <div class="field__label">// @Tags</div> <div class="field__items"> <div class="field__item"><a href="/tag/vim" hreflang="en">vim</a></div> <div class="field__item"><a href="/tag/tmux" hreflang="en">tmux</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="en">terminal</a></div> <div class="field__item"><a href="/tag/bespoke" hreflang="en">bespoke</a></div> <div class="field__item"><a href="/tag/yakshaving" hreflang="en">yakshaving</a></div> <div class="field__item"><a href="/tag/bash" hreflang="en">bash</a></div> </div> </div> <div class="field field--name-field-size field--type-entity-reference field--label-above"> <div class="field__label">// @Size</div> <div class="field__item"><a href="/size/meal" hreflang="en">meal</a></div> </div> <div class="field field--name-published-at field--type-published-at field--label-above"> <div class="field__label">// @</div><div class="field__item">15/09/2019</div> </div> Sun, 15 Sep 2019 07:32:01 +0000 admin 36 at https://michaelwelford.com Saving time with a preset tmux setup https://michaelwelford.com/post/saving-time-preset-tmux-setup <span class="field field--name-title field--type-string field--label-hidden">Saving time with a preset tmux setup</span> <div class="field field--name-field-series-listing field--type-viewfield field--label-hidden"> <div class="field__item field__item-label-hidden"> <div class="views-element-container"><div class="view view-series-listing view-id-series_listing view-display-id-block_3 js-view-dom-id-f18fc1e418fcbc7f509b470a911216d6f2e9fc584f4d2b0e2695f47c8e85a70b"> <div class="view-header"> This is part of the series: <a href="/series/customising-tmux" hreflang="en">Customising Tmux</a> </div> <div class="view-content"> <div class="item-list"> <ol> <li><a href="/post/more-tmux-scripting" hreflang="en">More tmux scripting</a></li> <li><a href="/post/saving-time-preset-tmux-setup" hreflang="en">Saving time with a preset tmux setup</a></li> <li><a href="/post/lets-put-current-itunes-track-tmux-status-line" hreflang="en">Let&#039;s put the current iTunes track into the Tmux status line</a></li> </ol> </div> </div> </div> </div> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">admin</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sun, 16/09/2018 - 14:32</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Programming is all about doing the same thing… <em>over and over again, ad nauseam</em>. No, not the computer, the poor programmer as they work on similar projects bouncing around all the different tools.</p> <p>For example, let’s take Drupal development - usually once you are in the midst of it, you may be accessing:</p> <ul> <li>An editor (Vim, <em>naturally</em>)</li> <li>A terminal for running system commands e.g. <code>drush cr</code>, <code>drush cedit</code>, <code>drupal generate:module</code> etc.</li> <li>Maybe a todo list / notes</li> <li>Log output</li> <li>Watch output e.g. <code>npm run watch</code> </li> <li>Test output e.g. <code>phpunit</code>, <code>codeception</code> etc.</li> <li>File ops e.g. <code>ranger</code> </li> <li>Reference material</li> <li>etc.</li> </ul> <p>That may end up looking a bit like this:</p> <img src="/sites/default/files/styles/max_1300x1300/public/2018-09/Screen%20Shot%202018-09-16%20at%202.42.34%20pm.png" width="1300" height="814" alt="Drupal development screenshot" class="image-max_1300x1300" data-insert-type="image" data-entity-type="file" data-entity-uuid="insert-max_1300x1300-312a4c52-4a6e-424d-b3e4-658cdbb073b1" /> <p><strong>Note</strong> the Tmux status, bottom left, where it shows that I am in the first window of three.</p> <p>As this is typical, wouldn’t it be nice if, I don’t know, you could run a command such as <code>tmd &lt;name of session&gt;</code> and it would set everything up <em>just so</em>. Also, over time, we could then refine this setup and get all the benefits of finessing it - or have multiple scripts depending on the type of project.</p> <h2>The script</h2> <p>No problem, take a look at this script <code>drupal.sh</code>:</p> <pre><code class="language-bash">#!/bin/zsh # Note that this assumes base index of 1 # check for existence of required things # $1 is the name of the window # we are in the directory of the drupal project if [ $# -eq 0 ] then echo &quot;No arguments supplied, requires name of window.&quot; exit 1 fi CWD=$(pwd) SESSION_NAME=&quot;$1&quot; # detach from a tmux session if in one tmux detach &gt; /dev/null # Create a new session, -d means detached itself set -- $(stty size) # $1 = rows $2 = columns tmux new-session -d -s $SESSION_NAME -x &quot;$2&quot; -y &quot;$(($1 - 1))&quot; tmux new-window -t $SESSION_NAME:1 -n 'code' tmux new-window -t $SESSION_NAME:2 -n 'logs' tmux new-window -t $SESSION_NAME:3 -n 'zsh' ## Logs window tmux select-window -t $SESSION_NAME:2 # Start up the logs listener tmux send-keys &quot;vbin/tail -f /var/log/apache2/error.log | clog drupal&quot; C-m ## Zsh window tmux select-window -t $SESSION_NAME:3 tmux rename-window 'Zsh' ## Main Window tmux select-window -t $SESSION_NAME:1 tmux rename-window 'code' # Split into left and right tmux split-window -h -p30 # Right ready for taking commands / tests. tmux select-pane -t 2 tmux send-keys &quot;figlet -f roman Ready! | lolcat -t&quot; C-m # Left for neovim. tmux select-pane -t 1 tmux send-keys &quot;v&quot; C-m # Finally attach to it tmux attach -t $SESSION_NAME </code></pre> <h2>How it works</h2> <p>The process can be broken down as follows:</p> <ul> <li>Creating a new session</li> <li>Creating windows</li> <li>Creating panes</li> <li>Sending commands to the panes / windows</li> </ul> <h3>Creating a new session</h3> <p>Creating a new session is as simple as <code>tmux new-session -s &lt;name-of-session&gt;</code>. In the example script I have a bit more going on:</p> <pre><code class="language-bash"># Create a new session, -d means detached itself set -- $(stty size) # $1 = rows $2 = columns tmux new-session -d -s $SESSION_NAME -x &quot;$2&quot; -y &quot;$(($1 - 1))&quot; </code></pre> <p>What I am doing here is getting the current screen resolution and then creating a detached session of that size - the reason being that if you don’t specify a size using the <code>-x</code> parameter then if you try to specify window split sizes it will <em>wig out</em> since it has no point of reference for “size”.</p> <h3>Creating windows</h3> <p>Creating a window can be accomplished via <code>tmux new-window -n &lt;name-of-window&gt;</code>. In the example we have:</p> <pre><code class="language-bash">tmux new-window -t $SESSION_NAME:1 -n 'code' tmux new-window -t $SESSION_NAME:2 -n 'logs' tmux new-window -t $SESSION_NAME:3 -n 'zsh' </code></pre> <p>Here we create three windows - the <code>-t</code> flag is so that we can specify the target of the windows, which in this case is the session that we just created and the index of where they should appear.</p> <p>We can then target windows with <code>tmux select-window -t &lt;name-of-session&gt;:&lt;index&gt;</code> for further commands.</p> <h3>Creating panes</h3> <p>Often you will want to split up a window into multiple panes. This can be done with something like <code>tmux split-window -h -p&lt;percentage&gt;</code> where <code>-h</code> signifies a horizontal split (guess how a vertical split is specified?) and <code>-p</code> signifies a percentage split. In the example I create a 30 percent split but you can of course specify by pixel if that is your jam.</p> <p>Once you have created one or more splits, you can target panes with <code>tmux select-pane -t &lt;index-of-pane&gt;</code> for more commands.</p> <h3>Sending commands to the panes / windows</h3> <p>Lastly, once we have our windows and panes ready, we can send them further commands to start things up. Some examples from the above:</p> <ul> <li> <code>tmux send-keys &quot;vbin/tail -f /var/log/apache2/error.log | clog drupal&quot; C-m</code> </li> </ul> <p>(run the <code>tail</code> command in watch mode against the apache error log, piped into <a rel="nofollow noopener noreferrer" target="_blank" href="https://taskwarrior.org/docs/clog/what.html">clog</a> - the <code>C-m</code> is used to send an <code>&lt;Enter&gt;</code> to a pane or window)</p> <ul> <li> <code>tmux send-keys &quot;figlet -f roman Ready! | lolcat -t&quot; C-m</code> </li> </ul> <p>(run <code>figlet</code> with the string “Ready!”, piped into lolcat in true colour mode )</p> <h2>Finishing up</h2> <p>Rounding out the script we have a call to <code>tmux attach -t &lt;name-of-session&gt;</code> which makes it visible. In the script, the name of the session is passed in as a parameter. For extra convenience I have the following alias in my <code>.zshrc</code> to run this script:</p> <pre><code class="language-bash">alias tmd='~/.config/tmux/drupal.sh' </code></pre> <p>Obviously you <em>don’t</em> have to attach to a Tmux session - if you had the need, your script could start up all kinds of processes and then you could attach only to check it whilst doing other things (or not!). Tmux also supports multiple people attaching to a session, sending commands to specific sessions, saving sessions (via plugins) etc. The possibilities <em>runneth over</em>.</p></div> <div class="field field--name-field-series field--type-entity-reference field--label-above"> <div class="field__label">// @Series</div> <div class="field__item"><a href="/series/customising-tmux" hreflang="en">Customising Tmux</a></div> </div> <div class="field field--name-field-category field--type-entity-reference field--label-above"> <div class="field__label">// @Category</div> <div class="field__items"> <div class="field__item"><a href="/category/code" hreflang="en">code</a></div> </div> </div> <div class="field field--name-field-blog-tags field--type-entity-reference field--label-above"> <div class="field__label">// @Tags</div> <div class="field__items"> <div class="field__item"><a href="/tag/tmux" hreflang="en">tmux</a></div> <div class="field__item"><a href="/tag/vim" hreflang="en">vim</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="en">terminal</a></div> <div class="field__item"><a href="/tag/bespoke" hreflang="en">bespoke</a></div> <div class="field__item"><a href="/tag/drupal" hreflang="en">Drupal</a></div> </div> </div> <div class="field field--name-field-size field--type-entity-reference field--label-above"> <div class="field__label">// @Size</div> <div class="field__item"><a href="/size/meal" hreflang="en">meal</a></div> </div> <div class="field field--name-published-at field--type-published-at field--label-above"> <div class="field__label">// @</div><div class="field__item">16/09/2018</div> </div> Sun, 16 Sep 2018 05:02:32 +0000 admin 29 at https://michaelwelford.com Let's put the current iTunes track into the Tmux status line https://michaelwelford.com/post/lets-put-current-itunes-track-tmux-status-line <span class="field field--name-title field--type-string field--label-hidden">Let&#039;s put the current iTunes track into the Tmux status line</span> <div class="field field--name-field-series-listing field--type-viewfield field--label-hidden"> <div class="field__item field__item-label-hidden"> <div class="views-element-container"><div class="view view-series-listing view-id-series_listing view-display-id-block_3 js-view-dom-id-f18fc1e418fcbc7f509b470a911216d6f2e9fc584f4d2b0e2695f47c8e85a70b"> <div class="view-header"> This is part of the series: <a href="/series/customising-tmux" hreflang="en">Customising Tmux</a> </div> <div class="view-content"> <div class="item-list"> <ol> <li><a href="/post/more-tmux-scripting" hreflang="en">More tmux scripting</a></li> <li><a href="/post/saving-time-preset-tmux-setup" hreflang="en">Saving time with a preset tmux setup</a></li> <li><a href="/post/lets-put-current-itunes-track-tmux-status-line" hreflang="en">Let&#039;s put the current iTunes track into the Tmux status line</a></li> </ol> </div> </div> </div> </div> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">admin</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sat, 08/09/2018 - 14:59</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>When you go <em>full terminal</em> it can be nice to know what music is playing for when it really sucks/rocks. Wouldn’t it be nice to get something like this into your Tmux status bar:</p> <img src="/sites/default/files/2018-09/Screen%20Shot%202018-09-08%20at%207.37.57%20pm.png" width="521" height="45" alt="tmux itunes example" data-insert-type="image" data-entity-type="file" data-entity-uuid="ee9b5852-4c75-42f8-bc3e-aca1cc92aa5b" /> <p>(the answer is <em>yes</em>)</p> <h2>Let’s do this</h2> <p>First you need to get the following into a script file, let’s say we put this into <code>~/.config/itunes_status.sh</code>.</p> <pre><code class="language-bash">#!/usr/bin/env bash ITUNES_TRACK=$(osascript &lt;&lt;EOF if appIsRunning(&quot;iTunes&quot;) then tell app &quot;iTunes&quot; to get the name of the current track end if on appIsRunning(appName) tell app &quot;System Events&quot; to (name of processes) contains appName end appIsRunning EOF) if [[ ! -z &quot;$ITUNES_TRACK&quot; ]]; then ITUNES_ARTIST=$(osascript &lt;&lt;EOF if appIsRunning(&quot;iTunes&quot;) then tell app &quot;iTunes&quot; to get the artist of the current track end if on appIsRunning(appName) tell app &quot;System Events&quot; to (name of processes) contains appName end appIsRunning EOF) TRACK_LEN=${#ITUNES_TRACK} if [[ &quot;$TRACK_LEN&quot; -gt 30 ]]; then ITUNES_TRACK=`echo &quot;$ITUNES_TRACK&quot; | cut -c -30` ITUNES_TRACK+=... fi ARTIST_LEN=${#ITUNES_ARTIST} if [[ &quot;$ARTIST_LEN&quot; -gt 20 ]]; then ITUNES_ARTIST=`echo &quot;$ITUNES_ARTIST&quot; | cut -c -20` ITUNES_ARTIST+=... fi echo '#[fg=#99a4bc]♫#[fg=#b4b4b9]' &quot;$ITUNES_TRACK&quot; '#[fg=#787882]-#[fg=#b4b4b9]' &quot;$ITUNES_ARTIST&quot; exit else echo &quot;#[fg=#787882]No music playing&quot; fi </code></pre> <p>Essentially this does the following:</p> <ul> <li>Check if iTunes is running, and if so grab the name of the track</li> <li>If we have a track name, also grab the artist</li> <li>If the track name is over 30 characters in length, truncate and insert an ellipsis</li> <li>If the artist name is over 20 characters in length, do the same</li> <li>Output this with some colours and space it out</li> <li>Otherwise write “No music playing”</li> </ul> <h2>Insert into the Tmux status bar</h2> <p>Ok, so that’s nice an’ all but we need to get that into the Tmux status. That can be accomplished by inserting something like the following into your <code>.tmux.conf</code>:</p> <pre><code class="language-bash">set -g status-right &quot;#(~/.config/itunes_status.sh) #[fg=#57575e]│ #[fg=white]%d/%m/%Y %H:%M &quot; </code></pre> <p><strong>Note</strong> as a “bonus” I have also put in the time after the iTunes track (yes, yes, such a generous bonus). If you are wondering what those colour hex values are, they come from the <a rel="nofollow noopener noreferrer" target="_blank" href="https://github.com/fenetikm/falcon">falcon</a> theme (made by moi). Don’t forget that you will need to make this script executable too.</p></div> <div class="field field--name-field-series field--type-entity-reference field--label-above"> <div class="field__label">// @Series</div> <div class="field__item"><a href="/series/customising-tmux" hreflang="en">Customising Tmux</a></div> </div> <div class="field field--name-field-category field--type-entity-reference field--label-above"> <div class="field__label">// @Category</div> <div class="field__items"> <div class="field__item"><a href="/category/code" hreflang="en">code</a></div> </div> </div> <div class="field field--name-field-blog-tags field--type-entity-reference field--label-above"> <div class="field__label">// @Tags</div> <div class="field__items"> <div class="field__item"><a href="/tag/tmux" hreflang="en">tmux</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="en">terminal</a></div> <div class="field__item"><a href="/tag/applescript" hreflang="en">applescript</a></div> <div class="field__item"><a href="/tag/bash" hreflang="en">bash</a></div> </div> </div> <div class="field field--name-field-size field--type-entity-reference field--label-above"> <div class="field__label">// @Size</div> <div class="field__item"><a href="/size/snack" hreflang="en">snack</a></div> </div> <div class="field field--name-published-at field--type-published-at field--label-above"> <div class="field__label">// @</div><div class="field__item">08/09/2018</div> </div> Sat, 08 Sep 2018 05:29:20 +0000 admin 28 at https://michaelwelford.com Making your own colour scheme: Introduction https://michaelwelford.com/post/making-your-own-colour-scheme-introduction <span class="field field--name-title field--type-string field--label-hidden">Making your own colour scheme: Introduction</span> <div class="field field--name-field-series-listing field--type-viewfield field--label-hidden"> <div class="field__item field__item-label-hidden"> <div class="views-element-container"><div class="view view-series-listing view-id-series_listing view-display-id-block_3 js-view-dom-id-a160f4cefe801631fcb785387e5b77756b30a32ea8f3e3537bd26ac42f4ef21c"> <div class="view-header"> This is part of the series: <a href="/series/making-your-own-colour-scheme" hreflang="en">Making your own colour scheme</a> </div> <div class="view-content"> <div class="item-list"> <ol> <li><a href="/post/making-your-own-colour-scheme-introduction" hreflang="en">Making your own colour scheme: Introduction</a></li> </ol> </div> </div> </div> </div> </div> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">admin</span></span> <span class="field field--name-created field--type-created field--label-hidden">Mon, 13/08/2018 - 06:36</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>There’s nothing quite like a tailored suit - so comfortable, so thoughtful, so knowing, so… <em>you</em>. Don’t like the cuffs? Change them. Not sitting correctly over the shoes? Have them re-hemmed. Not enough velvet? No problemo.</p> <p>Or so I imagine if I could afford one.</p> <p>But what <em>I can</em> afford is my own colour scheme.</p> <p>I have been making changes to <a rel="nofollow noopener noreferrer" target="_blank" href="https://github.com/fenetikm/falcon">falcon</a> over the last few months or so and I am about to make another major release as this time I think I have got it right.</p> <p>Unlike a suit, a colour scheme has to be a work horse and not a show pony. Like good design and timeless classics like Helvetica or the LBD it has to be something that <em>works</em>. Something that is gimmicky and garish like a fascinator will annoy and grate over time. Sure, wear it to the races but not to work every day.</p> <p>And so I think I am finally at the point, on the second time around, where everything is balanced and working well. I mean, just look at it:</p> <p><img src="/sites/default/files/falcon_01-fs8.png" alt="Falcon screenshot" /></p> <p>I like it so much that I have created settings for most things that I use - Vim, the terminal, ranger etc. and hey, even this Drupal theme.</p> <p>So how does one get started making a colour scheme? Well, earnest and imagined reader, you are in luck! This is going to be the first in a series of constructing your own colour scheme. I will go through getting started to tweaking everything possible for <em>all the things</em>.</p> <p>Stay tuned.</p></div> <div class="field field--name-field-category field--type-entity-reference field--label-above"> <div class="field__label">// @Category</div> <div class="field__items"> <div class="field__item"><a href="/category/code" hreflang="en">code</a></div> <div class="field__item"><a href="/category/ideas" hreflang="en">ideas</a></div> </div> </div> <div class="field field--name-field-blog-tags field--type-entity-reference field--label-above"> <div class="field__label">// @Tags</div> <div class="field__items"> <div class="field__item"><a href="/tag/vim" hreflang="en">vim</a></div> <div class="field__item"><a href="/tag/bespoke" hreflang="en">bespoke</a></div> <div class="field__item"><a href="/tag/syntax" hreflang="en">syntax</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="en">terminal</a></div> <div class="field__item"><a href="/tag/tmux" hreflang="en">tmux</a></div> <div class="field__item"><a href="/tag/design" hreflang="en">design</a></div> <div class="field__item"><a href="/tag/falcon" hreflang="en">falcon</a></div> </div> </div> <div class="field field--name-field-size field--type-entity-reference field--label-above"> <div class="field__label">// @Size</div> <div class="field__item"><a href="/size/snack" hreflang="en">snack</a></div> </div> <div class="field field--name-published-at field--type-published-at field--label-above"> <div class="field__label">// @</div><div class="field__item">13/08/2018</div> </div> Sun, 12 Aug 2018 21:06:33 +0000 admin 22 at https://michaelwelford.com Staying active or "Where the heck am I typing?!" https://michaelwelford.com/post/staying-active-or-where-heck-am-i-typing <span class="field field--name-title field--type-string field--label-hidden">Staying active or &quot;Where the heck am I typing?!&quot;</span> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/user/1" typeof="schema:Person" property="schema:name" datatype="">admin</span></span> <span class="field field--name-created field--type-created field--label-hidden">Mon, 23/07/2018 - 06:58</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Recently, someone posted a question on the issue queue for the <a rel="nofollow noopener noreferrer" target="_blank" href="https://github.com/fenetikm/falcon">colour scheme</a> that I have been developing. Specifically they wondered why I was only setting the background colour in NeoVim when it was running in the GUI version. <em>Why indeed?</em></p> <p>One of the downsides to the immense power of running <a rel="nofollow noopener noreferrer" target="_blank" href="https://github.com/neovim/neovim">NeoVim</a> <em>inside</em> of <a rel="nofollow noopener noreferrer" target="_blank" href="https://github.com/tmux/tmux">Tmux</a> <em>inside</em> of <a rel="nofollow noopener noreferrer" target="_blank" href="https://github.com/kovidgoyal/kitty">kitty</a>, especially on a relatively large screen, is that one tends to end up with quite a few splits and windows and at a glance one can often ask, “Where the heck am I typing?!”</p> <p>Thankfully, both Tmux and NeoVim have the concept of <em>active</em> vs <em>inactive</em> windows which ends up looking like the following in NeoVim:</p> <pre><code class="language-vim">if exists('+winhighlight') hi ActiveWindow guibg=NONE | hi InactiveWindow guibg=#13131c set winhighlight=Normal:ActiveWindow,NormalNC:InactiveWindow endif </code></pre> <p>(here we are only setting the background when the window is considered <em>inactive</em> in NeoVim, when it is <em>active</em> it will fall through to Tmux)</p> <p>…and in the Tmux configuration it looks like this:</p> <pre><code class="language-bash">set -g window-style &quot;bg=#13131c&quot; set -g window-active-style &quot;bg=#04041a&quot; </code></pre> <p>(note that Tmux doesn’t call something explicitly <em>active</em> but more like it has the absence of “active”-ness!)</p> <p>Of course, all these RGB hex values won’t work correctly unless you have true colour working in all three which can be troublesome especially if you <em>also</em> want italics, bold and cursor shapes working! (I will keep that for another post)</p> <p>Bon Appétit!</p></div> <div class="field field--name-field-category field--type-entity-reference field--label-above"> <div class="field__label">// @Category</div> <div class="field__items"> <div class="field__item"><a href="/category/code" hreflang="en">code</a></div> </div> </div> <div class="field field--name-field-blog-tags field--type-entity-reference field--label-above"> <div class="field__label">// @Tags</div> <div class="field__items"> <div class="field__item"><a href="/tag/vim" hreflang="en">vim</a></div> <div class="field__item"><a href="/tag/tmux" hreflang="en">tmux</a></div> <div class="field__item"><a href="/tag/terminal" hreflang="en">terminal</a></div> <div class="field__item"><a href="/tag/yakshaving" hreflang="en">yakshaving</a></div> </div> </div> <div class="field field--name-field-size field--type-entity-reference field--label-above"> <div class="field__label">// @Size</div> <div class="field__item"><a href="/size/snack" hreflang="en">snack</a></div> </div> <div class="field field--name-published-at field--type-published-at field--label-above"> <div class="field__label">// @</div><div class="field__item">23/07/2018</div> </div> Sun, 22 Jul 2018 21:28:41 +0000 admin 19 at https://michaelwelford.com