[actionfiles]
repo="https://github.com/gbraad-dotfiles/actionfiles"
path="${HOME}/Projects/gbraad-dotfiles/actionfiles"actionfiles_list_names_and_descs() {
local actionpath="$1"
find -L "$actionpath" -type f -name '*.md' | sort | while IFS= read -r file; do
relpath="${file#$actionpath/}"
desc=$(grep -m1 '^# ' "$file" | sed 's/^# //')
printf "%s\t%s\n" "$relpath" "$desc"
done
}
actionfiles_pick() {
local chosen_target
local dir=$1
chosen_target=$(printf "%s\n" "$(actionfiles_list_names_and_descs $dir)" | column -t -s $'\t' | fzf --prompt="Choose actionfile> ")
chosen_target=$(echo "$chosen_target" | awk '{print $1}')
echo ${dir}/${chosen_target}
}[ -d ${ACTIONFILES_PATH} ]cd ${ACTIONFILES_PATH}git clone ${ACTIONFILES_REPO} ${ACTIONFILES_PATH}cd ${ACTIONFILES_PATH}
git pullif ! app ${APPNAME} exists; then
app ${APPNAME} checkout
fi
app ${APPNAME} aliasesalias dotfedora="run ${ACTIONFILES_PATH}/machine/dotfedora.md"actionfiles_pick $(pwd)actionfiles_pick ${ACTIONFILES_PATH}Generate aliases for Actionfiles that use an alias section
Note
Needs to run in interactive-mode to allow the aliases to be exported
actions_aliases() {
local actname actfile folder alias_name alias_cmd
if [[ $(dotini apps --get "apps.aliases") == true ]]; then
# Find all .md files in ACTIONFILES_PATH and subfolders
find "${ACTIONFILES_PATH}" -type f -name '*.md' | while read -r mdfile; do
actfile="${mdfile##*/}"
actname="${actfile%.md}"
folder="$(dirname "${mdfile}")"
folder="${folder##*/}"
if [[ "${folder}" == "$(basename "${ACTIONFILES_PATH}")" ]]; then
alias_name="${actname}"
alias_cmd="action ${ACTIONFILES_PATH}/${actfile}"
else
alias_name="${folder}-${actname}"
alias_cmd="action ${ACTIONFILES_PATH}/${folder}/${actfile}"
fi
if grep -E -q '^###.*\balias\b' "$mdfile"; then
alias "${alias_name}"="${alias_cmd}"
fi
done
fi
}
actions_aliases
unset FILENAME
unset APPNAME
unset TITLE