質問

Let's take the following directory listing as an example:

folder-1-one
folder-2-two
folder-3-three

Let's further assume, I want to cd into folder-1-one.

I could use tab completions but this becomes tedious if I have plenty of very similar folder names.

Instead I would like to use some sort of keyword expression. In the example case, 1 and one is unique to the folder I want to access.

Thus I am looking for something like cd 1 or cd one to quickly change into the desired directory without having to pay attention at what point the 1 or the one occur in the file name.

What would be a good solution for that use case?

役に立ちましたか?

解決

You could use bash aliases to hardcode the directories you change to freqeuntly:

alias one='cd folder-1-one'
alias two='cd folder-2-two'

Alternatively you could look into using zsh, which supports fuzzy completion via 'oh-my-zsh'. Similar facilities for bash exist (although I can't vouch for them) - such as this one.

他のヒント

You can just use wildcards

cd *1*
cd *2*
cd *three

You can do:

cd *one
cd *two

etc.. but keep in mind that if there is another dir-one then you will get ambiguous warning.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top