0

I want to build a script that permit go fast to a path. I want to know if I can use 'complete' command or other command to autocomplete with the directories under '/var/www/vhosts/'. The script is like this:

#!/bin/bash
if [ -d /var/www/vhosts/$1/httpdocs ]; then
    cd /var/www/vhosts/$1/httpdocs
else
    cd /var/www/vhosts/$1
fi
  • I fail to see the question, this script looks fine, be sure to source it (e.g. using . myscript.sh ARG (with a leading dot). – Archemar Oct 25 '17 at 8:28
  • Yes, it work. I'm using source to interpret it. But not work like I want. The purpose of the script is to save time when accessing the directories. So it would be helpful to autocomplete with directories under the path – Daniel Oct 25 '17 at 8:31
  • How should it autocomplete when you are telling it to use the first parameter? – Jeff Schaller Oct 25 '17 at 11:17
  • You want to start here: unix.stackexchange.com/q/77009/4667 – glenn jackman Oct 25 '17 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.