oh-my-posh/themes/glowsticks.omp.yaml

198 lines
6.8 KiB
YAML
Raw Normal View History

2022-07-23 23:44:51 -07:00
# yaml-language-server: $schema=https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json
blocks:
- alignment: left
segments:
# Session
- background: p:black
foreground: p:white
invert_powerline: true
powerline_symbol:
style: powerline
template: "{{ .UserName }}@{{ .HostName }} "
type: session
# Path
- background: p:orange
foreground: p:white
powerline_symbol:
properties:
home_icon: ""
style: folder
style: powerline
template: "  {{ .Path }} "
type: path
# Git
- background: p:green
foreground: p:white
powerline_symbol:
properties:
script: |
BRANCH=$(git branch --show-current 2>/dev/null)
[[ -z $BRANCH ]] && exit
status=$(git status --porcelain | awk '{print $1}')
[[ $status == *"R"* ]] && bits+='>'
[[ $status == *"A"* ]] && bits+='+'
[[ $status == *"??"* ]] && bits+='?'
[[ $status == *"D"* ]] && bits+='x'
[[ $status == *"M"* ]] && bits+='!'
[[ "$(git rev-list --count "@{u}..")" -gt 0 ]] && bits+='*'
[[ -n $bits ]] && STAT="  $bits"
echo -n " $BRANCH$STAT"
shell: bash
style: powerline
template: " {{ .Output }} "
type: command
# Execution time
- background: p:darkred
foreground: p:white
powerline_symbol:
properties:
always_enabled: true
style: round
style: powerline
template: " 羽{{ .FormattedMs }} "
type: executiontime
# Exit code
- background: p:blue
background_templates:
- "{{ if gt .Code 0 }}p:red{{ end }}"
foreground: p:white
powerline_symbol:
properties:
always_enabled: true
style: diamond
template: " {{ if gt .Code 0 }} {{ .Meaning }}{{ else }}{{ end }} "
trailing_diamond:
type: exit
type: prompt
- alignment: right
segments:
# Shell
- background: p:black
foreground: p:white
style: plain
template: <p:black,transparent></> {{ .Name }}<transparent,p:black></>
type: shell
# Battery
- background_templates:
- '{{if eq "Charging" .State.String }}p:green{{end}}'
- '{{if eq "Discharging" .State.String}}p:orange{{end}}'
foreground: p:white
leading_diamond:
properties:
charged_icon:
charging_icon:
discharging_icon: " "
style: diamond
template: " {{.Templates }}{{ .Percentage}} <transparent></>"
templates:
- '{{if eq "Discharging" .State.String}}{{if lt .Percentage 11}}{{else if lt .Percentage 21}}{{else if lt .Percentage 31}}{{else if lt .Percentage 41}}{{else if lt .Percentage 51}}{{else if lt .Percentage 61}}{{else if lt .Percentage 71}}{{else if lt .Percentage 81}}{{else if lt .Percentage 91}}{{else}}{{end}}{{end}}'
- '{{if eq "Charging" .State.String}}{{ if lt .Percentage 21}}{{else if lt .Percentage 31}}{{else if lt .Percentage 41}}{{else if lt .Percentage 61}}{{else if lt .Percentage 81}}{{else if lt .Percentage 91}}{{else}}{{end}}{{end}}'
templates_logic: first_match
type: battery
# Weather & time of day
- background: p:blue
foreground: p:white
leading_diamond:
properties:
script: |
api_key="$OWM_API_KEY" # change this
location='$LOCATION' # change this (or dont, and set the variable in your env)
set -e
now="$(date +'%I:%M%P')"
if [[ -f /tmp/weather.w && $NO_WEATHER_CACHE -ne 1 ]]; then
update=$(jq '.minute' /tmp/weather.w | tr -d '"')
# refresh every ten minutes
if [[ $(bc -l <<<"$(date +'%M')<=($update+10)") -eq 1 ]]; then
echo "$now" "$(jq .weather /tmp/weather.w | tr -d '"')" && exit 0
fi
2022-07-23 23:44:51 -07:00
fi
gurl="curl -Gsm.7 https://api.openweathermap.org"
enc="--data-urlencode"
# get location
[[ ! -f /tmp/location.w ]] &&
$gurl/geo/1.0/direct $enc "q=$location" $enc "limit=0" $enc "appid=$api_key" | jq -c '{"lat": .[0].lat, "lon": .[0].lon}' >/tmp/location.w
location="$(cat /tmp/location.w)"
# get weather
res=$($gurl/data/2.5/weather $enc "lat=$(jq .lat <<<"$location")" $enc "lon=$(jq .lon <<<"$location")" $enc "units=metric" $enc "appid=$api_key")
temp=$(jq .main.temp <<<"$res")
temp_min=$(jq .main.temp_min <<<"$res")
temp_max=$(jq .main.temp_max <<<"$res")
[[ $(bc -l <<<"$temp_min!=$temp") -eq 1 ]] && temp_min_s="$temp_min-"
[[ $(bc -l <<<"$temp_max==$temp") -eq 1 ]] && temp_s="$temp_min_s$temp°C" || temp_s+="(${temp_min}${temp}-${temp_max})°C"
feels_like=$(jq .main.feels_like <<<"$res")
[[ $(bc -l <<<"$feels_like!=$temp_min&&$feels_like!=$temp&&$feels_like!=$temp_max") -eq 1 ]] && feels_string="feels $feels_like°C"
# pick weather icon
case $(jq .weather[0].icon <<<"$res" | tr -d '"') in
01n | 01d)
icon='\ufa98'
;;
02n | 02d)
icon='\ufa94'
;;
03n | 03d)
icon='\ue33d'
;;
04n | 04d)
icon='\ue312'
;;
09n | 09d)
icon='\ufa95'
;;
10n | 10d)
icon='\ue308'
;;
11n | 11d)
icon='\ue31d'
;;
13n | 13d)
icon='\ue31a'
;;
50n | 50d)
icon='\ue313'
;;
*)
icon=''
;;
esac
weather="$icon - $temp_s $feels_string"
echo -e "$now $weather"
echo -e "{\"minute\": \"$(date +'%M')\", \"weather\": \"$weather\"}" >/tmp/weather.w
2022-07-23 23:44:51 -07:00
style: diamond
template: "{{ .Output }}"
trailing_diamond:
type: command
type: rprompt
final_space: true
2022-07-31 04:32:17 -07:00
console_title_template:  {{ .Shell }} in {{ if ne .Folder "~"}} {{ .Folder }}{{else}}{{end}}
2022-07-23 23:44:51 -07:00
palette:
black: "#33395b"
blue: "#359ddd"
darkred: "#7c0a16"
green: "#277b48"
orange: "#ff972e"
red: "#de3142"
white: "#efeef4"
secondary_prompt:
background: transparent
foreground: p:white
template: " "
transient_prompt:
background: transparent
foreground: p:white
template: " "
version: 2