Change The Directory Without "cd"

695933



 

Automatically Switch To A Directory Without Using Cd Command

Let us say you wanted to go to the directory Downloads. You don’t need to type “cd Downloads” every time to go that directory. Instead, just type “Downloads” in the Terminal. Sounds cool, yeah? Indeed!
When you type Downloads in the Terminal, you will see the following message:
$ Downloads/
bash: Downloads/: Is a directory
You can type “cd Downloads” to go the Downloads directory, right? But, wait! You don’t have to use cd command anymore. To do so, edit your .bashrc file:
vi ~/.bashrc
And, add the following line at the end:
shopt -s autocd
Update the changes made in the .bashrc file with the following command:
source ~/.bashrc
All done! You can now go to any directory without using cd command. Just enter the path of the directory like below. Bash can automatically prepend cd when entering just the path of any directory in the Terminal.
[sk@sk]: ~>$ Downloads/
cd -- Downloads/
[sk@sk]: ~/Downloads>$ Telegram/
cd -- Telegram/
[sk@sk]: ~/Downloads/Telegram>$
autocd
 
Look at the above screenshot. Did I use “cd” command? Nope. I just entered the Directory name and it automatically went to the respective directory
REFERENSI :
https://www.ostechnix.com/automatically-switch-directory-without-using-cd-command/

Komentar

Postingan Populer