Thursday, 24 February 2022

Re: Bash Command "mkcd"

On 2/24/22 05:30, Colin Watson wrote:
I'm not the bash maintainer, but the bar for new shell builtins is  rightly high since any additions would affect all systems, and I would  expect this to be refused since it's easy to implement it as a local  shell function with whatever behaviour and spelling you want.

Pretty straightforward:

    function mkcd() { mkdir -p "$@" && cd "$_"; }

man bash, and look at the 'Special Parameters' section for the use of the '_' param. You could also use "$@" there as well.

  --   David A. Desrosiers  Principal Support Engineer (PSE/DSE), Canonical US   <david.desrosiers@canonical.com>