#!/bin/bash function print() { printf "\033[0;33m $1 \033[0m" } function println() { printf "\033[0;33m $1 \033[0m\n" } function printError() { printf "\033[0;31m $1 \033[0m\n" } function ask_open() { # The Captial letter is the default one printf "\033[0;33m $1 \033[0m" read -p " " REPLY /dev/null 2>&1;; darwin*) open $1;; *) printAlert "system not handle";; esac } function copyContentClipboard(){ case "$OSTYPE" in linux*) echo "$1" | xclip -selection c ;; darwin*) echo "$1" | pbcopy;; *) printAlert "system not handle";; esac } function getWorkingBranch () { RESULT=$(git branch --all --format='%(refname:short)') RESULT="${RESULT//origin\//}" selectAmongValues "${RESULT[@]}" } function setSymLinkFor() { ask_open "Path of the $1 ? (defualt is $2)" link_path=${REPLY:-$2} ln -s "$link_path" "$(pwd)/symlinks/$3" } if ! ask_yes_or_No "Did you add your ssh key on gihub ?" then keys=$(ls ~/.ssh/*.pub) if [ $? -eq 0 ]; then getExistingSSHKey else generateSSHKey fi println "Your public key is:" println "$RESULT" copyContentClipboard "$RESULT" println "Key copied in the clipboard!" question_ready_to "to open github settings" openLink https://github.com/settings/ssh/new fi REPO_URL=https://raw.githubusercontent.com/ghostwan/workspace-setup/master/ curl -fsSL $REPO_URL/stack.csv -o stack.csv if ask_yes_or_No "Do you want to install the full stack ?" then sh -c "$(curl -fsSL ${REPO_URL}scripts/stack)" else curl "${REPO_URL}scripts/stack" | bash -s -- -c base fi if ask_no_or_Yes "Do you want to clone the workspace ?" then read -p "Where do you want to clone the workspace ? (current directory): " path=$REPLY if [ -n "$path" ]; then println "Going to $path" eval cd $path fi println "Cloning workspace..." # Replace this repo by your own private workspace, this is my private gws config # This repo has a file .projects.gws that describe workspace tree # Each branch is a different configuration, master is the core one then I have: personal, work, doc # To know more about gws: https://github.com/StreakyCobra/gws git clone git@github.com:ghostwan/workspace.git cd workspace rm -f .cache.gws* getWorkingBranch git checkout $RESULT gws update else function goToWorkspace(){ read -p "Where is your workspace ? (current directory): " workspace_directory=$REPLY FILE=$workspace_directory/.projects.gws if [ ! -f $FILE ]; then printError "can't find workspace configuration! (.projects.gws)" goToWorkspace else cd $workspace_directory fi } goToWorkspace fi # Replace this part by your configuration # Finalize my workspace installation by configuring my apps as zsh, alfred, iterm ... # Import paid app licence and create symlink if ask_yes_or_No "Do you want to restore apps configuration ?" then # I cloned a repo named configs where I put all my app configs config_directory=$(pwd)"/configs" cd $config_directory println "Wich config branch do you want to use?" getWorkingBranch git checkout $RESULT sh init.sh fi