daviddwlee84 / DevEnvPack

Bring my development environment everywhere. vim, tmux, bash, zsh, VSCode, docker, and so on.
1 stars 0 forks source link

shell function #26

Open daviddwlee84 opened 3 years ago

daviddwlee84 commented 3 years ago

https://unix.stackexchange.com/questions/305844/how-to-create-a-file-and-parent-directories-in-one-command https://stackoverflow.com/questions/6212219/passing-parameters-to-a-bash-function

touch_create () {
    # Create file with its parent folders
    # https://unix.stackexchange.com/questions/305844/how-to-create-a-file-and-parent-directories-in-one-command
    # https://stackoverflow.com/questions/6212219/passing-parameters-to-a-bash-function
    file=$1
    mkdir -p "${file%/*}" && touch "$file"
}