Created
July 12, 2022 22:39
-
-
Save henkin/f08f32ee5d8d5b205638d2a85adb95e4 to your computer and use it in GitHub Desktop.
addf - add function
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
:${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