def run(self): _install.run(self) version = "{}.{}".format(sys.version_info.major, sys.version_info.minor) the_path = "/Library/Frameworks/Python.framework/Versions/{}/bin".format(version) shutil.copy('scripts/dir', the_path) first_line = '# pydir (version {0}) application modifying your bash profile starting here:\n#DO NOT MODIFY'.format(dir_version) user_bash_profile = os.path.expanduser('~/.bash_profile') if not os.path.exists(user_bash_profile): open(user_bash_profile, 'w') # touch with open(user_bash_profile) as f: user_profile = f.readlines() if not first_line in user_profile: with open(os.path.expanduser('~/.bash_profile'), 'a') as f: f.write('\n') f.write(first_line) f.write('\ntouch /tmp/tee_output.txt\n') f.write("""alias drop='cd "`cat /tmp/tee_output.txt| tail -2 | perl -ne "chomp and print"`"'""") f.write('\nPATH="{}:${}"'.format(the_path, '{PATH}')) f.write("\nexport PATH") f.write("\n#end dir modification\n") print("Success") print() print("You may now launch dir program anytime by typing 'dir' at the console prompt") yesno = input("Would you like to launch it now with the tutorial? (y/n): ") if yesno.lower() == 'y': from AppleScriptWrapper.Basic import get_front_app get_front_app().keystroke('dir -tutorial\n')
def _drop(self, command): """ drop to the shell and back again """ get_front_app().keystroke("drop;{};dir -tutorial {}\n".format(command, self.cntrl.tutor_info.where))
def _drop(self, command): """ drop to the shell and back again """ get_front_app().keystroke("{};{};{}\n".format( "drop", command, "dir"))
def drop(self, *args): """ Exits and puts the resulting shell in the same as the current directory """ get_front_app().keystroke('drop\n') self.cntrl.stop()