DEV Community

Cover image for Can you focus on work when owning Bitcoin?
Viorel PETCU
Viorel PETCU

Posted on

Can you focus on work when owning Bitcoin?

If you are here I am guessing that you too jumped on the bitcoin train and that's why you consume anything you can find on the subject, including this article. Yeah, you and me too, I got roped in after seeing this tweet from Elon Musk:


Because bitcoin is so volatile and valuable (for the moment) you can have huge swings within hours and if you want to do some trading during those peaks and valleys you inevitably get into constantly checking websites or some live ticker app, or worse, you might even have push notifications enabled ... so you end up in distraction hell, just ask Elon.

TL;DR version

Can you focus on work when owning Bitcoin?

YES you can!

Just take away all the unnecessary convoluted, distracting and time consuming steps.

OK, so what did I do to remove this distraction?

I made the conversion rate between BTC and EUR visible in my BASH prompt because, of course I did, I always have at least one instance open ( and probably so do you ):


This allows me to have the information in the corner of my eye, bare bones with no distraction. I don't have any cognitive effort and I don't switch the context.

To do this, I wrote a few lines of SHELL script and with it I can configure my prompt to display whatever I need:

  • how much is my current portfolio worth?
  • how much is X amount worth? (when buying / selling)
  • it's extensible to other crypto currencies
  • it's easy to setup
  • anyone can pick up where I left off

The long(er) version

I tagged this article ( at least the hands on part ) as intermediate, assuming that you know the concepts used to build this:

  • what the .bashrc file is
  • how the $PS1 environment variable is constructed
  • how to use the curl command
  • how to use the bc command
  • shell scripring

Step 1 - teaching BASH a new trick

Extend the .bashrc file (or any other file that your BASH consumes when starting up):

mbtc () 
    KEUR=$(curl -s '')
    MINE="${1}" # amount of BTC you want to monitor
    CALC=$(echo "scale=3; $MINE/$KEUR" | bc -q)
    echo "${CALC}k €"
Enter fullscreen mode Exit fullscreen mode

Now your linux knows a new "command" called mbtc that accepts a parameter, this is the amount of BTC you want converted into KILO EUROS or k €


By adjusting the value parameter from the curl GET call to the public API you can transform other quantities, just be careful to adjust the calculation string that is later passed to bc

Step 2 - start BTC/EUR monitoring

Check your current $PS1 variable value:

echo $PS1


Create a file with the amount of BTC you want to monitor in your prompt:

echo "0.1234" > ~/btc.count

Now redefine the PS1 variable also by editing the ~/.bashrc file, by adding a subshell call inside of the existing prompt:

($(mbtc $(cat ~/btc.count)))


What next ?

Now you can rest assured, you will always know the up to date value of a Bitcoin or any other amount you want to monitor, just write the value in the ~/btc.count


Of course these concepts work just as well with any other shell implementation, you just need to edit the corresponding equivalent files.

All that is left for me to do is to wish you happy monitoring! Let me know if you were able to use this or if you were able to enhance or build something completely new on top of this.

#staysafe #peace #coderforever


Top comments (1)

emx2anuel profile image

Now is the perfect time to have this since the price is all over the place.