Skip to content

Instantly share code, notes, and snippets.

@atalazer
Created September 26, 2021 03:04
Show Gist options
  • Save atalazer/b488801fe82c60637de34f0ba2321caa to your computer and use it in GitHub Desktop.
Save atalazer/b488801fe82c60637de34f0ba2321caa to your computer and use it in GitHub Desktop.
Better way to create file or directory.
#!/bin/sh
# ad
# Better way to create file or directory.
# Inspired by:
# - https://github.com/tanrax/terminal-AdvancedNewFile
# - https://github.com/NNBnh/mk
ad() {
mkfile() {
case "$1" in
*"/")
mkdir -p "$1"
;;
*)
mkdir -p "$(dirname "$1")"
touch "$1"
;;
esac
}
for file in "$@"; do
mkfile "$file"
done
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment