Skip to content

Instantly share code, notes, and snippets.

@henkin
Created July 12, 2022 22:39
Show Gist options
  • Save henkin/f08f32ee5d8d5b205638d2a85adb95e4 to your computer and use it in GitHub Desktop.
Save henkin/f08f32ee5d8d5b205638d2a85adb95e4 to your computer and use it in GitHub Desktop.
addf - add function
:${1?addf name 'body'}
func_filename="$FUNCS/$1"
func_body=$2
if [[ -f $func_filename ]];
then
echo "Existing found:"
highlight $func_filename --syntax bash
read -q "REPLY?Overwrite existing function?"
fi
echo "$func_body" > $func_filename
printf "adding $BYellow${func_filename}$Color_Off function: $BYellow${func_body}$Color_Off\n"
rr # reload functions
read -q "REPLY?Edit in 'code'?"
code ${func_filename}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment