Alias_parameter

Why do I need to mkdir some_dir and then cd some_dir?

That’s the first thought. Then: ‘I make a script’.

But the script runs in another process. You can cd all you want.. but when the child-process exists and returns focus to the parent-process.. your current directory has not changed.

I have let xdotool send the commands to the terminal before. So that’s a way.

You can also use an alias.

But an alias doesn’t take parameters. But the alias can be a function. And the function takes parameters and alias will pass those to the function.

Like this:

alias mkcd='_mkcd () { mkdir "$1"; cd "$1"; }; _mkcd'

Now a mkcd some_dir will create the directory and then cd into it.

If the directory already exist, you’ll get a warning from the shell.. but the change of directory will still occur.