Silent pushd and popd in Bash Scripts

I have several shell scripts that use pushd and popd extensively. These commands output the paths to stdout which may overwhelm the console output with lots of unwanted text. Unfortunately, neither pushd nor popd have any silent option according to their man pages. A simple solution is to redirect the stdout to /dev/null. pushd $PWD > /dev/null Is it favourable to explicitly redirect to /dev/null everytime I call pushd/popd in the script?
Read more →

Find All Directories

I needed to go through a directory structure and do a git-fetch if there was a .git repository inside. Finding all directories containing the .git is quite easy with find command. find $root-directory -regex '^.*/.git$' -printf '%h\n' | sort -d This is nice but it also prints unneccesary data. It does not only print the leaf directories but also all the partial paths to them. The original project structure is something like:
Read more →

Bash Autocomplete

MotivationI have inherited several Bash installation scripts for our software developed in CertiCon. What a user could do was to call the following command in the terminal and the application behaved as requested. $ myApp start|stop|restart The magic was hidden in the keyword complete in a file called autocomplete_app.sh. autocomplete_app.sh complete -o nospace -F _myApp_autocomplete myApp complete -o nospace -F _myApp_autocomplete /opt/myApp/compose.sh AutocompletionBash auto completion is quite a well-known feature from user point of view.
Read more →