Skip to content

Instantly share code, notes, and snippets.

@jumbosushi
Last active January 21, 2019 06:26
Show Gist options
  • Save jumbosushi/d4b7a1105845d4719e454a9bb583980a to your computer and use it in GitHub Desktop.
Save jumbosushi/d4b7a1105845d4719e454a9bb583980a to your computer and use it in GitHub Desktop.
Automate UBC CS server git auth
#!/usr/bin/expect -f
# Steps to add it to your server:
# 1. Create autopass.sh in your home dir
# $ touch ~/autopass.sh
# 2. Change file permission of the file
# $ chmod 777 ~/autopass.sh
# 3. Add alias in your .bashrc (or .zshrc if you're using zsh)
# $ echo 'alias ap="~/autopass"' > ~/.bashrc
# 4. Reload your shell
# $ bash
# 5. Command is ready to use!
#
# The script can accept commands up to four arguments
# All of the followings are valid:
# $ ap git push origin master
# $ ap git pull origin
# $ ap git fetch origin
set cmd [lindex $argv 0];
set arg1 [lindex $argv 1];
set arg2 [lindex $argv 2];
set arg3 [lindex $argv 3];
set arg4 [lindex $argv 4];
spawn $cmd $arg1 $arg2 $arg3 $arg4
expect "Username for 'https://stash.ugrad.cs.ubc.ca:8443'"
send "<CS_USERNAME>\r"
expect "Password for 'https://<CS_USERNAME>@stash.ugrad.cs.ubc.ca:8443'"
send "<CS_PASSWORD>\r"
expect eof
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment