<?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: Zach Whaley</title>
    <description>The latest articles on DEV Community by Zach Whaley (@zachwhaley).</description>
    <link>https://dev.to/zachwhaley</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%2F6886%2F2996465.jpeg</url>
      <title>DEV Community: Zach Whaley</title>
      <link>https://dev.to/zachwhaley</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/zachwhaley"/>
    <language>en</language>
    <item>
      <title>Solarized + tmux + ls + bold text</title>
      <dc:creator>Zach Whaley</dc:creator>
      <pubDate>Fri, 24 Feb 2017 02:16:21 +0000</pubDate>
      <link>https://dev.to/zachwhaley/solarized--tmux--ls--bold-text</link>
      <guid>https://dev.to/zachwhaley/solarized--tmux--ls--bold-text</guid>
      <description>&lt;p&gt;How I got &lt;i&gt;&lt;span&gt;S&lt;/span&gt;&lt;span&gt;o&lt;/span&gt;&lt;span&gt;l&lt;/span&gt;&lt;span&gt;a&lt;/span&gt;&lt;span&gt;r&lt;/span&gt;&lt;span&gt;i&lt;/span&gt;&lt;span&gt;z&lt;/span&gt;&lt;span&gt;e&lt;/span&gt;&lt;span&gt;d&lt;/span&gt;&lt;/i&gt;, &lt;code&gt;tmux&lt;/code&gt;, &lt;code&gt;ls&lt;/code&gt;, and &lt;strong&gt;bold text&lt;/strong&gt; to work together.&lt;/p&gt;

&lt;p&gt;Running &lt;code&gt;ls&lt;/code&gt; from a Solarized &lt;code&gt;tmux&lt;/code&gt; session returns a bunch of gray directories and files, instead of the distinguishable colors we would expect.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QZ-IkfvK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://i.imgur.com/FqQwFpK.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QZ-IkfvK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://i.imgur.com/FqQwFpK.png" alt='"Bright" blue'&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is because &lt;code&gt;ls&lt;/code&gt; uses &lt;a href="https://en.wikipedia.org/wiki/ANSI_escape_code#Colors"&gt;"bright"&lt;/a&gt; colors for directories and certain files, but Solarized has overridden these "bright" colors with its base colors.&lt;/p&gt;

&lt;p&gt;But I don't want "bright" colors, I want &lt;strong&gt;bold&lt;/strong&gt; text.  So I spent some time googling and hacking on config files, and I eventually got what I wanted!&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ls&lt;/code&gt; to print colored directories and files with &lt;strong&gt;bold text&lt;/strong&gt; ðŸ˜€&lt;/p&gt;

&lt;p&gt;As a preface, I honestly have no idea why this worked ðŸ˜•&lt;/p&gt;

&lt;h1&gt;
  
  
  My Setup
&lt;/h1&gt;

&lt;p&gt;I've only tested this within my own setup, so if it doesn't work for you, sorry â˜¹ï¸ &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OaOHFQdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://i.imgur.com/g1nSihX.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OaOHFQdZ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://i.imgur.com/g1nSihX.png" alt="Setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  Solarized
&lt;/h1&gt;

&lt;p&gt;No changes here, thankfully.&lt;/p&gt;

&lt;p&gt;I just set my terminal's colors to the beautiful Solarized colors as instructed by &lt;a href="http://ethanschoonover.com/solarized"&gt;Ethan&lt;/a&gt;.&lt;/p&gt;

&lt;h1&gt;
  
  
  tmux
&lt;/h1&gt;

&lt;p&gt;You must be using &lt;code&gt;tmux&lt;/code&gt; 2.2 or above.  I noticed this did not work on &lt;code&gt;tmux&lt;/code&gt; 2.1.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ tmux -V
tmux 2.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;My &lt;code&gt;TERM&lt;/code&gt; environment variable is set to &lt;code&gt;xterm-256color&lt;/code&gt; by default.  I'm unsure if that is something terminator is doing or Fedora, but it is what it is.&lt;/p&gt;

&lt;p&gt;In my &lt;code&gt;.tmux.conf&lt;/code&gt; file, I set the &lt;code&gt;default-terminal&lt;/code&gt; option to &lt;code&gt;screen-256color&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;set -g default-terminal screen-256color
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, I used the &lt;code&gt;-2&lt;/code&gt; option when opening &lt;code&gt;tmux&lt;/code&gt; to force &lt;code&gt;tmux&lt;/code&gt; to assume the terminal uses 256 colors.  I created an alias for &lt;code&gt;tmux&lt;/code&gt; which includes this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;alias tm='tmux -2'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Bold text
&lt;/h1&gt;

&lt;p&gt;I created a &lt;code&gt;.dir_colors&lt;/code&gt; file in my home directory using &lt;code&gt;dircolors&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dircolors -p &amp;gt; ~/.dir_colors
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This file defines all the color codes &lt;code&gt;ls&lt;/code&gt; will use when printing files and directories.&lt;/p&gt;

&lt;p&gt;I then used the &lt;a href="https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes"&gt;ANSI SGR parameter code 38&lt;/a&gt; to specify colors from the extended 256 colors.&lt;/p&gt;

&lt;p&gt;For example: From dircolors, the config to set directory colors, &lt;code&gt;DIR&lt;/code&gt;, was set to &lt;code&gt;1;34&lt;/code&gt;, which results in a bright(1) blue(34) color.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DIR 1;34
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But, as I've mentioned, the Solarized "bright blue" is not actually blue, but a gray hue.&lt;/p&gt;

&lt;p&gt;Using the &lt;code&gt;38;5&lt;/code&gt; ANSI code, I was able to specify the &lt;strong&gt;bold&lt;/strong&gt;(1) ANSI 256(38;5) color blue(4), NOT bright!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DIR 1;38;5;4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--dBhkDynv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://i.imgur.com/kxQ6tcC.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--dBhkDynv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/http://i.imgur.com/kxQ6tcC.png" alt="Bold blue"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And there you go!&lt;/p&gt;

&lt;p&gt;You can find the rest of my &lt;code&gt;.dir_colors&lt;/code&gt; file, along with all my home directory config files on &lt;a href="https://github.com/zachwhaley/dotfiles/"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="http://zachwhaleys.website/2017/01/19/solarized+tmux+ls+boldtext/"&gt;http://zachwhaleys.website/2017/01/19/solarized+tmux+ls+boldtext/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>solarized</category>
      <category>terminal</category>
      <category>colors</category>
      <category>tmux</category>
    </item>
    <item>
      <title>Better P4 Output</title>
      <dc:creator>Zach Whaley</dc:creator>
      <pubDate>Fri, 24 Feb 2017 02:09:31 +0000</pubDate>
      <link>https://dev.to/zachwhaley/better-p4-output</link>
      <guid>https://dev.to/zachwhaley/better-p4-output</guid>
      <description>&lt;h2&gt;
  
  
  P4 Output
&lt;/h2&gt;

&lt;p&gt;If you're using Perforce for version control, and you're using their command line tool, p4,&lt;br&gt;
you probably know that p4 is not a great tool.&lt;br&gt;
Perforce itself is a decent version control manager, it's certainly not the worst (*cough* CVS),&lt;br&gt;
but the p4 tool is just not that great ðŸ˜ž&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;p4's output is hard to read and inconsistent&lt;/li&gt;
&lt;li&gt;p4's various commands use inconsistent options and arguments&lt;/li&gt;
&lt;li&gt;And p4's return codes differ from the return codes of their own APIs!&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is nothing sensible I can do about the last two problems, but the bad output.&lt;br&gt;
That was something I could fix.&lt;/p&gt;
&lt;h2&gt;
  
  
  Better P4 Output
&lt;/h2&gt;

&lt;p&gt;I wrote a program called &lt;a href="http://zachwhaleys.website/bp4o/" rel="noopener noreferrer"&gt;BP4O&lt;/a&gt; (Better P4 Output) to improve p4's output and readability.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://asciinema.org/a/96884" rel="noopener noreferrer"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fasciinema.org%2Fa%2F96884.png" alt="asciicast"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Without BP4O, you get a deluge of text scattered across the screen.&lt;br&gt;
Finding the files, their changes, and the changelists they share is difficult and nearly impossible at a glance,&lt;br&gt;
and keeping that information straight between changes and commands is even more difficult.&lt;/p&gt;

&lt;p&gt;With BP4O, we turn that same output into a readable block, reasonably separated by sections, columns, and colors.&lt;br&gt;
Relevant information, like what files are in a changelist, and how files have been modified, is easily visible.&lt;/p&gt;

&lt;p&gt;BP4O will also color your diffs, page long output, and provide aliased commands!&lt;/p&gt;

&lt;p&gt;Overall, BP4O makes using p4 better without changing how you use p4.&lt;/p&gt;
&lt;h2&gt;
  
  
  Installing BP4O
&lt;/h2&gt;

&lt;p&gt;BP4O works with Bash, Zsh&lt;a href="https://github.com/zachwhaley/bp4o#zsh-users" rel="noopener noreferrer"&gt;*&lt;/a&gt;, and Fish shell, and is available for&lt;/p&gt;

&lt;p&gt;macOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;brew tap zachwhaley/beer
brew install bp4o
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ubuntu:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo add-apt-repository ppa:zachwhaley/ppa
sudo apt update
sudo apt install bp4o
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Fedora/CentOS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo dnf copr enable zachwhaley/bp4o
sudo dnf install bp4o
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;

&lt;p&gt;BP4O's code is open source on &lt;a href="https://github.com/zachwhaley/bp4o" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contributions are welcome!&lt;/p&gt;

&lt;p&gt;&lt;a href="http://zachwhaleys.website/2017/01/05/bp4o/" rel="noopener noreferrer"&gt;http://zachwhaleys.website/2017/01/05/bp4o/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>perforce</category>
      <category>vcs</category>
      <category>beautify</category>
    </item>
  </channel>
</rss>
