fast-files/ff
mintycube 00cf53931f Remove -v option and add ffv
Removes the -v argument and add script for verbose functionality
2024-04-22 15:06:34 +05:00

73 lines
2.4 KiB
Bash
Executable File

#!/usr/bin/env bash
#-----------------------------------------------------------------------------
# █▀▀ ▄▀█ █▀ ▀█▀ █▀▀ █ █ █▀▀ █▀
# █▀ █▀█ ▄█ █ █▀ █ █▄▄ ██▄ ▄█
#
# Usage: ff [path file or folder]
#
# Arguments: --help : prints usage info
# -h : prints usage info
#
# Description: Bash script which is a combination of 'mkdir' and 'touch'.
# It can create directory structures and files simultaneously.
#
# Dependencies: bash
#
# Examples: - Single file:
# ff file
# - Single directory:
# ff dir/
# - Multiple files:
# ff file1 file2 file3
# - Multiple directories:
# ff dir1/ dir2/ dir3/
# - File in a directory
# ff dir/file
# - Directory in a directory
# ff dir1/dir2/
# - Multiple files in multiple directories
# ff dir1/dir2/file1 dir3/file2
# - If your shell supports brace expansion e.g bash, zsh, fish
# ff dir1/{dir2/{file1,file2}.txt,dir3/file3.txt}
#-----------------------------------------------------------------------------
if [[ $# -eq 0 ]]; then
echo "No arguments provided"
echo "Usage: ff [path file or folder]"
echo "For more information, run: ff --help"
exit 1
fi
if [[ "$1" == "--help" || "$1" == "-h" ]]; then
echo "Usage: ff [path file or folder]"
echo "Examples: - Single file:
ff file
- Single directory:
ff dir/
- Multiple files:
ff file1 file2 file3
- Multiple directories:
ff dir1/ dir2/ dir3/
- File in a directory
ff dir/file
- Directory in a directory
ff dir1/dir2/
- Multiple files in multiple directories
ff dir1/dir2/file1 dir3/file2
- If your shell supports brace expansion e.g bash, zsh, fish
ff dir1/{dir2/{file1,file2}.txt,dir3/file3.txt}"
exit 0
fi
for path in "$@"; do
if [[ "$path" == */ ]]; then
mkdir -p "$path"
fi
parent_dir=$(dirname "$path")
if [[ -n "$parent_dir" ]] && [[ ! -d "$parent_dir" ]]; then
mkdir -p "$parent_dir"
fi
touch "$path"
done