-
-
Save deanturpin/2fc1bec5dfc7015e2be2b133713a91c0 to your computer and use it in GitHub Desktop.
Exploring the bash prompt
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
#!/bin/bash | |
# GNU bash, version 5.0.3(1)-release (x86_64-pc-linux-gnu) | |
# Some of these are a little tongue-in-cheek as an unresponsive prompt would be | |
# an annoying distraction. But still. This file should be sourcable to ensure | |
# individual commands can be pasted straight into the terminal. | |
# Uptime | |
PS1='$( | |
uptime | cut -d, -f1 | |
) \u@\h:\w $ ' | |
# Current IP address(es) | |
PS1='$( | |
hostname -I | |
) \u@\h:\w $ ' | |
# Epoch seconds (bash 5) | |
PS1='$EPOCHSECONDS \u@\h:\w $ ' | |
# SSID of current WiFi connection | |
PS1='$( | |
iwconfig |& grep -o "\".*\"" | |
) \u@\h:\w $ ' | |
# Bitcoin spot price | |
PS1='$( | |
curl --silent "https://min-api.cryptocompare.com/data/price?fsym=BTC&tsyms=USD" | grep -o "[0-9\.]*" | |
) \u@\h:\w $ ' | |
# GBP-EUR exchange rate | |
PS1='$( | |
curl --silent "https://min-api.cryptocompare.com/data/price?fsym=GBP&tsyms=EUR" | grep -o "[0-9\.]*" | |
) \u@\h:\w $ ' | |
# Value of your Ethereum wallet | |
PS1='$( | |
curl --silent gbp.rate.sx/0.01113750ETH | |
) \u@\h:\w $ ' | |
# Time from NIST - two versions: using netcat and /dev/tcp | |
PS1='$( | |
nc time.nist.gov 13 | cut -d" " -f3 | |
) \u@\h:\w $ ' | |
PS1='$( | |
cat </dev/tcp/time.nist.gov/13 | cut -d" " -f3 | |
) \u@\h:\w $ ' | |
# Public IP address | |
PS1='$( | |
curl --silent ifconfig.co | |
) \u@\h:\w $ ' | |
# Country associated with current IP address | |
PS1='$( | |
curl --silent ifconfig.co/country | |
) \u@\h:\w $ ' | |
# Examples to add | |
# Animations | |
# CPU load | |
# Google cloud status | |
# Network stats | |
# Display duration of previous command - see https://github.com/rcaloras/bash-preexec/issues/28 | |
# Right-aligned text - printf "%${COLUMNS}s\n" "hello" - https://superuser.com/questions/187455/right-align-part-of-prompt | |
# Trimming the prompt - https://zork.net//~st/jottings/How_to_limit_the_length_of_your_bash_prompt.html | |
# Rotating through different info each return | |
# Spot price diff exceeds standard deviation | |
# Do slow calculations as a background process | |
# Terminal Title Ticker | |
# References | |
# http://bashrcgenerator.com/ | |
# http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x405.html | |
# https://www.gnu.org/savannah-checkouts/gnu/bash/manual/bash.html | |
# http://tiswww.case.edu/php/chet/bash/NEWS | |
# https://www.cyberciti.biz/tips/howto-linux-unix-bash-shell-setup-prompt.html |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment