Posted in bash

Make and Change into Directory

Several times a day I have to create a directory and have immediately change into this directory. After a while I found it rather annoying to type every time

$ mkdir new_directory
$ cd new_directory

So I created a shell function to reduce the typing:

mcd ()
    mkdir -p "$@" && cd "$@"

Now I have to type only

$ mcd new_directory

and magically I’m in the newly created directory.

Posted in bash

Make a Directory with Actual Date

For different workflows I like to have directories with the actual date as name. To this end I created a little bash function called mkdd (make date directory), which I put into my .bashrc:

mkdd ()
    D=$(date '+%F')
    mkdir $D
    cd $D

This function creates the directory with the actual date in ISO format and changes into it:

$ pwd
$ mkdd
$ pwd