I'll do it once.
Trying to enter a directory that does not exist
$ cd foo
bash: cd: foo: No such file or directory
And fuck while yelling fuck.
fuck To do
$ fuck
mkdir -p foo && cd foo [enter/↑/↓/ctrl+c]
When I saw the fuck given here, it turned out to be "this is it".
Should I do something like this? (The name of the directory you are trying to enter is ** foo **)
All you have to do is write this.
Trial writing
function cd() {
if [ -d $1 ]; then
command cd $1
elif [ ! -e $1 ]; then
mkdir -p $1 && command cd $1
else
echo no more
fi
}
But how about the error display ** no longer **?
Of course I get angry when I try to cd to a file.
$ touch hoge
$ cd hoge
bash: cd: hoge: Not a directory
Isn't this all right?
For the time being, the favorite
function cd() {
if [ ! -e $1 ]; then
mkdir -p $1 && command cd $1
else
command cd $1
fi
}
Please let me know if there is a smarter way.
Recommended Posts