Fast way to share code snippet from terminal
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
$ 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
$ echo 'alias tb="nc termbin.com 9999"' >> .bashrc
In case you want the link to be copied to the clipboard you can improve command even more
$ sudo apt-get install xclip
Examples of usage
# output link to your file in terminal
This small improvement to your shell is really handy and will be helpful to quickly share snippets with others.
Thanks for reading.