Mercurial > hg > revset-talk
changeset 1:d5300f96f9a2 draft
Add a Ctrl-l key
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Mon, 09 Sep 2013 11:36:49 -0400 |
parents | 685cb4aa66f7 |
children | e4f64c12923c |
files | sh-replay |
diffstat | 1 files changed, 13 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/sh-replay +++ b/sh-replay @@ -3,6 +3,9 @@ import os,sys,subprocess from colors import yellow, blue, magenta from sh import hg, cd +import sh + +curr_cmd = "" def getch(): import sys, tty, termios @@ -15,6 +18,12 @@ termios.tcsetattr(fd, termios.TCSADRAIN, old_settings) if ord(ch) == 3: sys.exit(0) + if ord(ch) == 12: + subprocess.call("reset") + print_prompt() + sys.stdout.write(curr_cmd) + sys.stdout.flush() + return ch def get_hg_id(): @@ -47,17 +56,20 @@ + magenta(hg_id, style="bold") + "$ ") def main(): + subprocess.call("reset") with open(sys.argv[1]) as f: cmds = [cmd.strip() for cmd in f.readlines() if cmd.strip() and not cmd.strip().startswith("#")] - + global curr_cmd for cmd in cmds: print_prompt() + curr_cmd = "" for c in cmd: key = getch() sys.stdout.write(c) sys.stdout.flush() + curr_cmd += c while True: key = getch()