Full command line as it was typed

后端 未结 8 2068
猫巷女王i
猫巷女王i 2020-12-01 20:56

I want to get the full command line as it was typed.

This:

\" \".join(sys.argv[:])

doesn\'t work here (deletes double quotes). Also I pr

8条回答
  •  暖寄归人
    2020-12-01 21:28

    If you're on Linux, I'd suggest monkeying with the ~/.bash_history file or the shell history command, although I believe the command must finish executing before it's added to the shell history.

    I started playing with:

    import popen2
    x,y = popen2.popen4("tail ~/.bash_history")
    print x.readlines()
    

    But I'm getting weird behavior where the shell doesn't seem to be completely flushing to the .bash_history file.

提交回复
热议问题