Skip to content

Instantly share code, notes, and snippets.

@jhuttner
Created June 7, 2011 19:06
Show Gist options
  • Save jhuttner/1012911 to your computer and use it in GitHub Desktop.
Save jhuttner/1012911 to your computer and use it in GitHub Desktop.
Store last command to mac buffer
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