You are not logged in.
Pages: 1
Is it possible to make bash treat typing in a folder name as cd + this folder name? I type cd all the time and it's sort of tiring. Also it would be nice to make bash also automatically xdg-open file names which are typed in, but are not folders.
Thanks.
Offline
Not sure about bash, but zsh has an option for this. It's called autocd.
EDIT: https://www.gnu.org/software/bash/manua … iltin.html
Last edited by WorMzy (2014-03-13 21:59:41)
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
And then I create a file or folder with the same name as an executable and the joke is on you.
Offline
And then I create a file or folder with the same name as an executable and the joke is on you.
Make a folder called cd.
Sakura:-
Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD
Making lemonade from lemons since 2015.
Offline
And then I create a file or folder with the same name as an executable and the joke is on you.
You still need dot slash to launch a local executable, so i don't think those two would collide - besides, i can't remember naming folders "sudo" or "rm". But it's a valid point.
Not sure about bash, but zsh has an option for this. It's called autocd.
Thanks, it seems to be built in after all.
shopt -s autocd
Checking this out right now, kind of buggy imho - for example bash autocompletion doesn't always kick in without cd - it seems to work ok if a folder name is capitalized. Oh, well..
Last edited by hrdx (2014-03-13 22:12:38)
Offline
And then I create a file or folder with the same name as an executable and the joke is on you.
i should try this...
Last edited by Rasi (2014-03-13 22:39:38)
He hoped and prayed that there wasn't an afterlife. Then he realized there was a contradiction involved here and merely hoped that there wasn't an afterlife.
Douglas Adams
Offline
I have
shopt -s cdable_vars
export apps="/home/karol/apps"
export usb="/media/usb"
export cachedir="/var/cache/pacman/pkg"
export foo="/home/karol/test/foo"
export bar="/home/karol/test/bar"
in my .bashrc.
$ pwd
/home/karol/test
$ cd cachedir
/var/cache/pacman/pkg
$ pwd
/var/cache/pacman/pkg
$ cd foo
/home/karol/test/foo
$ pwd
/home/karol/test/foo
Offline
Checking this out right now, kind of buggy imho - for example bash autocompletion doesn't always kick in without cd - it seems to work ok if a folder name is capitalized. Oh, well..
Prepend
./
before the foldernames, and the completion should work fine.
Offline
I think cd is easier to type than ./.
Offline
you need to type an extra character (space) with cd
Offline
If you want to navigate through folders with as little typing as possible try 'autojump' from the community repos. See how it works here:
https://www.youtube.com/watch?v=tnNyoMGnbKg
Offline
you could make aliases
alias Home='cd "$HOME"'
alias Pictures='cd "$HOME/Pictures"'
# etc..
also, if you want to 'cd "$HOME"' then you can just 'cd' and it assumes you want to go to ~
Last edited by HiImTye (2014-07-11 20:55:28)
Offline
Ranger File Manager has some useful shortcuts for navigating to directories. you can set aliases to go to the most frequently visited directories or for all the directories in /
eg.
alias gh='cd $HOME'
alias ge='cd /etc/'
alias gu='cd /usr/'
etc.
Offline
Isn't 'cd $HOME' the same as 'cd'?
See also the aforementioned 'shopt -s autocd' and 'shopt -s cdable_vars'.
Last edited by karol (2014-07-11 21:15:12)
Offline
setting $CDPATH does that.
$ echo $CDPATH
/home/chaonaut/chaos:/home/chaos
$ pwd
/home/chaonaut
$ cd Ozric\ Tentacles
/home/chaos/Ozric Tentacles
$ pwd
/home/chaos/Ozric Tentacles
— love is the law, love under wheel, — said aleister crowley and typed in his terminal:
usermod -a -G wheel love
Offline
Pages: 1