Skip to content

Instantly share code, notes, and snippets.

@nicokoelewijn
Last active January 19, 2019 11:22
Show Gist options
  • Save nicokoelewijn/888f194a520b7277fc815adca3e78120 to your computer and use it in GitHub Desktop.
Save nicokoelewijn/888f194a520b7277fc815adca3e78120 to your computer and use it in GitHub Desktop.
OSX - Create login item via terminal
# Creating the scripts directory
DIR=$HOME"/scripts"
if [ ! -d "$DIR" ]; then
mkdir ~/scripts
fi
read -p "Script name: " FILE
echo "Creating script: $FILE!"
FILEPATH=$DIR"/"$FILE
touch $FILEPATH
read -p "command to execute:" EXEC
echo "using script:"
echo $EXEC
echo "#!/bin/sh" > $FILEPATH
echo $EXEC >> $FILEPATH
chmod 755 $FILEPATH
osascript -e 'tell application "System Events" to make login item at end with properties {name: "'$FILE'", path:"'$FILEPATH'", hidden:false}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment