Search code examples
linuxbashln

Why does Bash show me the whole path of my symlinked script when I tab complete its name?


I'm trying to do my own command (test.sh script).

The script works perfect and I created a soft link (i.e., ln -s /home/test.sh ~/bin/test).

And when I call from anywhere inside RHEL, it also works perfectly.

But my problem is the next one:

When from the command line I'm writing the name of the command (test), and I press the Tab key, the system shows me the full path and name of my script, i.e., $ /home/bin/test, and I want that it only shows me the name of the command ($ test).

Is that possible? How can I do it?


Solution

  • What you need is an alias. In RHEL/CENTOS systems, perform the below steps

    1. vi ~/.bashrc
    2. add this line alias test='/home/test.sh'
    3. source ~/.bashrc (optional step, unless you want your current session to have the updated bashrc, else a restart/logout/login should not require this step!)