demo screen
Sometimes you want to quickly share code scratch over the Internet. Usually you open services like pastebin or Github gist and get a link to your code from there. I want to share a really quick way to do this from your command line with a help of termbin.
Assuming you already have your file my_code.py and you want to share it. Just type

1
$ cat my_code.py | nc termbin.com 9999

and you’ll get an unique link to you code as an output of this command. Now you can share it with your friends or teammates.
For even better user experience you may add this command as one of your aliases like this

1
2
$ echo 'alias tb="nc termbin.com 9999"' >> .bashrc
$ exec $SHELL

In case you want the link to be copied to the clipboard you can improve command even more

1
2
3
$ sudo apt-get install xclip
$ echo 'alias tbc="nc termbin.com 9999 | xclip -selection clipboard"'
$ exec $SHELL

Examples of usage

1
2
3
4
5
# output link to your file in terminal
$ cat my_code.py | tb
# save link to your shared file into clipboard
$ cat my_code.py | tbc
$ echo "Test sharing some text data" | tbc

This small improvement to your shell is really handy and will be helpful to quickly share snippets with others.
Thanks for reading.