Skip to content

Instantly share code, notes, and snippets.

View deanturpin's full-sized avatar
:octocat:

Dean Turpin deanturpin

:octocat:
View GitHub Profile
@deanturpin
deanturpin / newline-chomp
Last active June 14, 2019 08:57
Ways to chomp a newline in bash
head -c -1
tr "\n" " "
echo -n $(<command>)
xargs echo -n
[[ $(<command>) =~ <regex> ]] && echo -n $BASH_REMATCH
@deanturpin
deanturpin / PS1
Last active November 11, 2021 00:06
Exploring the bash prompt
#!/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='$(
@deanturpin
deanturpin / cpu-prompt.sh
Last active August 6, 2019 19:11
CPU load in your bash prompt - source this script
cpu-status-string(){
# Create some colours
idle="\u001b[32m"
low="\u001b[36m"
medium="\u001b[33m"
high="\u001b[31m"
reset="\u001b[0m"
# Extract CPU info from top