This article was originally published on bmf-tech.com.
Overview
I started feeling lazy about typing paths and directories like cd hogehoge, so I used a shell script to make it a bit easier.
Source
#!/bin/sh
# cd by selecting numbers
function cdSelect() {
dirs=`ls -a`
PS3="Select directory > "
echo 'Directory list:'
select dir in ${dirs}
do
stty erase ^H
cd ${dir}
break
done
}
alias cd-s=cdSelect
When you type cd-s, it looks like this:
Directory list:
1) .
2) ..
3) hoge_a
4) hoge_b
5) hoge_c
Select directory > 3
Thoughts
It might be challenging when there are many directories, but it has reduced the stress of using the cd command. I'm considering making a vim version too.
Top comments (0)