Created
December 26, 2024 04:45
-
-
Save yeiichi/1cd955cd10f0aa85538399b1eb79d280 to your computer and use it in GitHub Desktop.
Opens ./meetings/yyyymmddHHMM/index.rst with Vim.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
my_name=$(basename "$0") | |
display_help() { | |
echo usage: "${my_name}" | |
} | |
main() { | |
printf "*** Opens ./meetings/yyyymmddHHMM/index.rst with Vim. ***\n" | |
printf "\033[93mMeeting Date?(yyyymmdd) >> \033[0m" | |
read -r mtg_date | |
# Find candidate directories | |
dirs=$(find ./meetings -type d -maxdepth 1 -name "${mtg_date}*") | |
num_of_dirs=$(echo "${dirs}" | wc -l) | |
# Specify a single file path. | |
if [[ "${num_of_dirs}" -ne 1 ]]; then | |
{ | |
printf "\033[93mStart Time?(HHMM) >> \033[0m" | |
read -r start_time | |
fpath="${mtg_date}${start_time}"/index.rst | |
} | |
else | |
fpath="${dirs}"/index.rst | |
fi | |
# Check the target_rst file. | |
[[ ! -f "${fpath}" ]] && echo 'No match found.' && exit | |
# Open the target file with vim. | |
echo "Opening ${fpath}..." | |
sleep 3 | |
vim "${fpath}" | |
} | |
main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment