{"id":20,"date":"2007-02-10T07:14:00","date_gmt":"2007-02-10T05:14:00","guid":{"rendered":"http:\/\/blog.sqawasmi.com\/?p=20"},"modified":"2007-02-10T07:14:00","modified_gmt":"2007-02-10T05:14:00","slug":"enhance-bash-completion-feature","status":"publish","type":"post","link":"https:\/\/blog.sqawasmi.com\/index.php\/2007\/02\/10\/enhance-bash-completion-feature\/","title":{"rendered":"Enhance Bash Completion feature"},"content":{"rendered":"<p>as known pressing tabs in the Command Line Interface will complete commands or filenames for you, it&#8217;s a very nice feature in bash, i don&#8217;t remember most of the commands without this feature, but does this feature need to enhance? when you write <span style=\"color: rgb(102, 102, 102);\">cd [tab]<\/span> then bash will list all files and directories in the directory you are working in, but you just need the directories to be listed.<br \/><span class=\"fullpost\"><br \/><\/span>Imagine typing ssh [Tab] and being able to complete on hosts from your ~\/.ssh\/known_hosts files. Or typing man 3 str [Tab] and getting a list of all string handling functions in the UNIX manual.<\/p>\n<p>you can do many things like that with bash built in commands like <span style=\"color: rgb(153, 153, 153);\">complete <\/span>for example:<br \/><span style=\"color: rgb(153, 153, 153);\">complete -d pushd -C cd<\/span><br \/>now when you use <span style=\"color: rgb(153, 153, 153);\">cd [tab]<\/span> then the directories should be listed&#8230;.<br \/>there is a nice tool named bash-completion<span style=\"text-decoration: underline;\"> <\/span><span style=\"color: rgb(153, 153, 153);\"><span style=\"color: rgb(51, 0, 51);\"><span style=\"color: rgb(0, 0, 0);\"><span style=\"color: rgb(153, 153, 153);\"><span style=\"color: rgb(0, 0, 0);\">that combines a lot of nice completion features, in slackware you can find it in the extra folder. i dont know about the other distributions but you can find it <a href=\"http:\/\/freshmeat.net\/projects\/bashcompletion\/\">here<\/a>, after you install it, you have to source it with <span style=\"color: rgb(153, 153, 153);\">.\/etc\/bash_completion<\/span> command or you can put it into your <span=\"\" style=\"color: rgb(102, 102, 102);\">~\/.bashrc<\/span=\"\"><\/span> <\/span>file by writing some something like this in it<\/p>\n<pre style=\"color: rgb(102, 102, 102);\"># enable bash completion in interactive shells<br \/>if [ -f \/etc\/bash_completion ]; then<br \/>. \/etc\/bash_completion<br \/>fi<br \/><br \/><span style=\"color: rgb(0, 0, 0); font-family: arial;\">Have Fun!<\/span><br \/><\/pre>\n<p><\/span><br \/><\/span><\/span><\/p>\n<h3>Related Images:<\/h3>","protected":false},"excerpt":{"rendered":"<p>as known pressing tabs in the Command Line Interface will complete commands or filenames for you, it&#8217;s a very nice feature in bash, i don&#8217;t remember most of the commands without this feature, but does this feature need to enhance? when you write cd [tab] then bash will list all files and directories in the [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"ngg_post_thumbnail":0,"footnotes":""},"categories":[14],"tags":[],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-bash"],"_links":{"self":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts\/20","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/comments?post=20"}],"version-history":[{"count":0,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.sqawasmi.com\/index.php\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}