{"id":7951,"date":"2022-03-28T17:28:16","date_gmt":"2022-03-28T16:28:16","guid":{"rendered":"https:\/\/www.blopig.com\/blog\/?p=7951"},"modified":"2022-03-28T17:31:34","modified_gmt":"2022-03-28T16:31:34","slug":"making-pwd-redundant","status":"publish","type":"post","link":"https:\/\/www.blopig.com\/blog\/2022\/03\/making-pwd-redundant\/","title":{"rendered":"Making pwd redundant"},"content":{"rendered":"\n<p>I&#8217;m going to keep this one brief, because I am mid-confirmation-and-paper-writing madness. I have seen too many people &#8211; both beginners and seasoned veterans &#8211; wandering around their Linux filesystem blindfolded:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/03\/image-3.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/03\/image-3.png?resize=104%2C25&#038;ssl=1\" alt=\"\" class=\"wp-image-7953\" width=\"104\" height=\"25\" \/><\/a><figcaption>Isn&#8217;t it hideous?<\/figcaption><\/figure><\/div>\n\n\n\n<p>Whenever you want to see where you are, you have to execute <code>pwd<\/code> (present working directory), which will print your absolute location to stdout. If you have many terminals open at the same time, it is easy to lose track of where you are, and every other command becomes <code>pwd<\/code>; surely, I hear you cry, there has to be a better way!<\/p>\n\n\n\n<p>Well, fear not! With a little tinkering with <code>~\/.bashrc<\/code>, we can display the working directory as part of the special <code>PS1<\/code> environment variable, responsible for how your username and computer are displayed above. Putting the following at the top of <code>~\/.bashrc<\/code><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>me=`id | awk -F\\( '{print $2}' | awk -F\\) '{print $1}'`\nexport PS1=\"`uname -n |  \/bin\/sed 's\/\\..*\/\/'`{$me}:\\$PWD$ \"<\/code><\/pre>\n\n\n\n<p>&#8230; saving, and starting a new termanal window results in:<\/p>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/03\/image-4.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"482\" height=\"39\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/03\/image-4.png?resize=482%2C39&#038;ssl=1\" alt=\"\" class=\"wp-image-7954\" srcset=\"https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/03\/image-4.png?w=482&amp;ssl=1 482w, https:\/\/i0.wp.com\/www.blopig.com\/blog\/wp-content\/uploads\/2022\/03\/image-4.png?resize=300%2C24&amp;ssl=1 300w\" sizes=\"auto, (max-width: 482px) 100vw, 482px\" \/><\/a><figcaption>Much better!<\/figcaption><\/figure><\/div>\n\n\n\n<p>I haven&#8217;t used <code>pwd<\/code> in 3 years.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m going to keep this one brief, because I am mid-confirmation-and-paper-writing madness. I have seen too many people &#8211; both beginners and seasoned veterans &#8211; wandering around their Linux filesystem blindfolded: Whenever you want to see where you are, you have to execute pwd (present working directory), which will print your absolute location to stdout. [&hellip;]<\/p>\n","protected":false},"author":61,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","wikipediapreview_detectlinks":true,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[348,29,296,14,15],"tags":[],"ppma_author":[541],"class_list":["post-7951","post","type-post","status-publish","format-standard","hentry","category-bash","category-code","category-hints-and-tips","category-howto","category-technical"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"authors":[{"term_id":541,"user_id":61,"is_guest":0,"slug":"jack","display_name":"Jack Scantlebury","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/2d30962dbe9d08db0ac110abbf9ffd5bd52f4eb7da79636d286fb584280feb2c?s=96&d=mm&r=g","0":null,"1":"","2":"","3":"","4":"","5":"","6":"","7":"","8":""}],"_links":{"self":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/7951","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/users\/61"}],"replies":[{"embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/comments?post=7951"}],"version-history":[{"count":3,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/7951\/revisions"}],"predecessor-version":[{"id":7957,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/posts\/7951\/revisions\/7957"}],"wp:attachment":[{"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/media?parent=7951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/categories?post=7951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/tags?post=7951"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.blopig.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=7951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}