Skip to content

Instantly share code, notes, and snippets.

@jenrzzz
Created August 1, 2019 23:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jenrzzz/7e59240afda1bfff109888e7c5d709ac to your computer and use it in GitHub Desktop.
Save jenrzzz/7e59240afda1bfff109888e7c5d709ac to your computer and use it in GitHub Desktop.
Realize the sun doesn't go down — it's just an illusion CAUSED by the WORLD spinning 'ROUND
try
if !empty($LIGHT_MODE)
set background=light
colorscheme PaperColor
let g:airline_theme='papercolor'
else
set background=dark
colorscheme jellybeans
let g:airline_theme = 'jellybeans'
endif
catch /^Vim\%((\a\+)\)\=:E185/
set background=dark
colorscheme elflord
endtry
function whereami {
curl --silent https://freegeoip.app/csv/ | awk -F, 'BEGIN { OFS="," }; { print $9, $10 }'
}
function sunrise-sunset {
local day=$(date "+%Y-%m-%d")
local cache_path="${HOME}/.solar-schedule/${day}"
if [[ -s "$cache_path" ]]; then
cat "$cache_path"
else
IFS=, read lat long < <(whereami)
curl --silent "https://api.sunrise-sunset.org/json?lat=$lat&lng=$long&date=$day&formatted=0" | jq -r '.results | "\(.sunrise),\(.sunset)"' | tee "$cache_path"
fi
}
function is-daytime {
sunrise-sunset | ruby -r date -e 'daytime = Range.new(*STDIN.read.split(",").map {|d| DateTime.parse(d).to_time }); exit 1 unless daytime.include?(Time.now)'
}
function is-dark-mode {
[[ $(defaults read -g AppleInterfaceStyle 2>/dev/null || echo 'Light') == "Dark" ]]
}
function vim {
if is-daytime && ! is-dark-mode; then
viml "$@"
else
vimd "$@"
fi
}
alias vimd="/usr/local/bin/vim"
alias viml="LIGHT_MODE=y /usr/local/bin/vim"
set timeOfDay to do shell script "bash -c 'source functions.sh; is-daytime && ! is-dark-mode && echo daytime || echo nighttime'"
tell application "iTerm"
if (timeOfDay = "daytime") then
create window with profile "Light"
else if (timeOfDay = "nighttime") then
create window with profile "Night"
end if
end tell
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment