def installIterm2(self): printInstallInfo("iTerm2") brewInstall("iterm2", cask=True) printer.info("» Setting Iterm2 to persist windows on exit") runCommandInShell( 'defaults write "com.googlecode.iterm2" "NSQuitAlwaysKeepsWindows" 1' )
def npmInstall(package): out = runCommandAndGetOutput("ls `npm root -g`") packages = out.stdout.decode().split("\n") if package in packages: print(Style.DIM, Fore.YELLOW, end="") print("NPM Package : {} is already installed".format(package) + Style.RESET_ALL) else: cmd = "npm install --global {}".format(package) runCommandInShell(cmd) # print(out)
def brewInstall(formula, cask = False): if cask == False: out = runCommandAndGetOutput("brew list --formula -1") else: out = runCommandAndGetOutput("brew list --cask -1") packages = out.stdout.decode().split("\n") if formula in packages: print(Style.DIM, Fore.YELLOW, end="") print("Brew Package : {} is already installed".format(formula) + Style.RESET_ALL) else: cmd = "" if cask == True: cmd = "brew cask install {}".format(formula) else: cmd = "brew install {}".format(formula) print("Installing Package") runCommandInShell(cmd)
def addSSHKey(self, email): sshFolder = Path.home().joinpath(".ssh") # Iterate to find a file name which is not already existing i = 1 fileName = "id_ed25519_{}".format(i) while sshFolder.joinpath(fileName).exists() == True: i += 1 fileName = "id_ed25519_{}".format(i) runCommandInShell( "ssh-keygen -t ed25519 -C '{}' -f ~/.ssh/{} -N ''".format( email, fileName)) publicKeyFile = "{}.pub".format(fileName) privateKeyPath = sshFolder.joinpath(fileName) publicKeyPath = sshFolder.joinpath(publicKeyFile) f = open(publicKeyPath, 'r') publicKey = f.readlines() return { "fileName": fileName, "filePath": privateKeyPath.resolve(), "publicKey": publicKey[0] }
def installOhMyZsh(self): printInstallInfo("Oh-My-Zsh") runCommandInShell( 'sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"' )
def setGitNameEmail(): runCommandInShell("git config --global user.name '{}'".format(GIT_NAME)) runCommandInShell("git config --global user.email '{}'".format(GIT_EMAIL))