Created
June 7, 2011 19:06
-
-
Save jhuttner/1012911 to your computer and use it in GitHub Desktop.
Store last command to mac buffer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PUT AS TWO SEPARATE SCRIPTS: store.sh, and store.py. | |
USAGE: ./store.sh | |
#/!bin/bash | |
echo "Wait...." | |
history > /tmp/store | |
/home/jhuttner/store.py | |
cat /tmp/store2 | pbcopy | |
echo "Complete!" | |
#!/usr/local/bin/python | |
def main(): | |
fobj = open('/tmp/store') | |
back_one = back_two = '' | |
while 1: | |
curr_line = fobj.readline() | |
if not curr_line: | |
fobj2 = open('/tmp/store2', 'w') | |
fobj2.write(back_two.strip().lstrip(' 0123456789')) | |
fobj2.close() | |
fobj.close() | |
break | |
else: | |
back_two = back_one | |
back_one = curr_line | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment