{"id":4048,"date":"2011-08-17T11:21:05","date_gmt":"2011-08-17T05:51:05","guid":{"rendered":"http:\/\/www.tothenew.com\/blog\/?p=4048"},"modified":"2016-12-19T15:19:23","modified_gmt":"2016-12-19T09:49:23","slug":"organizing-bashrc","status":"publish","type":"post","link":"https:\/\/www.tothenew.com\/blog\/organizing-bashrc\/","title":{"rendered":"Organizing &#8220;.bashrc&#8221;"},"content":{"rendered":"<p>I have been working on Linux for almost 3 years now and have grown to love it a lot. <\/p>\n<p>As with every linux user, the .bashrc file becomes cumbersome and difficult to maintain over a period of time, since there are a lot of project specific aliases, paths, etc<\/p>\n<p>So after working on a couple of projects, I started maintaining separate files for my environment settings. So I just had to create a separate project setting file:<\/p>\n<p>[bash]~\/.myProjectSettings[\/bash]<br \/>\n[bash]<br \/>\nalias myAlias1=&#8217;cd \/to\/project\/dir&#8217;<br \/>\nalias projectqa=&#8217;ssh to@qa&#8217;<br \/>\nalias projectDb=&#8217;mysql -u&lt;username&gt; -p&lt;password&gt; &lt;project_db_name&gt;&#8217;<br \/>\n[\/bash]<br \/>\nSo, everytime I had to add more project specific settings or separate my settings, I had to create a  new settings file and then source it in my .bashrc by adding this line<\/p>\n<p>[bash]. ~\/.myProjectSettings[\/bash]<\/p>\n<p>As you can guess, after doing this a couple of times, even this was becoming very tedious. <\/p>\n<p>So, I tried to follow the golden rule of convention over configuration. <\/p>\n<p>In my .bashrc, I added the following function :<br \/>\n[bash]<br \/>\nfunction sourceAllMySettings(){<br \/>\n\tFOLDER_TO_BE_SOURCED=~\/.mySettings\/<br \/>\n\tfor i in `find $FOLDER_TO_BE_SOURCED -type f`;<br \/>\n\tdo<br \/>\n\t\t. $i<br \/>\n\tdone;<br \/>\n}<br \/>\n##don&#8217;t forget to execute the function<br \/>\nsourceAllMySettings<br \/>\n[\/bash]<br \/>\nand placed all my setting files into the folder :<br \/>\n[bash]~\/.mySettings\/[\/bash]<\/p>\n<p>So, now if I have to add more settings to my .bashrc, I just create a new executable file in this folder and it gets automatically sourced.<\/p>\n<p>Goodbye messy .bashrc, welcome organized (segregated) settings \ud83d\ude42<\/p>\n<p>Regards<br \/>\n~~Himanshu Seth~~<br \/>\nhttp:\/\/www.tothenew.com<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I have been working on Linux for almost 3 years now and have grown to love it a lot. As with every linux user, the .bashrc file becomes cumbersome and difficult to maintain over a period of time, since there are a lot of project specific aliases, paths, etc So after working on a couple [&hellip;]<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":10},"categories":[1],"tags":[260,8],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4048"}],"collection":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/comments?post=4048"}],"version-history":[{"count":0,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/posts\/4048\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/media?parent=4048"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/categories?post=4048"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tothenew.com\/blog\/wp-json\/wp\/v2\/tags?post=4048"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}