<div dir="ltr"><p>Dear password store users,</p>
<p>First of all thank you for developing such a great command line utility as <i>pass</i> is. I am fresh IT university graduate and a while ago I started using <i>pass</i> in a smaller company I work in, but let's go for my pull request.</p>
<p><font size="+1"><b>TLDR</b></font></p>
<p>Implementation of shortcuts which are written left of the password files in <i>pass ls/find/search </i>output and can be used with <i>pass show -s<number></i> to retrieve passwords not by full path, but by usually short number.<br>
</p>
<p><b><font size="+1">Short description</font></b></p>
<p>This commit introduces shortcut argument <i>-s</i> or <i>--shortcut</i> to <i><b>pass show</b> </i>command
with which you can reference password not by full path, but by number,
which reference the specific gpg file in your password storage
directory.</p>
<p><b><font size="+1">Motivation</font></b><br>
</p>
<p>Long paths to keys where you have multiple options in autocomplete are harder to write, so I was thinking about easier way to input path to
password I want to look for. I was thinking about something like short
hash for the files, or unique ID, but when I pulled actual code for pass
I found that the code is made very simple (which is great)
but also harder to extend (for example because of relying on the output of
<i>tree</i> command). <br>
</p>
<p>After few days of thinking about an easy solution I decided to use an <i>inode</i> as a reference shortcut for paths and implemented new argument to <i>pass show</i> command. Inodes are easy to get (tree --inodes) and easy to find (with <i>find</i> -inum). </p>
<p><b><font size="+1">Usage</font></b><i><br>
</i></p>
<p>The best use case I found<i> </i>is<i> </i>when you use <i>pass find/search</i> or <i>pass ls <dir> along</i> with <i>pass show -s<shortcut></i>. <br>
</p>
<p>Example: </p>
<blockquote>
<p><font face="DejaVu Sans"><b>$ pass find db</b> #This is usual output<br>
</font></p>
<p><font face="DejaVu Sans">passwords<br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans">└</font>── customers<br>
├── customer1<br>
│ </font><font face="DejaVu Sans"><font face="DejaVu Sans">├</font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">── </font><a href="http://db01.example.com">db01.example.com</a><br>
</font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│</font> </font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│</font> </font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">├</font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">── root</font></font></font></font><br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│</font></font></font> </font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│</font></font></font> </font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">──</font></font></font> customer1</font></font><br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans">│</font> </font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans">──</font> <a href="http://db02.example.com">db02.example.com</a> <br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│ </font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font></font></font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">── </font></font></font></font></font></font></font></font></font></font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">root</font></font></font></font></font></font></font></font></font></font></font></font><font face="DejaVu Sans"><br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font><font face="DejaVu Sans">─</font><font face="DejaVu Sans">─ customer2<br>
</font> <font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font><font face="DejaVu Sans">── <a href="http://db.customer2.com">db.customer2.com</a><br>
</font> <font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font></font></font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">── </font></font></font></font></font></font></font></font></font></font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">root</font></font></font></font></font></font></font></font></font></font></font></font></p>
<p><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"></font></font></font></font></font></font></font></font><font face="DejaVu Sans"><b>$ pass find db </b></font># Output after implementing new shortcut feature<br>
</p>
<p><font face="DejaVu Sans">passwords<br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans">└</font>── customers<br>
├── customer1<br>
│ </font><font face="DejaVu Sans"><font face="DejaVu Sans">├</font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">── </font><a href="http://db01.example.com">db01.example.com</a><br>
</font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│</font> </font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│</font> </font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">├</font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">── [123456] root</font></font></font></font><br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│</font></font></font> </font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│</font></font></font> </font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">──</font></font></font> [123457] customer1</font></font><br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans">│</font> </font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans">──</font> <a href="http://db02.example.com">db02.example.com</a> <br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">│ </font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font></font></font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">── </font></font></font></font></font></font></font></font></font></font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">[135412] root</font></font></font></font></font></font></font></font></font></font></font></font><font face="DejaVu Sans"><br>
</font><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font><font face="DejaVu Sans">─</font><font face="DejaVu Sans">─ customer2<br>
</font> <font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font><font face="DejaVu Sans">── <a href="http://db.customer2.com">db.customer2.com</a><br>
</font> <font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">└</font></font></font></font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">── </font></font></font></font></font></font></font></font></font></font></font></font><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans">[<NUMBER>] root<br>
</font></font></font></font></font></font></font></font></font></font></font></font></p>
<p><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><font face="DejaVu Sans"><b>$ pass </b><b>show -</b><b>s123456</b><br>
<u>> customer1rootpassword</u><br>
</font></font></font></font></font></font></font></font></font></font></font></font></p>
</blockquote>
<p><font face="DejaVu Sans"><b><font size="+1">Benefits</font></b></font></p>
<ul>
<li><font face="DejaVu Sans">Inodes are usually not very long, therefore you can write pass show -s<N> easily on keyboard, or copy shortcut with mouse (but I don't want to encourage people to use mouse) or keyboard.</font><font face="DejaVu Sans"><font size="+1"><br>
</font></font></li>
</ul>
<p><font size="+1"><b>Downsides</b></font><br>
</p>
<ul>
<li>I needed to add shortcut ID to the output of tree command, so the
output is now different. I sedded out inodes for directories so the
printed tree is prettier. <br>
</li>
<li>Files which have string [<number>] in name can cause troubles (filtering of regex '\[[0-9]+\]\ \ ')<br>
</li><li>There must not be a space after argument -s. Relevant usage is '<i>pass show -s<number>'. </i>I reused code from other functions, so maybe other functions behave the same.</li>
</ul>
<p><b><font size="+1">Git diff</font></b></p>
<p>All tests passed OK with exception of <i>t0500-find.sh</i> where the changed output was issue, so I updated regex to strip inode number ([NUMBER]) in this test. Git diff is located in attachment.</p>
<p>Thank you for reading :-).</p></div>