{"id":8206,"date":"2015-05-28T10:40:46","date_gmt":"2015-05-28T14:40:46","guid":{"rendered":"http:\/\/www.ezrasf.com\/wplog\/?p=8206"},"modified":"2015-05-28T10:40:46","modified_gmt":"2015-05-28T14:40:46","slug":"separating-bash-histories","status":"publish","type":"post","link":"https:\/\/www.ezrasf.com\/wplog\/2015\/05\/28\/separating-bash-histories\/","title":{"rendered":"Separating Bash Histories"},"content":{"rendered":"<p>Years ago, maybe 2011 based on the age of files, our Systems group moved our Linux home directories to a central system. My only real complaint about this move was finding anything I needed in my Bash history. See, I am terrible at remembering things and often make typos. It is easier to go back in my history to a prior command and either run it or modify that one and run. The same home directory across all these systems complicated things by co-mingling commands. I was able to find\u00c2\u00a0things. Just eventually. That\u00c2\u00a0seemed inefficient.<\/p>\n<p>Eventually, this situation annoyed me to the point I decided to fix it. And the fix was so simple it is amazing that I did not immediately address it rather than suffering with it for a couple years. (Well, actually, we picked Desire2Learn before the change so 90% of my server responsibilities were on Windows. Only when I was promoted to a Technology Strategist and returned\u00c2\u00a0to majority work in Linux did it get annoying enough to address.)<\/p>\n<p>The fix? Add hostname to the HISTFILE variable\u00c2\u00a0in .bash_profile.<\/p>\n<blockquote><p>export HISTFILE=&#8221;${HOME}\/.bash_history.`hostname`&#8221;<\/p><\/blockquote>\n<p>Apparently I made the change back on December 18th. In the six months since, I have not noticed any oddities with the history.\u00c2\u00a0This morning I noticed that I have about twenty different host named history files of various sizes and dates.<\/p>\n<p>Given the number of files, while writing this post, I decided to\u00c2\u00a0re-organize these into a directory. (An organized home directory is a happy home directory. Heh.)<\/p>\n<blockquote><p>export HISTFILE=&#8221;${HOME}\/.bash_history\/.bash_history.`hostname`&#8221;<\/p><\/blockquote>\n<p>Then I ran these.<\/p>\n<blockquote><p>mv .bash_history .bash_history.org<br \/>\nmkdir\u00c2\u00a0.bash_history<br \/>\nmv .bash_history.* .bash_history<\/p><\/blockquote>\n<p>Then I exited which dumped that session&#8217;s history into a file in the old location. I logged in again and used cat and the output redirect to append those new lines to the correct file in the new location.<\/p>\n<p>Exited again and logged in again. And everything still looks good.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Years ago, maybe 2011 based on the age of files, our Systems group moved our Linux home directories to a central system. My only real complaint about this move was finding anything I needed in my Bash history. See, I am terrible at remembering things and often make typos. It is easier to go back [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_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,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","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}},"categories":[109],"tags":[324,3002],"class_list":["post-8206","post","type-post","status-publish","format-standard","hentry","category-unix","tag-bash","tag-hostname"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p1rUBW-28m","jetpack-related-posts":[],"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/posts\/8206","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/comments?post=8206"}],"version-history":[{"count":0,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/posts\/8206\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/media?parent=8206"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/categories?post=8206"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ezrasf.com\/wplog\/wp-json\/wp\/v2\/tags?post=8206"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}