I am trying to create a Terminal command. I have created this so far:
cd ~/ && touch .bash_profile && echo "" >> .bash_profile && echo "alias sendtext=\"osascript -e 'on run argv' -e 'tell application \\\"Messages\\\"' -e 'set myid to get id of first service' -e 'set address to item 1 of argv' -e 'set message to item 2 of argv' -e 'set receiver to buddy address of service id myid' -e 'send message to receiver' -e 'end tell' -e 'end run'\"" >> .bash_profile && echo "alias sendtext-remove=\"cd ~/ && grep -vwE \\\"(sendtext|sendtext-remove)\\\" .bash_profile > .bash_profile && . .bash_profile\"" >> .bash_profile && . .bash_profile
It creates two commands:
- sendtext [email] [message] (Sends a text message to email)
- sendtext-remove (Removes the two lines from the .bash_profile)
The problem is that after I run sendtext-remove
, I can still run send text
. How can I update the .bash_profile without opening a new Terminal window?
sed
instead)sed
? (I want to remove the lines that contain my script)