Created
June 29, 2015 19:36
-
-
Save xuru/e896b5cce865df57f142 to your computer and use it in GitHub Desktop.
smartcd buildout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [smartcd] | |
| recipe = mr.scripty | |
| install = | |
| ... import sys | |
| ... import os.path | |
| ... sys.path.insert(0, self.buildout['omelette']['location']) | |
| ... import pexpect | |
| ... | |
| ... script_dir = os.path.join( | |
| ... self.buildout['facts']['user.home'], '.smartcd/scripts', | |
| ... self.buildout['buildout']['directory']) | |
| ... | |
| ... if os.path.exists(os.path.join(script_dir + '.inode')): | |
| ... os.remove(os.path.join(script_dir + '.inode')) | |
| ... if os.path.exists(os.path.join(script_dir, 'bash_leave')): | |
| ... os.remove(os.path.join(script_dir, 'bash_leave')) | |
| ... if os.path.exists(os.path.join(script_dir, 'bash_enter')): | |
| ... os.remove(os.path.join(script_dir, 'bash_enter')) | |
| ... | |
| ... child = pexpect.spawn( | |
| ... '/bin/bash -c "curl -L http://smartcd.org/install > /tmp/install; source /tmp/install"', logfile=sys.stdout) | |
| ... done = False | |
| ... while not done: | |
| ... index = child.expect(['\[Y\/n\]', '\[y\/N\]', pexpect.EOF, pexpect.TIMEOUT]) | |
| ... if index == 0: | |
| ... child.sendline('Y') | |
| ... elif index == 1: | |
| ... child.sendline('N') | |
| ... elif index == 2: | |
| ... done = True | |
| ... elif index == 3: | |
| ... child.terminate(force=True) | |
| ... done = True | |
| ... if child.isalive(): | |
| ... child.wait() | |
| ... return [] | |
| [smartcd-config] | |
| recipe = cp.recipe.cmd | |
| on_install = true | |
| install_cmd = | |
| cd ${buildout:directory} | |
| source ~/.smartcd/lib/core/smartcd | |
| echo ". ${buildout:bin-directory}/activate; export PYTHONIOENCODING=utf_8" | smartcd edit enter | |
| echo "deactivate" | smartcd edit leave | |
| FILENAME="$HOME/.bash_profile" | |
| if grep ".smartcd_config" "$FILENAME" > /dev/null | |
| then | |
| echo "Smartcd is already in .bash_profile" | |
| else | |
| echo '[ -r "$HOME/.smartcd_config" ] && ( [ -n $BASH_VERSION ] || [ -n $ZSH_VERSION ] ) && source ~/.smartcd_config' >> $FILENAME | |
| fi | |
| find "$HOME/.smartcd" -type f \( -iname "*.inode" \) -exec rm -f {} \; | |
| update_cmd = ${smartcd-config:install_cmd} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment