Share Your Shell 'Plugins' #70
Replies: 8 comments 5 replies
-
I'll get things kicked off with a couple simple outputs I've been using :) Unread e-mail indicator
As you can see, it's for my work inbox, but could probably quite easily be switched out to evaluate Current Kubernetes context/namespace
Where #! /usr/bin/env bash
CONTEXT=$(kubectl config current-context)
NAMESPACE=$(kubectl config view --minify --output 'jsonpath={..namespace}')
echo "${CONTEXT}:${NAMESPACE}"
|
Beta Was this translation helpful? Give feedback.
-
Current track information from
|
Beta Was this translation helpful? Give feedback.
-
CPU Utilization: Config:
Script:
|
Beta Was this translation helpful? Give feedback.
-
Keyboard Language: Config:
Script:
That being said, it would be helpful to have a "force spacebar to update" function as there is a severe delay, the shell script running only every 5 seconds |
Beta Was this translation helpful? Give feedback.
-
Wifi SSID and speed network.sh
spacebarrc
|
Beta Was this translation helpful? Give feedback.
-
I wrote script for checking Wi-Fi signal quality (RSSI / Noise) :
|
Beta Was this translation helpful? Give feedback.
-
I wrote a quick python script for collecting the current bitcoin price and the 24 hours percentage change from Coinmarketcap. However, it requires that you python3 installation has bs4 and requests.
#!/usr/bin/env python3
from bs4 import BeautifulSoup
import requests
import json
import sys
fiat = 'BTC'
if len(sys.argv) > 1:
fiat = sys.argv[1]
if fiat.lower() == 'eth':
cur = 1
idx = '1027'
else:
cur = 0
idx = '1'
url = 'https://coinmarketcap.com/currencies/bitcoin'
cmc = requests.get(url)
soup = BeautifulSoup(cmc.content, 'html.parser')
data = soup.find('script', id='__NEXT_DATA__', type='application/json')
data = json.loads(data.contents[0])
crypt_data = data['props']['initialState']['cryptocurrency']['quotes'][idx]
percentChange = crypt_data['fmc24hpc']
price = crypt_data['p']
# percentChangeFormat = '<span color="{}">{}{:.2f}%</span>'
percentChangeFormat = '{}{:.2f}%'
precision = 2
if percentChange > 0:
# percentChangeInfo = percentChangeFormat.format('#3BB92D', '', percentChange)
percentChangeInfo = percentChangeFormat.format('', percentChange)
elif percentChange == 0:
# percentChangeInfo = percentChangeFormat.format('#CCCCCC', '', percentChange)
percentChangeInfo = percentChangeFormat.format('', percentChange)
else:
# percentChangeInfo = percentChangeFormat.format('#F7555E', '', percentChange)
percentChangeInfo = percentChangeFormat.format('', -percentChange)
print(('${:.' + str(precision) + 'f} {}').format(price, percentChangeInfo)) # Full Text |
Beta Was this translation helpful? Give feedback.
-
Here's a script to display the Current State of the Music App and/or current track information. It could use some tweaking particularly for long titles. It's kind of sloppy, but it works pretty well. If anyone knows if there's a way to dynamically update the icon that would be great. MUSIC_INFO=$(osascript <<EOF
on titleCase(theString)
set UpperFirstCharString to do shell script "echo " & character 1 of theString & " | tr [:lower:] [:upper:]"
set theString to UpperFirstCharString & characters 2 through -1 of theString
return theString
end titleCase
on appRunning(appName)
if application appName is running then
return true
else
return false
end if
end appRunning
on musicPlaying()
tell application "Music"
set playerState to (get player state) as text
end tell
if playerState is "paused" then
set stateIcon to " "
else if playerState is "stopped" then
set stateIcon to " "
else if playerState is "playing" then
set stateIcon to " "
end if
if playerState is not "stopped" then
return {true, titleCase(playerState), stateIcon}
else
return {false, titleCase(playerState), stateIcon}
end if
end musicPlaying
on getTrackInfo()
set appRunning to appRunning("Music")
set musicPlaying to musicPlaying()
if appRunning is true then
if item 1 of musicPlaying is true then
tell application "Music"
set info to get {name, artist, album} of current track
return "" & item 3 of musicPlaying & " " & item 1 of info & " x " & item 2 of info & " - " & item 3 of info
end tell
else
return item 3 of musicPlaying & " Music Stopped "
end if
else
return " Music App Not Running "
end if
end getTrackInfo
getTrackInfo()
EOF
)
printf "$MUSIC_INFO" |
Beta Was this translation helpful? Give feedback.
-
🐚
Got something cool working with spacebar's
shell
options? 😎 Share the config and/or script!Want to implement something but you're not quite sure how? 🤔 Go ahead and ask!
Note: Providing more of these "slots" is planned for a future release
Beta Was this translation helpful? Give feedback.
All reactions