me.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #-*- coding: UTF-8 -*-
  2. import sys, os, readline
  3. # define Color
  4. Green = '\033[32m'; Red = '\033[31m'
  5. GreenBG = '\033[42;37m'; RedBG = '\033[41;37m'
  6. Yellow = '\033[0;33m'; SkyBlue = '\033[0;36m'; Font = '\033[0m'
  7. sys.ps1 = Red + '>' + Yellow + '>' + SkyBlue + '> ' + Font
  8. sys.ps2 = SkyBlue + '... ' + Font
  9. def cls():
  10. # print('\x1bc')
  11. os.system('clear')
  12. def pwd():
  13. print( SkyBlue + os.getcwd(), end = ' ')
  14. def ls():
  15. cur_path = os.getcwd()
  16. os.system('ls -l ' + cur_path)
  17. pwd()
  18. def cd(path = '.'):
  19. os.chdir(path)
  20. pwd()
  21. def cat(file = 'me.py'):
  22. with open(file, 'r') as f:
  23. print(f.read())
  24. def bash():
  25. os.system('bash')
  26. def history():
  27. for i in range(readline.get_current_history_length()):
  28. print(readline.get_history_item(i + 1))
  29. print( Yellow + ':: Clear_History: readline.clear_history() ')
  30. def info():
  31. print( SkyBlue + ':: Usage: ' + Green + 'python -i me.py' + Yellow + ' or [import me] , import the module me.py')
  32. print( Green + ':: Function: cls() ls() cd(path) cat(file) pwd() bash() info() history()')
  33. pwd()
  34. info(); c = cls; h = history