by BiteCode_dev · 4y ago · 0 comments
my() {
script_name="$1"
script_path="$HOME/.local/bin/my/$script_name"
shift
$script_path "$@"
}
So you have your namespace ? Of course that mean you must put all script in .local/bin, not anywhere in the PATH, and some more work is needed to figure out completion.But it seems less weird than the comma.
-- EDIT --
With completion:
export MY_SCRIPS_DIR="$HOME/.local/bin/my"
_my_completions() {
if [ "${#COMP_WORDS[@]}" != "2" ]; then
return
fi
COMPREPLY=($(compgen -W "$(echo $(find "$MY_SCRIPS_DIR" -printf '%P\n' ))"))
}
my() {
script_name="$1"
script_path="$MY_SCRIPS_DIR/$script_name"
shift
$script_path "$@"
}
complete -F _my_completions my
-- EDIT 2 --After testing both, the comma win. Kiss, more flexible.
No comments yet.