コード例 #1
0
ファイル: setup.py プロジェクト: brainysmurf/pydir
    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')
コード例 #2
0
ファイル: Tutorial.py プロジェクト: brainysmurf/pydir
 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))
コード例 #3
0
ファイル: Dir.py プロジェクト: brainysmurf/pydir
 def _drop(self, command):
     """ drop to the shell and back again """
     get_front_app().keystroke("{};{};{}\n".format(
             "drop", command, "dir"))
コード例 #4
0
ファイル: Menu.py プロジェクト: brainysmurf/pydir
 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()