forked from strom/dotfiles
Remove path delimiter from word matching
This commit is contained in:
parent
078d0cf0e3
commit
a7318c8fbd
5 changed files with 48 additions and 47 deletions
|
@ -334,6 +334,13 @@ unsetopt histsavebycopy
|
|||
# }}}
|
||||
|
||||
# Widgets and OSC {{{
|
||||
|
||||
# Word matching
|
||||
# Remove path delimiter from word matching
|
||||
autoload -Uz select-word-style
|
||||
WORDCHARS=$WORDCHARS:s:/:
|
||||
select-word-style normal
|
||||
|
||||
# Set path as window title using to_status_line/from_status_line if available
|
||||
if ((${+terminfo[fsl]} && ${+terminfo[tsl]})); then
|
||||
window-title() {
|
||||
|
|
35
scripts/bin/dwd/dwd
Executable file
35
scripts/bin/dwd/dwd
Executable file
|
@ -0,0 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
# shellcheck source=../../lib/common.sh
|
||||
source "${0%/*}/../share/dotfiles/lib/common.sh" || exit 1
|
||||
|
||||
if ! _has_all_emit jq curl; then
|
||||
exit 1
|
||||
fi
|
||||
if (($# < 1)); then
|
||||
_die "Please provide a station id, see: https://www.dwd.de/DE/leistungen/klimadatendeutschland/statliste/statlex_html.html?view=nasPublication&nn=16102"
|
||||
fi
|
||||
|
||||
station=$1
|
||||
|
||||
forecast_to_stdout() {
|
||||
local endpoint='https://dwd.api.proxy.bund.dev/v30/stationOverviewExtended'
|
||||
local station=$1
|
||||
if ! curl --silent --location --request 'GET' --header 'accept: application/json' "${endpoint}?stationIds=${station}"; then
|
||||
_die 'Could not retrieve data from endpoint.'
|
||||
fi
|
||||
}
|
||||
|
||||
IFS='@' read -r temp timestamp \
|
||||
< <(forecast_to_stdout "$station" \
|
||||
| jq -r --arg station "$station" \
|
||||
'[.[$station].forecast1.temperature[0] / 10, (.[$station].forecast1.start / 1000 | strflocaltime("%c"))] | map(@text) | join("@")' 2>/dev/null)
|
||||
|
||||
if [[ -z $temp || -z $timestamp ]]; then
|
||||
_die "Got empty or invalid response."
|
||||
fi
|
||||
|
||||
printf "%sºC (%s)\n" "$temp" "$timestamp"
|
||||
|
||||
# vi: set ft=sh ts=4 sw=0 sts=-1 sr noet nosi tw=80 fdm=manual:
|
|
@ -1,8 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
for cmd in delta bat "less -FRX" cat; do
|
||||
if command -v ${cmd%% *} >/dev/null 2>&1; then
|
||||
exec $cmd "$@"
|
||||
break
|
||||
fi
|
||||
if command -v "${cmd%% *}" >/dev/null 2>&1; then
|
||||
exec $cmd "$@"
|
||||
fi
|
||||
done
|
||||
|
||||
# vi: set ft=sh ts=4 sw=0 sts=-1 sr noet nosi tw=80 fdm=manual:
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
# shellcheck shell=bash
|
||||
|
||||
# If you source this file, it will set wttr_params as well as show weather.
|
||||
|
||||
# wttr_params is space-separated URL parameters, many of which are single characters that can be
|
||||
# lumped together. For example, "F q m" behaves the same as "Fqm".
|
||||
_wttr_param() {
|
||||
declare -a wttr_params
|
||||
if [[ ! -v wttr_params[@] ]]; then
|
||||
# Form localized URL parameters for curl
|
||||
if [[ -t 1 ]] && [[ "$(tput cols)" -lt 125 ]]; then
|
||||
wttr_params+=('n')
|
||||
fi 2>/dev/null
|
||||
|
||||
for tok in $(locale LC_MEASUREMENT); do
|
||||
case $tok in
|
||||
1) wttr_params+=('m') ;;
|
||||
2) wttr_params+=('u') ;;
|
||||
esac
|
||||
done 2>/dev/null
|
||||
wttr_params+=('F')
|
||||
fi
|
||||
echo "${wttr_params[*]}"
|
||||
}
|
||||
|
||||
wttr() {
|
||||
local location=${1// /+}
|
||||
local param
|
||||
param=$(_wttr_param)
|
||||
command shift
|
||||
local -a args
|
||||
for p in $param "$@"; do
|
||||
args+=('--data-urlencode' "$p")
|
||||
done
|
||||
|
||||
curl -fGsS -H "Accept-Language: ${LANG%_*}" "${args[@]}" --compressed "http://wttr.in/${location}"
|
||||
}
|
||||
|
||||
wttr "$@"
|
||||
|
||||
# vi: set ft=sh ts=4 sw=0 sts=-1 sr noet nosi tw=80 fdm=manual:
|
|
@ -24,7 +24,7 @@ _has_oneof() {
|
|||
|
||||
_has_emit() {
|
||||
if ! _has "$1"; then
|
||||
msg "$1" 'not found in PATH'
|
||||
_msg "$1" 'not found in PATH'
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue