[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFE] mkdir w/chdir
From: |
Davide Brini |
Subject: |
Re: [RFE] mkdir w/chdir |
Date: |
Tue, 3 Sep 2019 22:28:48 +0200 |
On Tue, 3 Sep 2019 13:12:25 -0700, Vito Caputo <address@hidden> wrote:
> Lately I've been finding myself wishing there were a flag for mkdir to
> cd into the directory, especially in combination with creating parents.
>
> It's like I'm already thinking in convenient shortcut mode asking for
> parents to be created and just want to throw another flag in there to
> switch my directory as well in the same command.
There's no unique "current directory", it's per-process, so even if mkdir
changed into the newly-created directoy, the caller (ie, the calling shell)
would be unaffected.
On the other hand, you can easily write a function to perform the two
actions, for example:
mkcd(){
mkdir -p -- "$1" && cd -- "$1"
}
--
D.