mirror of https://gitlab.com/meliurwen/dotfiles
Added GNU Screen with its zsh integration plugin, a simple plugin loader for zsh, a `syntax-highlighting` and `autosuggestions` zsh plugins loaded from system
parent
0c36d35d99
commit
adf0773fd7
@ -0,0 +1,67 @@ |
||||
#!/bin/sh |
||||
# Usage: ./battery.sh [--color [screen]] |
||||
|
||||
if [ "$1" = "--color" ]; then |
||||
case $2 in |
||||
"screen") |
||||
colgreen="\005{g}" |
||||
colyellow="\005{y}" |
||||
colred="\005{r}" |
||||
colred_blink="\005{+B r}" |
||||
colend="\005{-}" |
||||
;; |
||||
"") |
||||
colgreen="\033[0;32m" |
||||
colyellow="\033[0;33m" |
||||
colred="\033[0;31m" |
||||
colred_blink="\033[5;31m" |
||||
colend="\033[0m" |
||||
;; |
||||
*) |
||||
printf "Color coding not supported. Aborting...\n" |
||||
exit 1 |
||||
;; |
||||
esac |
||||
fi |
||||
|
||||
pwr_lvl="" |
||||
status="" |
||||
multi_bat=0 |
||||
for folder in /sys/class/power_supply/BAT?/; do |
||||
pwr_lvl="$(cat "$folder/capacity")" |
||||
pwr_stat="$(cat "$folder/status")" |
||||
if [ "$pwr_stat" = "Discharging" ]; then |
||||
status="%▼" |
||||
elif [ "$pwr_stat" = "Charging" ]; then |
||||
status="%▲" |
||||
elif [ "$pwr_stat" = "Not charging" ]; then |
||||
status="%~" |
||||
elif [ "$pwr_stat" = "Unknown" ]; then |
||||
status="%?" |
||||
else |
||||
status="%/" |
||||
fi |
||||
if [ "$1" = "--color" ]; then |
||||
# if: |
||||
# - <= 5 blinking red text |
||||
# - <= 10 red text |
||||
# - <= 20 yellow text |
||||
# - > 20 green |
||||
if [ "$pwr_lvl" -le 8 ]; then |
||||
color="${colred_blink}" |
||||
elif [ "$pwr_lvl" -le 20 ]; then |
||||
color="${colred}" |
||||
elif [ "$pwr_lvl" -le 40 ]; then |
||||
color="${colyellow}" |
||||
else |
||||
color="${colgreen}" |
||||
fi |
||||
fi |
||||
if [ $multi_bat = 1 ]; then |
||||
sep="|" |
||||
else |
||||
sep="" |
||||
multi_bat=1 |
||||
fi |
||||
printf "%b%s%s%b%s" "${color}" "${pwr_lvl}" "${status}" "${colend}" "${sep}" |
||||
done |
@ -0,0 +1,79 @@ |
||||
#!/bin/sh |
||||
# Usage: ./netinfo.sh [--color [screen]] |
||||
|
||||
if [ "$1" = "--color" ]; then |
||||
case $2 in |
||||
"screen") |
||||
colgreen="\005{g}" |
||||
colyellow="\005{y}" |
||||
colred="\005{r}" |
||||
colred_blink="\005{+B r}" |
||||
colend="\005{-}" |
||||
;; |
||||
"") |
||||
colgreen="\033[0;32m" |
||||
colyellow="\033[0;33m" |
||||
colred="\033[0;31m" |
||||
colred_blink="\033[5;31m" |
||||
colend="\033[0m" |
||||
;; |
||||
*) |
||||
printf "Color coding not supported. Aborting...\n" |
||||
exit 1 |
||||
;; |
||||
esac |
||||
fi |
||||
|
||||
wifi_str() { |
||||
wifi_signal="$(cat < /proc/net/wireless | grep "$1" | awk '{print $3}' | tr -d '.')" |
||||
bar="" |
||||
case $wifi_signal in |
||||
[0-1][0-9]) |
||||
color=${colred} |
||||
bar="▂___" |
||||
;; |
||||
[2-3][0-9]) |
||||
color=${colyellow} |
||||
bar="▂▄__" |
||||
;; |
||||
[4-5][0-9]) |
||||
color=${colgreen} |
||||
bar="▂▄▆_" |
||||
;; |
||||
[6-7][0-9]) |
||||
color=${colgreen} |
||||
bar="▂▄▆█" |
||||
;; |
||||
*) |
||||
color=${colred_blink} |
||||
bar="????" |
||||
;; |
||||
esac |
||||
printf "%b%s%b" "${color}" "${bar}" "${colend}" |
||||
} |
||||
|
||||
IFACES="$(ip link show | awk '/^[0-9]+:/ {sub(/:/,"",$2); print $2","$9}')" |
||||
|
||||
multi_ifce=0 |
||||
for NET_IFACE in $IFACES ; do |
||||
|
||||
[ "$(echo "$NET_IFACE" | cut -d ',' -f2)" = "DOWN" ] && continue |
||||
|
||||
device="$(echo "$NET_IFACE" | cut -d ',' -f1)" |
||||
case $device in |
||||
wlp*) |
||||
[ $multi_ifce = 1 ] && STR_OUT="$STR_OUT|" || multi_ifce="1" |
||||
STR_OUT="$STR_OUT$(wifi_str "$device")" |
||||
;; |
||||
enp*) |
||||
[ $multi_ifce = 1 ] && STR_OUT="$STR_OUT|" || multi_ifce="1" |
||||
STR_OUT="$STR_OUT$device" |
||||
;; |
||||
usb*) |
||||
[ $multi_ifce = 1 ] && STR_OUT="$STR_OUT|" || multi_ifce="1" |
||||
STR_OUT="$STR_OUT$device" |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
printf "%s" "${STR_OUT}" |
@ -0,0 +1,22 @@ |
||||
#!/bin/zsh |
||||
|
||||
# If the terminal is `screen` set a proper title and hardstatus |
||||
# See: https://gist.github.com/rampion/143727 |
||||
if [[ $TERM == "screen" || $TERM == "screen-256color" ]]; then |
||||
function print_precmdexec() { |
||||
local tilded_home="$(printf %s "$PWD" | sed "s|^$HOME|~|")" |
||||
# set hardstatus of tab window (%h) for screen |
||||
printf '\e]0;%s\a' "[$tilded_home]:$1" |
||||
# set the tab window title (%t) for screen |
||||
printf '\ek%s\e\\' "$2" |
||||
} |
||||
# called by zsh before executing a command |
||||
function preexec() { |
||||
local cmd=(${(z)1}) # the command string |
||||
print_precmdexec "$cmd" "$cmd[1]:t" |
||||
} |
||||
# called by zsh before showing the prompt |
||||
function precmd() { |
||||
print_precmdexec "$SHELL:t" "$SHELL:t" |
||||
} |
||||
fi |
@ -0,0 +1,28 @@ |
||||
#!/bin/screen -c |
||||
# ~/.screenrc |
||||
# Docs: https://www.gnu.org/software/screen/manual/ |
||||
|
||||
startup_message off |
||||
altscreen on |
||||
term screen-256color |
||||
|
||||
# Enables use of shift-PgUp and shift-PgDn |
||||
termcapinfo xterm*|rxvt*|kterm*|Eterm* ti@:te@ |
||||
|
||||
# Set the default size of the scrollback buffer for all windows |
||||
# Enter in copy mode `Ctrl+A [` and navigate with: PgUp/PgDn, arrows, vim keys |
||||
# or in some terminals also the mouse wheel |
||||
defscrollback 10000 |
||||
|
||||
# backtick id lifespan autorefresh cmd args... |
||||
backtick 1 10 10 $HOME/.config/screen/bin/battery.sh --color screen |
||||
backtick 2 10 10 $HOME/.config/screen/bin/netinfo.sh --color screen |
||||
|
||||
# Statusbar |
||||
hardstatus on |
||||
hardstatus alwayslastline |
||||
hardstatus string '%-Lw%?%E%{= ck}%:%{= mk}%? %n%f %t %{-}%+Lw%{= dd}%=%{b}%D %d %M %c%=%{K}[%{y}Avg: %l%{K}][%1`%{K}][%2`]' |
||||
|
||||
# Window captions |
||||
caption always |
||||
caption string '%?%F%{= gk}%:%{= wk}%? %n %?%F%{= Wk}%? %h%= ' |
Loading…
Reference in new issue