Compare commits

..

7 Commits

Author SHA1 Message Date
Dario Ernst 584af1bfd1 Batch commit
3 years ago
Dario Ernst 221bc281d4 Lots of changes
4 years ago
Dario Ernst 4f60aa8662 Zsh install
5 years ago
Dario Ernst b01e0c1b83 zsh
5 years ago
Dario Ernst 83b67821ec Various changes
5 years ago
Dario Ernst a4ccac03ab Add zsh config
5 years ago
Dario Ernst 36a99b19e4 Various changes
5 years ago

1
.gitignore vendored

@ -1 +0,0 @@
i3/config

File diff suppressed because it is too large Load Diff

@ -1,867 +0,0 @@
#!/usr/bin/env bash
#
# Written by Denilson Figueiredo de Sá <denilsonsa@gmail.com>
# MIT license
#
# Requirements:
# * bash (tested on 4.20, should work on older versions too)
# * awk (works with GNU awk, nawk, busybox awk, mawk)
# * ping (from iputils)
#
# More information:
# http://denilsonsa.github.io/prettyping/
# https://github.com/denilsonsa/prettyping
# http://www.reddit.com/r/linux/comments/1op98a/prettypingsh_a_better_ui_for_watching_ping/
# Third-party demonstration video: https://www.youtube.com/watch?v=ziEMY1BcikM
# TODO: Adjust how many items in the legend are printed based on the terminal width.
#
# TODO: Detect the following kinds of message and avoid printing it repeatedly.
# From 192.168.1.11: icmp_seq=4 Destination Host Unreachable
# Request timeout for icmp_seq 378
#
# TODO: Handle when a single message is spread over multiple lines. Specially,
# like in this case: https://bitbucket.org/denilsonsa/small_scripts/issue/5
#
# TODO: Print the destination (also) at the bottom bar. Useful after leaving
# the script running for quite some time.
#
# TODO: Print the destination as escape codes to xterm title.
#
# TODO: Print the current time in the beginning of each line.
#
# TODO: Implement audible ping.
#
# TODO: Autodetect the width of printf numbers, so they will always line up correctly.
#
# TODO: Test the behavior of this script upon receiving out-of-order packets, like these:
# http://www.blug.linux.no/rfc1149/pinglogg.txt
#
# TODO? How will prettyping behave if it receives a duplicate response?
print_help() {
cat << EOF
Usage: $MYNAME [prettyping parameters] <standard ping parameters>
This script is a wrapper around the system's "ping" tool. It will substitute
each ping response line by a colored character, giving a very compact overview
of the ping responses.
prettyping parameters:
--[no]color Enable/disable color output. (default: enabled)
--[no]multicolor Enable/disable multi-color unicode output. Has no effect if
either color or unicode is disabled. (default: enabled)
--[no]unicode Enable/disable unicode characters. (default: enabled)
--[no]legend Enable/disable the latency legend. (default: enabled)
--[no]terminal Force the output designed to a terminal. (default: auto)
--last <n> Use the last "n" pings at the statistics line. (default: 60)
--columns <n> Override auto-detection of terminal dimensions.
--lines <n> Override auto-detection of terminal dimensions.
--rttmin <n> Minimum RTT represented in the unicode graph. (default: auto)
--rttmax <n> Maximum RTT represented in the unicode graph. (default: auto)
--awkbin <exec> Override the awk interpreter. (default: awk)
--pingbin <exec> Override the ping tool. (default: ping)
-6 Shortcut for: --pingbin ping6
ping parameters handled by prettyping:
-a Audible ping is not implemented yet.
-f Flood mode is not allowed in prettyping.
-q Quiet output is not allowed in prettyping.
-R Record route mode is not allowed in prettyping.
-v Verbose output seems to be the default mode in ping.
All other parameters are passed directly to ping.
EOF
}
# Thanks to people at #bash who pointed me at
# http://bash-hackers.org/wiki/doku.php/scripting/posparams
parse_arguments() {
USE_COLOR=1
USE_MULTICOLOR=1
USE_UNICODE=1
USE_LEGEND=1
if [ -t 1 ]; then
IS_TERMINAL=1
else
IS_TERMINAL=0
fi
LAST_N=60
OVERRIDE_COLUMNS=0
OVERRIDE_LINES=0
RTT_MIN=auto
RTT_MAX=auto
PING_BIN="ping"
#PING_BIN="./mockping.awk"
PING_PARAMS=( )
AWK_BIN="awk"
AWK_PARAMS=( )
while [[ $# != 0 ]] ; do
case "$1" in
-h | -help | --help )
print_help
exit
;;
# Forbidden ping parameters within prettyping:
-f )
echo "${MYNAME}: You can't use the -f (flood) option."
exit 1
;;
-R )
# -R prints extra information at each ping response.
echo "${MYNAME}: You can't use the -R (record route) option."
exit 1
;;
-q )
echo "${MYNAME}: You can't use the -q (quiet) option."
exit 1
;;
-v )
# -v enables verbose output. However, it seems the output with
# or without this option is the same. Anyway, prettyping will
# strip this parameter.
;;
# Note:
# Small values for -s parameter prevents ping from being able to
# calculate RTT.
# New parameters:
-a )
# TODO: Implement audible ping for responses or for missing packets
;;
-color | --color ) USE_COLOR=1 ;;
-nocolor | --nocolor ) USE_COLOR=0 ;;
-multicolor | --multicolor ) USE_MULTICOLOR=1 ;;
-nomulticolor | --nomulticolor ) USE_MULTICOLOR=0 ;;
-unicode | --unicode ) USE_UNICODE=1 ;;
-nounicode | --nounicode ) USE_UNICODE=0 ;;
-legend | --legend ) USE_LEGEND=1 ;;
-nolegend | --nolegend ) USE_LEGEND=0 ;;
-terminal | --terminal ) IS_TERMINAL=1 ;;
-noterminal | --noterminal ) IS_TERMINAL=0 ;;
-awkbin | --awkbin ) AWK_BIN="$2" ; shift ;;
-pingbin | --pingbin ) PING_BIN="$2" ; shift ;;
-6 ) PING_BIN="ping6" ;;
#TODO: Check if these parameters are numbers.
-last | --last ) LAST_N="$2" ; shift ;;
-columns | --columns ) OVERRIDE_COLUMNS="$2" ; shift ;;
-lines | --lines ) OVERRIDE_LINES="$2" ; shift ;;
-rttmin | --rttmin ) RTT_MIN="$2" ; shift ;;
-rttmax | --rttmax ) RTT_MAX="$2" ; shift ;;
* )
PING_PARAMS+=("$1")
;;
esac
shift
done
if [[ "${RTT_MIN}" -gt 0 && "${RTT_MAX}" -gt 0 && "${RTT_MIN}" -ge "${RTT_MAX}" ]] ; then
echo "${MYNAME}: Invalid --rttmin and -rttmax values."
exit 1
fi
if [[ "${#PING_PARAMS[@]}" = 0 ]] ; then
echo "${MYNAME}: Missing parameters, use --help for instructions."
exit 1
fi
# Workaround for mawk:
# http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=593504
local version="$(echo | "${AWK_BIN}" -W version 2>&1)"
if [[ "${version}" == mawk* ]] ; then
AWK_PARAMS+=(-W interactive)
fi
}
MYNAME=`basename "$0"`
parse_arguments "$@"
export LC_ALL=C
# Warning! Ugly code ahead!
# The code is so ugly that the comments explaining it are
# bigger than the code itself!
#
# Suppose this:
#
# cmd_a | cmd_b &
#
# I need the PID of cmd_a. How can I get it?
# In bash, $! will give me the PID of cmd_b.
#
# So, I came up with this ugly solution: open a subshell, like this:
#
# (
# cmd_a &
# echo "This is the PID I want $!"
# wait
# ) | cmd_b
# Ignore Ctrl+C here.
# If I don't do this, this shell script is killed before
# ping and gawk can finish their work.
trap '' 2
# Now the ugly code.
(
"${PING_BIN}" "${PING_PARAMS[@]}" &
PING_PID="$!"
# Commented out, because it looks like this line is not needed
#trap "kill -2 $PING_PID ; exit 1" 2 # Catch Ctrl+C here
wait
) 2>&1 | (
if [ "${IS_TERMINAL}" = 1 ]; then
# Print a message to notify the awk script about terminal size change.
trap "echo SIGWINCH" 28
fi
# The trap must be in another subshell because otherwise it will interrupt
# the "wait" commmand.
while read line; do
echo -E "$line"
done
) 2>&1 | "${AWK_BIN}" "${AWK_PARAMS[@]}" '
# Weird that awk does not come with abs(), so I need to implement it.
function abs(x) {
return ( (x < 0) ? -x : x )
}
# Ditto for ceiling function.
function ceil(x) {
return (x == int(x)) ? x : int(x) + 1
}
# Local variables MUST be declared in argument list, else they are
# seen as global. Ugly, but that is how awk works.
function get_terminal_size(SIZE, SIZEA, HAS_DETECTED, CMD) {
HAS_DETECTED = 0
CMD = "stty -f /dev/tty size 2> /dev/null"
if ( (CMD | getline SIZE) == 1 ) {
split(SIZE, SIZEA, " ")
LINES = int(SIZEA[1])
COLUMNS = int(SIZEA[2])
HAS_DETECTED = 1
}
close(CMD)
if ( HAS_DETECTED == 0 ) {
CMD = "tput lines"
if ( (CMD | getline SIZE) == 1 ) {
LINES = int(SIZE)
HAS_DETECTED = 1
}
close(CMD)
CMD = "tput cols"
if ( (CMD | getline SIZE) == 1 ) {
COLUMNS = int(SIZE)
HAS_DETECTED = 1
}
close(CMD)
}
if ( int('"${OVERRIDE_COLUMNS}"') ) { COLUMNS = int('"${OVERRIDE_COLUMNS}"') }
if ( int('"${OVERRIDE_LINES}"') ) { LINES = int('"${OVERRIDE_LINES}"') }
}
############################################################
# Functions related to cursor handling
# Function called whenever a non-dotted line is printed.
#
# It will move the cursor to the line next to the statistics and
# restore the default color.
function other_line_is_printed() {
if ( IS_PRINTING_DOTS ) {
if ( '"${IS_TERMINAL}"' ) {
printf( ESC_DEFAULT ESC_NEXTLINE ESC_NEXTLINE "\n" )
} else {
printf( ESC_DEFAULT "\n" )
print_statistics_bar()
}
}
IS_PRINTING_DOTS = 0
CURR_COL = 0
}
# Function called whenever a non-dotted line is repeated.
function other_line_is_repeated() {
if ( other_line_times < 2 ) {
return
}
if ( '"${IS_TERMINAL}"' ) {
printf( ESC_DEFAULT ESC_ERASELINE "\r" )
}
printf( "Last message repeated %d times.", other_line_times )
if ( ! '"${IS_TERMINAL}"' ) {
printf( "\n" )
}
}
# Function called whenever the repeating line has changed.
function other_line_finished_repeating() {
if ( other_line_times >= 2 ) {
if ( '"${IS_TERMINAL}"' ) {
printf( "\n" )
} else {
other_line_is_repeated()
}
}
other_line = ""
other_line_times = 0
}
# Prints the newlines required for the live statistics.
#
# I need to print some newlines and then return the cursor back to its position
# to make sure the terminal will scroll.
#
# If the output is not a terminal, break lines on every LAST_N dots.
function print_newlines_if_needed() {
if ( '"${IS_TERMINAL}"' ) {
# COLUMNS-1 because I want to avoid bugs with the cursor at the last column
if ( CURR_COL >= COLUMNS-1 ) {
CURR_COL = 0
}
if ( CURR_COL == 0 ) {
if ( IS_PRINTING_DOTS ) {
printf( "\n" )
}
#printf( "\n" "\n" ESC_PREVLINE ESC_PREVLINE ESC_ERASELINE )
printf( ESC_DEFAULT "\n" "\n" ESC_CURSORUP ESC_CURSORUP ESC_ERASELINE )
}
} else {
if ( CURR_COL >= LAST_N ) {
CURR_COL = 0
printf( ESC_DEFAULT "\n" )
print_statistics_bar()
}
}
IS_PRINTING_DOTS = 1
}
############################################################
# Functions related to the data structure of "Last N" statistics.
# Clears the data structure.
function clear(d) {
d["index"] = 0 # The next position to store a value
d["size"] = 0 # The array size, goes up to LAST_N
}
# This function stores the value to the passed data structure.
# The data structure holds at most LAST_N values. When it is full,
# a new value overwrite the oldest one.
function store(d, value) {
d[d["index"]] = value
d["index"]++
if ( d["index"] >= d["size"] ) {
if ( d["size"] < LAST_N ) {
d["size"]++
} else {
d["index"] = 0
}
}
}
############################################################
# Functions related to processing the received response
function process_rtt(rtt) {
# Overall statistics
last_rtt = rtt
total_rtt += rtt
if ( last_seq == 0 ) {
min_rtt = max_rtt = rtt
} else {
if ( rtt < min_rtt ) min_rtt = rtt
if ( rtt > max_rtt ) max_rtt = rtt
}
# "Last N" statistics
store(lastn_rtt,rtt)
}
function lost_a_packet() {
print_newlines_if_needed()
print_missing_response()
last_seq++
lost++
store(lastn_lost, 1)
}
############################################################
# Functions related to printing the fancy ping response
# block_index, n, w are just local variables.
function print_response_legend(i, n, w) {
if ( ! '"${USE_LEGEND}"' ) {
return
}
if ( BLOCK_LEN > 1 ) {
# w counts the cursor position in the current line. Because of the
# escape codes, I need to jump through some hoops in order to count the
# position correctly.
w = 0
n = "0 "
w += length(n) + 1
printf( n BLOCK[0] ESC_DEFAULT )
for ( i=1 ; i<BLOCK_LEN ; i++ ) {
n = sprintf( "%d ", BLOCK_RTT_MIN + ceil((i-1) * BLOCK_RTT_RANGE / (BLOCK_LEN - 2)) )
w += length(n) + 1
# Avoid breaking the legend at the end of the line.
# Also avoids a background color change right at
# the edge of the screen. (If it happens, the entire next line
# will have that background color, which is not desired.)
if ( '"${IS_TERMINAL}"' && w + 1 >= COLUMNS ) {
printf( "\n" )
w = length(n) + 1
} else {
printf( " " )
w += 1
}
printf( n BLOCK[i] ESC_DEFAULT )
}
printf( " ∞\n" )
}
# Useful code for debugging.
#for ( i=0 ; i<=BLOCK_RTT_MAX ; i++ ) {
# print_received_response(i)
# printf( ESC_DEFAULT "%4d\n", i )
#}
}
# block_index is just a local variable.
function print_received_response(rtt, block_index) {
if ( rtt < BLOCK_RTT_MIN ) {
block_index = 0
} else if ( rtt >= BLOCK_RTT_MAX ) {
block_index = BLOCK_LEN - 1
} else {
block_index = 1 + int((rtt - BLOCK_RTT_MIN) * (BLOCK_LEN - 2) / BLOCK_RTT_RANGE)
}
printf( BLOCK[block_index] )
CURR_COL++
}
function print_missing_response(rtt) {
printf( ESC_RED "!" )
CURR_COL++
}
############################################################
# Functions related to printing statistics
# All arguments are just local variables.
function print_overall(percentage_lost, avg_rtt) {
# Handling division by zero.
# Note that mawk does not consider division by zero an error, while all
# other awk implementations abort in such case.
# https://stackoverflow.com/questions/14581966/why-does-awk-produce-different-results-for-division-by-zero
avg_rtt = ( received > 0 ) ? (total_rtt/received) : 0
percentage_lost = ( lost+received > 0 ) ? (lost*100/(lost+received)) : 0
if ( '"${IS_TERMINAL}"' ) {
printf( "%2d/%3d (%2d%%) lost; %4.0f/" ESC_BOLD "%4.0f" ESC_DEFAULT "/%4.0fms; last: " ESC_BOLD "%4.0f" ESC_DEFAULT "ms",
lost,
lost+received,
percentage_lost,
min_rtt,
avg_rtt,
max_rtt,
last_rtt )
} else {
printf( "%2d/%3d (%2d%%) lost; %4.0f/" ESC_BOLD "%4.0f" ESC_DEFAULT "/%4.0fms",
lost,
lost+received,
percentage_lost,
min_rtt,
avg_rtt,
max_rtt )
}
}
# All arguments are just local variables.
function print_last_n(i, percentage_lost, sum, min, avg, max, diffs) {
# Calculate and print the lost packets statistics
sum = 0
for ( i=0 ; i<lastn_lost["size"] ; i++ ) {
sum += lastn_lost[i]
}
percentage_lost = (lastn_lost["size"] > 0) ? (sum*100/lastn_lost["size"]) : 0
printf( "%2d/%3d (%2d%%) lost; ",
sum,
lastn_lost["size"],
percentage_lost )
# Calculate the min/avg/max rtt times
sum = diffs = 0
min = max = lastn_rtt[0]
for ( i=0 ; i<lastn_rtt["size"] ; i++ ) {
sum += lastn_rtt[i]
if ( lastn_rtt[i] < min ) min = lastn_rtt[i]
if ( lastn_rtt[i] > max ) max = lastn_rtt[i]
}
avg = (lastn_rtt["size"]) ? (sum/lastn_rtt["size"]) : 0
# Calculate mdev (mean absolute deviation)
for ( i=0 ; i<lastn_rtt["size"] ; i++ ) {
diffs += abs(lastn_rtt[i] - avg)
}
if ( lastn_rtt["size"] > 0 ) {
diffs /= lastn_rtt["size"]
}
# Print the rtt statistics
printf( "%4.0f/" ESC_BOLD "%4.0f" ESC_DEFAULT "/%4.0f/%4.0fms (last %d)",
min,
avg,
max,
diffs,
lastn_rtt["size"] )
}
function print_statistics_bar() {
if ( '"${IS_TERMINAL}"' ) {
printf( ESC_SAVEPOS ESC_DEFAULT )
printf( ESC_NEXTLINE ESC_ERASELINE )
print_overall()
printf( ESC_NEXTLINE ESC_ERASELINE )
print_last_n()
printf( ESC_UNSAVEPOS )
} else {
print_overall()
printf( "\n" )
print_last_n()
printf( "\n" )
}
}
function print_statistics_bar_if_terminal() {
if ( '"${IS_TERMINAL}"' ) {
print_statistics_bar()
}
}
############################################################
# Initializations
BEGIN {
# Easy way to get each value from ping output
FS = "="
############################################################
# General internal variables
# This is needed to keep track of lost packets
last_seq = 0
# The previously printed non-ping-response line
other_line = ""
other_line_times = 0
# Variables to keep the screen clean
IS_PRINTING_DOTS = 0
CURR_COL = 0
############################################################
# Variables related to "overall" statistics
received = 0
lost = 0
total_rtt = 0
min_rtt = 0
max_rtt = 0
last_rtt = 0
############################################################
# Variables related to "last N" statistics
LAST_N = int('"${LAST_N}"')
# Data structures for the "last N" statistics
clear(lastn_lost)
clear(lastn_rtt)
############################################################
# Terminal height and width
# These are sane defaults, in case we cannot query the actual terminal size
LINES = 24
COLUMNS = 80
# Auto-detecting the terminal size
get_terminal_size()
if ( '"${IS_TERMINAL}"' && COLUMNS <= 50 ) {
print "Warning: terminal width is too small."
}
############################################################
# ANSI escape codes
# Color escape codes.
# Fortunately, awk defaults any unassigned variable to an empty string.
if ( '"${USE_COLOR}"' ) {
ESC_DEFAULT = "\033[0m"
ESC_BOLD = "\033[1m"
#ESC_BLACK = "\033[0;30m"
#ESC_GRAY = "\033[1;30m"
ESC_RED = "\033[0;31m"
ESC_GREEN = "\033[0;32m"
ESC_YELLOW = "\033[0;33m"
ESC_BLUE = "\033[0;34m"
ESC_MAGENTA = "\033[0;35m"
ESC_CYAN = "\033[0;36m"
ESC_WHITE = "\033[0;37m"
ESC_YELLOW_ON_GREEN = "\033[42;33m"
ESC_RED_ON_YELLOW = "\033[43;31m"
}
# Other escape codes, see:
# http://en.wikipedia.org/wiki/ANSI_escape_code
# http://invisible-island.net/xterm/ctlseqs/ctlseqs.html
ESC_NEXTLINE = "\n"
ESC_CURSORUP = "\033[A"
ESC_CURSORDOWN = "\033[B"
ESC_SCROLLUP = "\033[S"
ESC_SCROLLDOWN = "\033[T"
ESC_ERASELINEEND = "\033[0K"
ESC_ERASELINE = "\033[2K"
ESC_SAVEPOS = "\0337"
ESC_UNSAVEPOS = "\0338"
# I am avoiding these escapes as they are not listed in:
# http://vt100.net/docs/vt100-ug/chapter3.html
#ESC_PREVLINE = "\033[F"
#ESC_SAVEPOS = "\033[s"
#ESC_UNSAVEPOS = "\033[u"
# I am avoiding this to improve compatibility with (older versions of) tmux
#ESC_NEXTLINE = "\033[E"
############################################################
# Unicode characters (based on https://github.com/holman/spark )
if ( '"${USE_UNICODE}"' ) {
BLOCK[ 0] = ESC_GREEN "▁"
BLOCK[ 1] = ESC_GREEN "▂"
BLOCK[ 2] = ESC_GREEN "▃"
BLOCK[ 3] = ESC_GREEN "▄"
BLOCK[ 4] = ESC_GREEN "▅"
BLOCK[ 5] = ESC_GREEN "▆"
BLOCK[ 6] = ESC_GREEN "▇"
BLOCK[ 7] = ESC_GREEN "█"
BLOCK[ 8] = ESC_YELLOW_ON_GREEN "▁"
BLOCK[ 9] = ESC_YELLOW_ON_GREEN "▂"
BLOCK[10] = ESC_YELLOW_ON_GREEN "▃"
BLOCK[11] = ESC_YELLOW_ON_GREEN "▄"
BLOCK[12] = ESC_YELLOW_ON_GREEN "▅"
BLOCK[13] = ESC_YELLOW_ON_GREEN "▆"
BLOCK[14] = ESC_YELLOW_ON_GREEN "▇"
BLOCK[15] = ESC_YELLOW_ON_GREEN "█"
BLOCK[16] = ESC_RED_ON_YELLOW "▁"
BLOCK[17] = ESC_RED_ON_YELLOW "▂"
BLOCK[18] = ESC_RED_ON_YELLOW "▃"
BLOCK[19] = ESC_RED_ON_YELLOW "▄"
BLOCK[20] = ESC_RED_ON_YELLOW "▅"
BLOCK[21] = ESC_RED_ON_YELLOW "▆"
BLOCK[22] = ESC_RED_ON_YELLOW "▇"
BLOCK[23] = ESC_RED_ON_YELLOW "█"
if ( '"${USE_MULTICOLOR}"' && '"${USE_COLOR}"' ) {
# Multi-color version:
BLOCK_LEN = 24
BLOCK_RTT_MIN = 10
BLOCK_RTT_MAX = 230
} else {
# Simple version:
BLOCK_LEN = 8
BLOCK_RTT_MIN = 25
BLOCK_RTT_MAX = 175
}
} else {
BLOCK[ 0] = ESC_GREEN "_"
BLOCK[ 1] = ESC_GREEN "."
BLOCK[ 2] = ESC_GREEN "o"
BLOCK[ 3] = ESC_GREEN "O"
BLOCK[ 4] = ESC_YELLOW "_"
BLOCK[ 5] = ESC_YELLOW "."
BLOCK[ 6] = ESC_YELLOW "o"
BLOCK[ 7] = ESC_YELLOW "O"
BLOCK[ 8] = ESC_RED "_"
BLOCK[ 9] = ESC_RED "."
BLOCK[10] = ESC_RED "o"
BLOCK[11] = ESC_RED "O"
if ( '"${USE_MULTICOLOR}"' && '"${USE_COLOR}"' ) {
# Multi-color version:
BLOCK_LEN = 12
BLOCK_RTT_MIN = 20
BLOCK_RTT_MAX = 220
} else {
# Simple version:
BLOCK_LEN = 4
BLOCK_RTT_MIN = 75
BLOCK_RTT_MAX = 225
}
}
if ( int('"${RTT_MIN}"') > 0 && int('"${RTT_MAX}"') > 0 ) {
BLOCK_RTT_MIN = int('"${RTT_MIN}"')
BLOCK_RTT_MAX = int('"${RTT_MAX}"')
} else if ( int('"${RTT_MIN}"') > 0 ) {
BLOCK_RTT_MIN = int('"${RTT_MIN}"')
BLOCK_RTT_MAX = BLOCK_RTT_MIN * (BLOCK_LEN - 1)
} else if ( int('"${RTT_MAX}"') > 0 ) {
BLOCK_RTT_MAX = int('"${RTT_MAX}"')
BLOCK_RTT_MIN = int(BLOCK_RTT_MAX / (BLOCK_LEN - 1))
}
BLOCK_RTT_RANGE = BLOCK_RTT_MAX - BLOCK_RTT_MIN
print_response_legend()
}
############################################################
# Main loop
{
if ( $0 ~ /^[0-9]+ bytes from .*: icmp_[rs]eq=[0-9]+ ttl=[0-9]+ time=[0-9.]+ *ms/ ) {
# Sample line from ping:
# 64 bytes from 8.8.8.8: icmp_seq=1 ttl=49 time=184 ms
if ( other_line_times >= 2 ) {
other_line_finished_repeating()
}
# $1 = useless prefix string
# $2 = icmp_seq
# $3 = ttl
# $4 = time
# This must be called before incrementing the last_seq variable!
rtt = int($4)
process_rtt(rtt)
seq = int($2)
while ( last_seq < seq - 1 ) {
lost_a_packet()
}
# Received a packet
print_newlines_if_needed()
print_received_response(rtt)
# In case of receiving multiple responses with the same seq number, it
# is better to use "last_seq = seq" than to increment last_seq.
last_seq = seq
received++
store(lastn_lost, 0)
print_statistics_bar_if_terminal()
} else if ( $0 ~ /^.*onnected to.*, seq=[0-9]+ time=[0-9.]+ *ms/ ) {
# Sample line from httping:
# connected to 200.149.119.168:80 (273 bytes), seq=0 time=129.86 ms
if ( other_line_times >= 2 ) {
other_line_finished_repeating()
}
seq = $0
sub(/.* seq=/, "", seq)
seq = int(seq)
rtt = $0
sub(/.* time=/, "", rtt)
rtt = int(rtt)
process_rtt(rtt)
while ( last_seq < seq - 1 ) {
lost_a_packet()
}
# Received a packet
print_newlines_if_needed()
print_received_response(rtt)
# In case of receiving multiple responses with the same seq number, it
# is better to use "last_seq = seq" than to increment last_seq.
last_seq = seq
received++
store(lastn_lost, 0)
print_statistics_bar_if_terminal()
} else if ( $0 == "" ) {
# Do nothing on blank lines.
} else if ( $0 == "error shutting down ssl" ) {
# Common error message when using httping, ignore it.
} else if ( $0 ~ /^Request timeout for icmp_seq [0-9]+/ ) {
# Reply timeout is printed on Mac OS X.
if ( other_line_times >= 2 ) {
other_line_finished_repeating()
}
lost_a_packet()
# Making sure the last_seq number is correct.
gsub(/.* icmp_seq /, "")
seq = int($0)
last_seq = seq
print_newlines_if_needed()
print_statistics_bar_if_terminal()
} else if ( $0 ~ /^SIGWINCH$/ ) {
get_terminal_size()
if ( IS_PRINTING_DOTS ) {
if ( CURR_COL >= COLUMNS-1 ) {
# Not enough space anyway.
} else {
# Making up room in case the number of lines has changed.
printf( ESC_NEXTLINE ESC_NEXTLINE ESC_CURSORUP ESC_CURSORUP )
# Moving to the correct column and erasing the rest of the line.
printf( "\033[" (CURR_COL+1) "G" ESC_DEFAULT ESC_ERASELINEEND )
}
print_newlines_if_needed()
print_statistics_bar_if_terminal()
}
} else {
other_line_is_printed()
original_line = $0
gsub(/icmp_seq[= ][0-9]+/, "")
if ( $0 == other_line ) {
other_line_times++
if ( '"${IS_TERMINAL}"' ) {
other_line_is_repeated()
}
} else {
other_line_finished_repeating()
other_line = $0
other_line_times = 1
printf( "%s\n", original_line )
}
}
# Not needed when the output is a terminal, but does not hurt either.
fflush()
}'

@ -0,0 +1 @@
config-laptoparbeit

@ -56,7 +56,8 @@ font pango:monospace 8
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec kitty --single-instance
#bindsym $mod+Return exec kitty --single-instance
bindsym $mod+Return exec xfce4-terminal
# start chromium
bindsym $mod+BackSpace exec /home/dario/firefox/firefox
@ -175,9 +176,9 @@ bindsym $mod+F4 exec sh ~/config/susp.sh
# TODO: debug
# bindsym $mod+F12 exec xfce4-terminal --drop-down
# bindsym $mod+y exec xfce4-terminal --drop-down
exec_always --no-startup-id /home/dario/.local/bin/kitti3 -n bubblegum -p top
bindsym $mod+y nop bubblegum
#bindsym $mod+y exec /home/dario/config/i3/scripts/i3quake -p top -H 0.4 kitty
#for_window [class="(?i)xfce4-terminal"] floating enable
#for_window [class="(?i)xfce4-terminal"] border none
@ -208,7 +209,7 @@ mode "resize" {
bindsym Escape mode "default"
}
bindsym $mod+c mode "resize"
# bindsym $mod+c mode "resize"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
@ -226,3 +227,6 @@ exec --no-startup-id xfce4-power-manager
exec --no-startup-id "nm-applet &"
exec --no-startup-id "pnmixer &"
focus_on_window_activation urgent
workspace_auto_back_and_forth yes
mouse_warping output

@ -1,217 +0,0 @@
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Workspace assignment for monitors
workspace "1:l" output DP-1
workspace "2:l" output DP-1
workspace "3:l" output DP-1
workspace "4:l" output DP-1
workspace "5:l" output DP-1
workspace "6:l" output DP-1
#--
workspace "7:r" output DP-2
workspace "8:r" output DP-2
workspace "9:r" output DP-2
workspace "0:r" output HDMI-1
workspace "ß:r" output HDMI-1
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesnt scale on retina/hidpi displays.
exec_always xset -dpms ; xset s 0 0 ; xset s off
#exec autocutsel -selection CLIPBOARD
#exec autocutsel -selection PRIMARY
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec xfce4-terminal
# start chromium
bindsym $mod+BackSpace exec /home/dario/firefox/firefox
# screenshot
bindsym $mod+Delete exec scrot -s
# kill focused window
bindsym $mod+Shift+x kill
bindsym Scroll_Lock exec "sh -c 'for i in $(pactl list sinks | grep Sink | cut -d# -f2) ; do pactl set-sink-volume $i +5% ; done'"
bindsym Print exec "sh -c 'for i in $(pactl list sinks | grep Sink | cut -d# -f2) ; do pactl set-sink-volume $i -5% ; done'"
bindsym Pause exec "sh -c 'for i in $(pactl list sinks | grep Sink | cut -d# -f2) ; do pactl set-sink-mute $i toggle ; done'"
bindsym XF86AudioRaiseVolume exec "sh -c 'for i in $(pactl list sinks | grep Sink | cut -d# -f2) ; do pactl set-sink-volume $i +5% ; done'"
bindsym XF86AudioLowerVolume exec "sh -c 'for i in $(pactl list sinks | grep Sink | cut -d# -f2) ; do pactl set-sink-volume $i -5% ; done'"
bindsym XF86AudioMute exec "sh -c 'for i in $(pactl list sinks | grep Sink | cut -d# -f2) ; do pactl set-sink-mute $i toggle ; done'"
# start dmenu (a program launcher)
#bindsym $mod+a exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+n focus left
bindsym $mod+r focus down
bindsym $mod+t focus up
bindsym $mod+d focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+n move left
bindsym $mod+Shift+r move down
bindsym $mod+Shift+t move up
bindsym $mod+Shift+d move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+s split h
# split in vertical orientation
bindsym $mod+p split v
# enter fullscreen mode for the focused container
bindsym $mod+e fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+i layout stacking
bindsym $mod+v layout tabbed
bindsym $mod+l layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+u focus parent
# focus the child container
#bindsym $mod+d focus child
# switch to workspace
bindsym $mod+1 workspace "1:l"
bindsym $mod+2 workspace "2:l"
bindsym $mod+3 workspace "3:l"
bindsym $mod+4 workspace "4:l"
bindsym $mod+5 workspace "5:l"
bindsym $mod+6 workspace "6:l"
bindsym $mod+7 workspace "7:r"
bindsym $mod+8 workspace "8:r"
bindsym $mod+9 workspace "9:r"
bindsym $mod+0 workspace "0:r"
bindsym $mod+minus workspace "ß:r"
# switch workspace left/right
bindsym $mod+Prior workspace prev
bindsym $mod+Next workspace next
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace "1:l"
bindsym $mod+Shift+2 move container to workspace "2:l"
bindsym $mod+Shift+3 move container to workspace "3:l"
bindsym $mod+Shift+4 move container to workspace "4:l"
bindsym $mod+Shift+5 move container to workspace "5:l"
bindsym $mod+Shift+6 move container to workspace "6:l"
bindsym $mod+Shift+7 move container to workspace "7:r"
bindsym $mod+Shift+8 move container to workspace "8:r"
bindsym $mod+Shift+9 move container to workspace "9:r"
bindsym $mod+Shift+0 move container to workspace "0:r"
bindsym $mod+Shift+minus move container to workspace "ß:r"
# reload the configuration file
bindsym $mod+Shift+adiaeresis reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+c restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+l exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
bindsym $mod+Tab exec rofi -show window
bindsym $mod+a exec rofi -show drun
bindsym $mod+F2 exec sh ~/config/lock.sh
bindsym $mod+F4 exec sh ~/config/susp.sh
# TODO: debug
bindsym $mod+F12 exec xfce4-terminal --drop-down
bindsym $mod+y exec xfce4-terminal --drop-down
bindsym $mod+PAUSE exec xfce4-terminal --drop-down
#for_window [class="(?i)xfce4-terminal"] floating enable
#for_window [class="(?i)xfce4-terminal"] border none
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym n resize shrink width 10 px or 10 ppt
bindsym r resize grow height 10 px or 10 ppt
bindsym t resize shrink height 10 px or 10 ppt
bindsym d resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+c mode "resize"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
#status_command i3status --config ~/.config/i3/i3status.conf
status_command i3blocks -c ~/.config/i3/i3blocks.conf
bindsym button4 workspace next_on_output
bindsym button5 workspace prev_on_output
}

@ -1,213 +0,0 @@
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see http://i3wm.org/docs/userguide.html for a complete reference!
set $mod Mod4
# Workspace assignment for monitors
workspace "1:l" output DP-1
workspace "2:l" output DP-1
workspace "3:l" output DP-1
workspace "4:l" output DP-1
workspace "5:l" output DP-1
workspace "6:l" output DP-1
#--
workspace "7:r" output DP-2
workspace "8:r" output DP-2
workspace "9:r" output DP-2
workspace "0:r" output HDMI-1
workspace "ß:r" output HDMI-1
# Font for window titles. Will also be used by the bar unless a different font
# is used in the bar {} block below.
font pango:monospace 8
# This font is widely installed, provides lots of unicode glyphs, right-to-left
# text rendering and scalability on retina/hidpi displays (thanks to pango).
#font pango:DejaVu Sans Mono 8
# Before i3 v4.8, we used to recommend this one as the default:
# font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
# The font above is very space-efficient, that is, it looks good, sharp and
# clear in small sizes. However, its unicode glyph coverage is limited, the old
# X core fonts rendering does not support right-to-left and this being a bitmap
# font, it doesnt scale on retina/hidpi displays.
# Use Mouse+$mod to drag floating windows to their wanted position
floating_modifier $mod
# start a terminal
bindsym $mod+Return exec xfce4-terminal
# start chromium
bindsym $mod+BackSpace exec firefox
# screenshot
bindsym $mod+Delete exec scrot -s
# kill focused window
bindsym $mod+Shift+x kill
bindsym Scroll_Lock exec "sh -c 'for i in $(pacmd list-sinks | grep index | cut -d: -f2) ; do pactl set-sink-volume $i +5% ; done'"
bindsym Print exec "sh -c 'for i in $(pacmd list-sinks | grep index | cut -d: -f2) ; do pactl set-sink-volume $i -5% ; done'"
bindsym Pause exec "sh -c 'for i in $(pacmd list-sinks | grep index | cut -d: -f2) ; do pactl set-sink-mute $i toggle ; done'"
bindsym XF86AudioRaiseVolume exec "sh -c 'for i in $(pacmd list-sinks | grep index | cut -d: -f2) ; do pactl set-sink-volume $i +5% ; done'"
bindsym XF86AudioLowerVolume exec "sh -c 'for i in $(pacmd list-sinks | grep index | cut -d: -f2) ; do pactl set-sink-volume $i -5% ; done'"
bindsym XF86AudioMute exec "sh -c 'for i in $(pacmd list-sinks | grep index | cut -d: -f2) ; do pactl set-sink-mute $i toggle ; done'"
# start dmenu (a program launcher)
#bindsym $mod+a exec dmenu_run
# There also is the (new) i3-dmenu-desktop which only displays applications
# shipping a .desktop file. It is a wrapper around dmenu, so you need that
# installed.
# bindsym $mod+d exec --no-startup-id i3-dmenu-desktop
# change focus
bindsym $mod+n focus left
bindsym $mod+r focus down
bindsym $mod+t focus up
bindsym $mod+d focus right
# alternatively, you can use the cursor keys:
bindsym $mod+Left focus left
bindsym $mod+Down focus down
bindsym $mod+Up focus up
bindsym $mod+Right focus right
# move focused window
bindsym $mod+Shift+n move left
bindsym $mod+Shift+r move down
bindsym $mod+Shift+t move up
bindsym $mod+Shift+d move right
# alternatively, you can use the cursor keys:
bindsym $mod+Shift+Left move left
bindsym $mod+Shift+Down move down
bindsym $mod+Shift+Up move up
bindsym $mod+Shift+Right move right
# split in horizontal orientation
bindsym $mod+s split h
# split in vertical orientation
bindsym $mod+p split v
# enter fullscreen mode for the focused container
bindsym $mod+e fullscreen toggle
# change container layout (stacked, tabbed, toggle split)
bindsym $mod+i layout stacking
bindsym $mod+v layout tabbed
bindsym $mod+l layout toggle split
# toggle tiling / floating
bindsym $mod+Shift+space floating toggle
# change focus between tiling / floating windows
bindsym $mod+space focus mode_toggle
# focus the parent container
bindsym $mod+u focus parent
# focus the child container
#bindsym $mod+d focus child
# switch to workspace
bindsym $mod+1 workspace "1:l"
bindsym $mod+2 workspace "2:l"
bindsym $mod+3 workspace "3:l"
bindsym $mod+4 workspace "4:l"
bindsym $mod+5 workspace "5:l"
bindsym $mod+6 workspace "6:l"
bindsym $mod+7 workspace "7:r"
bindsym $mod+8 workspace "8:r"
bindsym $mod+9 workspace "9:r"
bindsym $mod+0 workspace "0:r"
bindsym $mod+minus workspace "ß:r"
# switch workspace left/right
bindsym $mod+Prior workspace prev
bindsym $mod+Next workspace next
# move focused container to workspace
bindsym $mod+Shift+1 move container to workspace "1:l"
bindsym $mod+Shift+2 move container to workspace "2:l"
bindsym $mod+Shift+3 move container to workspace "3:l"
bindsym $mod+Shift+4 move container to workspace "4:l"
bindsym $mod+Shift+5 move container to workspace "5:l"
bindsym $mod+Shift+6 move container to workspace "6:l"
bindsym $mod+Shift+7 move container to workspace "7:r"
bindsym $mod+Shift+8 move container to workspace "8:r"
bindsym $mod+Shift+9 move container to workspace "9:r"
bindsym $mod+Shift+0 move container to workspace "0:r"
bindsym $mod+Shift+minus move container to workspace "ß:r"
# reload the configuration file
bindsym $mod+Shift+adiaeresis reload
# restart i3 inplace (preserves your layout/session, can be used to upgrade i3)
bindsym $mod+Shift+c restart
# exit i3 (logs you out of your X session)
bindsym $mod+Shift+l exec "i3-nagbar -t warning -m 'You pressed the exit shortcut. Do you really want to exit i3? This will end your X session.' -b 'Yes, exit i3' 'i3-msg exit'"
bindsym $mod+Tab exec rofi -show window
bindsym $mod+a exec rofi -show drun
bindsym $mod+F2 exec sh ~/config/lock.sh
bindsym $mod+F4 exec sh ~/config/susp.sh
# TODO: debug
bindsym $mod+F12 exec xfce4-terminal --drop-down
bindsym $mod+y exec xfce4-terminal --drop-down
bindsym $mod+PAUSE exec xfce4-terminal --drop-down
#for_window [class="(?i)xfce4-terminal"] floating enable
#for_window [class="(?i)xfce4-terminal"] border none
# resize window (you can also use the mouse for that)
mode "resize" {
# These bindings trigger as soon as you enter the resize mode
# Pressing left will shrink the windows width.
# Pressing right will grow the windows width.
# Pressing up will shrink the windows height.
# Pressing down will grow the windows height.
bindsym n resize shrink width 10 px or 10 ppt
bindsym r resize grow height 10 px or 10 ppt
bindsym t resize shrink height 10 px or 10 ppt
bindsym d resize grow width 10 px or 10 ppt
# same bindings, but for the arrow keys
bindsym Left resize shrink width 10 px or 10 ppt
bindsym Down resize grow height 10 px or 10 ppt
bindsym Up resize shrink height 10 px or 10 ppt
bindsym Right resize grow width 10 px or 10 ppt
# back to normal: Enter or Escape
bindsym Return mode "default"
bindsym Escape mode "default"
}
bindsym $mod+c mode "resize"
# Start i3bar to display a workspace bar (plus the system information i3status
# finds out, if available)
bar {
#status_command i3status --config ~/.config/i3/i3status.conf
status_command i3blocks -c ~/.config/i3/i3blocks.conf
bindsym button4 workspace next_on_output
bindsym button5 workspace prev_on_output
}

@ -28,7 +28,8 @@ command=/usr/share/i3blocks/$BLOCK_NAME
separator_block_width=15
markup=none
[volume-pipewire]
[volume-pulseaudio]
label=🎚️
command=~/.config/i3/scripts/volume-pulseaudio
interval=1
signal=1
@ -53,7 +54,7 @@ interval=5
# The script may be called with a optional argument to set the alert
# (defaults to 10 for 10%).
[disk]
label=Disk
label=HOME
#instance=/mnt/data
interval=30
@ -71,17 +72,6 @@ separator=false
instance=enp0s31f6
interval=5
[iface]
instance=enx00e04c6803b1
color=#00FF00
interval=10
separator=false
[bandwidth]
instance=enx00e04c6803b1
interval=5
[iface]
instance=wlp58s0
color=#00FF00

Binary file not shown.

@ -1,172 +0,0 @@
#!/bin/bash
# Displays the default device, volume, and mute status for i3blocks
set -a
AUDIO_HIGH_SYMBOL=${AUDIO_HIGH_SYMBOL:-' '}
AUDIO_MED_THRESH=${AUDIO_MED_THRESH:-50}
AUDIO_MED_SYMBOL=${AUDIO_MED_SYMBOL:-' '}
AUDIO_LOW_THRESH=${AUDIO_LOW_THRESH:-0}
AUDIO_LOW_SYMBOL=${AUDIO_LOW_SYMBOL:-' '}
AUDIO_MUTED_SYMBOL=${AUDIO_MUTED_SYMBOL:-' '}
AUDIO_DELTA=${AUDIO_DELTA:-5}
DEFAULT_COLOR=${DEFAULT_COLOR:-"#ffffff"}
MUTED_COLOR=${MUTED_COLOR:-"#a0a0a0"}
LONG_FORMAT=${LONG_FORMAT:-'${SYMB} ${VOL}% [${INDEX}:${NAME}]'}
SHORT_FORMAT=${SHORT_FORMAT:-'${SYMB} ${VOL}% [${INDEX}]'}
USE_ALSA_NAME=${USE_ALSA_NAME:-0}
USE_DESCRIPTION=${USE_DESCRIPTION:-0}
SUBSCRIBE=${SUBSCRIBE:-0}
MIXER=${MIXER:-""}
SCONTROL=${SCONTROL:-""}
while getopts F:Sf:adH:M:L:X:T:t:C:c:i:m:s:h opt; do
case "$opt" in
S) SUBSCRIBE=1 ;;
F) LONG_FORMAT="$OPTARG" ;;
f) SHORT_FORMAT="$OPTARG" ;;
a) USE_ALSA_NAME=1 ;;
d) USE_DESCRIPTION=1 ;;
H) AUDIO_HIGH_SYMBOL="$OPTARG" ;;
M) AUDIO_MED_SYMBOL="$OPTARG" ;;
L) AUDIO_LOW_SYMBOL="$OPTARG" ;;
X) AUDIO_MUTED_SYMBOL="$OPTARG" ;;
T) AUDIO_MED_THRESH="$OPTARG" ;;
t) AUDIO_LOW_THRESH="$OPTARG" ;;
C) DEFAULT_COLOR="$OPTARG" ;;
c) MUTED_COLOR="$OPTARG" ;;
i) AUDIO_INTERVAL="$OPTARG" ;;
m) MIXER="$OPTARG" ;;
s) SCONTROL="$OPTARG" ;;
h) printf \
"Usage: volume-pulseaudio [-S] [-F format] [-f format] [-p] [-a|-d] [-H symb] [-M symb]
[-L symb] [-X symb] [-T thresh] [-t thresh] [-C color] [-c color] [-i inter]
[-m mixer] [-s scontrol] [-h]
Options:
-F, -f\tOutput format (-F long format, -f short format) to use, with exposed variables:
\${SYMB}, \${VOL}, \${INDEX}, \${NAME}
-S\tSubscribe to volume events (requires persistent block, always uses long format)
-a\tUse ALSA name if possible
-d\tUse device description instead of name if possible
-H\tSymbol to use when audio level is high. Default: '$AUDIO_HIGH_SYMBOL'
-M\tSymbol to use when audio level is medium. Default: '$AUDIO_MED_SYMBOL'
-L\tSymbol to use when audio level is low. Default: '$AUDIO_LOW_SYMBOL'
-X\tSymbol to use when audio is muted. Default: '$AUDIO_MUTED_SYMBOL'
-T\tThreshold for medium audio level. Default: $AUDIO_MED_THRESH
-t\tThreshold for low audio level. Default: $AUDIO_LOW_THRESH
-C\tColor for non-muted audio. Default: $DEFAULT_COLOR
-c\tColor for muted audio. Default: $MUTED_COLOR
-i\tInterval size of volume increase/decrease. Default: $AUDIO_DELTA
-m\tUse the given mixer.
-s\tUse the given scontrol.
-h\tShow this help text
" && exit 0;;
esac
done
if [[ -z "$MIXER" ]] ; then
MIXER="default"
if amixer -D pulse info >/dev/null 2>&1 ; then
MIXER="pulse"
fi
fi
if [[ -z "$SCONTROL" ]] ; then
SCONTROL=$(amixer -D "$MIXER" scontrols | sed -n "s/Simple mixer control '\([^']*\)',0/\1/p" | head -n1)
fi
CAPABILITY=$(amixer -D $MIXER get $SCONTROL | sed -n "s/ Capabilities:.*cvolume.*/Capture/p")
function move_sinks_to_new_default {
DEFAULT_SINK=$1
pactl list sink-inputs | grep 'Sink Input #' | grep -o '[0-9]\+' | while read SINK
do
pactl move-sink-input $SINK $DEFAULT_SINK
done
}
function set_default_playback_device_next {
inc=${1:-1}
num_devices=$(pactl list sinks | grep -c Name:)
sink_arr=($(pactl list sinks | grep Name: | sed -r 's/\s+Name: (.+)/\1/'))
default_sink=$(pactl get-default-sink)
default_sink_index=$(for i in "${!sink_arr[@]}"; do if [[ "$default_sink" = "${sink_arr[$i]}" ]]; then echo "$i"; fi done)
default_sink_index=$(( ($default_sink_index + $num_devices + $inc) % $num_devices ))
default_sink=${sink_arr[$default_sink_index]}
pactl set-default-sink $default_sink
move_sinks_to_new_default $default_sink
}
case "$BLOCK_BUTTON" in
1) set_default_playback_device_next ;;
2) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY toggle ;;
3) set_default_playback_device_next -1 ;;
4) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%+ ;;
5) amixer -q -D $MIXER sset $SCONTROL $CAPABILITY $AUDIO_DELTA%- ;;
esac
function print_format {
echo "$1" | envsubst '${SYMB}${VOL}${INDEX}${NAME}'
}
function print_block {
ACTIVE=$(pactl list sinks | grep "State\: RUNNING" -B4 -A55 | grep "Name:\|Volume: \(front-left\|mono\)\|Mute:\|api.alsa.pcm.card = \|node.nick = ")
for Name in NAME MUTED VOL INDEX NICK; do
read $Name
done < <(echo "$ACTIVE")
INDEX=$(echo "$INDEX" | grep -o '".*"' | sed 's/"//g')
VOL=$(echo "$VOL" | grep -o "[0-9]*%" | head -1 )
VOL="${VOL%?}"
NAME=$(echo "$NICK" | grep -o '".*"' | sed 's/"//g')
if [[ $USE_ALSA_NAME == 1 ]] ; then
ALSA_NAME=$(pactl list sinks |\
awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\
grep "alsa.name\|alsa.mixer_name" |\
head -n1 |\
sed 's/.*= "\(.*\)".*/\1/')
NAME=${ALSA_NAME:-$NAME}
elif [[ $USE_DESCRIPTION == 1 ]] ; then
DESCRIPTION=$(pactl list sinks | grep "State\: RUNNING" -B4 -A55 | grep 'Description: ' | sed 's/^.*: //')
NAME=${DESCRIPTION:-$NAME}
fi
if [[ $MUTED =~ "no" ]] ; then
SYMB=$AUDIO_HIGH_SYMBOL
[[ $VOL -le $AUDIO_MED_THRESH ]] && SYMB=$AUDIO_MED_SYMBOL
[[ $VOL -le $AUDIO_LOW_THRESH ]] && SYMB=$AUDIO_LOW_SYMBOL
COLOR=$DEFAULT_COLOR
else
SYMB=$AUDIO_MUTED_SYMBOL
COLOR=$MUTED_COLOR
fi
if [[ $ACTIVE = "" ]] ; then
echo "Sound inactive"
COLOR='#222225'
fi
if [[ $SUBSCRIBE == 1 ]] ; then
print_format "$LONG_FORMAT"
else
print_format "$LONG_FORMAT"
print_format "$SHORT_FORMAT"
echo "$COLOR"
fi
}
print_block
if [[ $SUBSCRIBE == 1 ]] ; then
while read -r EVENT; do
print_block
done < <(pactl subscribe | stdbuf -oL grep change)
fi

@ -59,9 +59,9 @@ done
function set_default_playback_device_next {
inc=${1:-1}
num_devices=$(pactl list sinks | grep -c index:)
sink_arr=($(pactl list sinks | grep index: | grep -o '[0-9]\+'))
default_sink_index=$(( $(patl list sinks | grep index: | grep -no '*' | grep -o '^[0-9]\+') - 1 ))
num_devices=$(pacmd list-sinks | grep -c index:)
sink_arr=($(pacmd list-sinks | grep index: | grep -o '[0-9]\+'))
default_sink_index=$(( $(pacmd list-sinks | grep index: | grep -no '*' | grep -o '^[0-9]\+') - 1 ))
default_sink_index=$(( ($default_sink_index + $num_devices + $inc) % $num_devices ))
default_sink=${sink_arr[$default_sink_index]}
pacmd set-default-sink $default_sink
@ -77,7 +77,7 @@ esac
for name in INDEX NAME VOL MUTED; do
read $name
done < <(pactl list sinks | grep "index:\|name:\|volume: front\|muted:" | grep -A3 '*')
done < <(pacmd list-sinks | grep "index:\|name:\|volume: front\|muted:" | grep -A3 '*')
INDEX=$(echo "$INDEX" | grep -o '[0-9]\+')
VOL=$(echo "$VOL" | grep -o "[0-9]*%" | head -1 )
VOL="${VOL%?}"
@ -89,7 +89,7 @@ NAME=$(echo "$NAME" | sed \
if [[ $USE_ALSA_NAME == 1 ]] ; then
ALSA_NAME=$(
pactl list sinks |\
pacmd list-sinks |\
awk '/^\s*\*/{f=1}/^\s*index:/{f=0}f' |\
grep "alsa.name\|alsa.mixer_name" |\
head -n1 |\

@ -1,8 +1,12 @@
let g:netrw_dirhistmax =10
let g:netrw_dirhistcnt =6
let g:netrw_dirhistcnt =3
let g:netrw_dirhist_3='/home/dario/source/ilabs/pyunits/build/lib/pyunits'
let g:netrw_dirhist_2='/home/dario/source/ilabs/bert-os/doc/releases_full/2.15.0'
let g:netrw_dirhist_1='/home/dario/source/ilabs/mappy/mypy'
let g:netrw_dirhist_0='/home/dario/source/ilabs/mappy/mappy'
let g:netrw_dirhist_9='/home/dario/source/ilabs/mappy/doc/releases/2.13.1'
let g:netrw_dirhist_8='/home/dario/source/ilabs/mappy/doc/releases'
let g:netrw_dirhist_7='/home/dario/source/ilabs/mappy/doc/releases/2.13.0'
let g:netrw_dirhist_6='/home/dario/machines/434004/434004_V1_1_2020-06-22/Logical/BP/Program/Rommelag_pharma_platform/RPP_con'
let g:netrw_dirhist_5='/home/dario/source/Marlin/Marlin/src/pins/lpc1768'
let g:netrw_dirhist_4='/home/dario/source/ilabs/rpp_basis_modell/.git'
let g:netrw_dirhist_3='/home/dario/source/ilabs/appify/appify'
let g:netrw_dirhist_2='/home/dario/source/python-opcua/opcua/ua/uaerrors/_auto.py'
let g:netrw_dirhist_1='/home/dario/source/python-opcua/opcua/ua/uaerrors'

@ -1,50 +1 @@
Starting
====
* Install all deps `apt update ; apt install neovim python3-neovim fzy ripgrep exuberant-ctags`
* Start `vi` (or `nvim`)
* Perform initial setup of plugins and modules `nvim -n -c "PlugUpgrade | PlugInstall | q | PlugUpdate | q | q" && nvim -n -c "CocInstall -sync coc-css coc-docker coc-eslint coc-git coc-gitignore coc-html coc-json coc-yaml coc-pairs coc-python coc-sh coc-tsserver coc-prettier | CocUpdateSync | UpdateRemotePlugins | q"`
Useful Shortcuts
====
* File/Buffer management:
* C-p: fuzzy quick open (also buffer switch)
* gn / gp: switch next/prev buffer
* gd: close buffer
* Split management:
* C-w C-s / C-w C-v: split horizontal (s), vertical (v)
* C-w C-w: switch splits
* C-w C-q: quit (current) split
* Movement:
* hjkl: char left/right/up/down
* e / b: move (word) forward / backward
* E / B: move delimited setence-split (a bit more than word)
* { / }: move paragraphs (codeblocks) up / down
* gg / G: begin/end of buffer
* fx / Fx: find (next/prev few) <x>, highlights next few in hit-a-hint manner
* tx / Tx: move (before/after) next <x>
* d<movement>: delete up to <any of above>, mnmenoic: *d*elete *to* <char>
* %: matching bracket
* ^ / $: line begin/end
* v: char-select-mode (`:`-any-command while in select will apply command on selection)
* V: line-selectmode (`:`-any-command while in select will apply command on selection)
* C-v: visual select (horizontal+vertical), useful with I afterwards (insert-mode for multiple lines, edit first line, apply to all selected afte ESC)
* Coding stuff
* tb: tagbar
* rn: rename symbol under cursor
* td: *t*o *d*efinition
* ty: *t*o t*y*pe-definition
* ti: *t*o *i*mplementation
* tr: *t*o *r*eferences (actually find/list usages)
* ,f: `rg`/grep for symbol under cursor
* K: documentation of symbol under cursor
* \*: find/highlight symbold under cursor
* =: auto-indent (useful with V line-select)
* `:<…>s///`: regex search/replace. `%s///` for global, or V then : then just type your `s///`
* Misc
* ,p: toggle paste-mode
* ESC ESC: deselect search results, \*-highligh or similar
nvim -n -c "PlugUpgrade | PlugInstall | q | PlugUpdate | q | q" && nvim -n -c "CocInstall -sync coc-css coc-vetur coc-docker coc-eslint coc-git coc-gitignore coc-html coc-json coc-yaml coc-pairs coc-python coc-sh coc-tsserver coc-prettier coc-docker | CocUpdateSync | UpdateRemotePlugins | q"
nvim -n -c "PlugUpgrade | PlugInstall | q | PlugUpdate | q | q" && nvim -n -c "CocInstall -sync coc-css coc-vetur coc-docker coc-eslint coc-git coc-gitignore coc-html coc-json coc-yaml coc-pairs coc-pyright coc-sh coc-tsserver coc-prettier coc-docker | CocUpdateSync | UpdateRemotePlugins | q"

@ -22,10 +22,10 @@
" Plug 'SirVer/ultisnips' | Plug 'honza/vim-snippets'
"
" " On-demand loading
" Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'preservim/nerdtree', { 'on': 'NERDTreeToggle' }
" Plug 'tpope/vim-fireplace', { 'for': 'clojure' }
"
" " Using a non-master branch
" " Using a non-default branch
" Plug 'rdnetto/YCM-Generator', { 'branch': 'stable' }
"
" " Using a tagged release; wildcard allowed (requires git 1.9.2 or above)
@ -106,7 +106,7 @@ if s:is_win && &shellslash
else
let s:me = resolve(expand('<sfile>:p'))
endif
let s:base_spec = { 'branch': 'master', 'frozen': 0 }
let s:base_spec = { 'branch': '', 'frozen': 0 }
let s:TYPE = {
\ 'string': type(''),
\ 'list': type([]),
@ -116,6 +116,94 @@ let s:TYPE = {
let s:loaded = get(s:, 'loaded', {})
let s:triggers = get(s:, 'triggers', {})
function! s:is_powershell(shell)
return a:shell =~# 'powershell\(\.exe\)\?$' || a:shell =~# 'pwsh\(\.exe\)\?$'
endfunction
function! s:isabsolute(dir) abort
return a:dir =~# '^/' || (has('win32') && a:dir =~? '^\%(\\\|[A-Z]:\)')
endfunction
function! s:git_dir(dir) abort
let gitdir = s:trim(a:dir) . '/.git'
if isdirectory(gitdir)
return gitdir
endif
if !filereadable(gitdir)
return ''
endif
let gitdir = matchstr(get(readfile(gitdir), 0, ''), '^gitdir: \zs.*')
if len(gitdir) && !s:isabsolute(gitdir)
let gitdir = a:dir . '/' . gitdir
endif
return isdirectory(gitdir) ? gitdir : ''
endfunction
function! s:git_origin_url(dir) abort
let gitdir = s:git_dir(a:dir)
let config = gitdir . '/config'
if empty(gitdir) || !filereadable(config)
return ''
endif
return matchstr(join(readfile(config)), '\[remote "origin"\].\{-}url\s*=\s*\zs\S*\ze')
endfunction
function! s:git_revision(dir) abort
let gitdir = s:git_dir(a:dir)
let head = gitdir . '/HEAD'
if empty(gitdir) || !filereadable(head)
return ''
endif
let line = get(readfile(head), 0, '')
let ref = matchstr(line, '^ref: \zs.*')
if empty(ref)
return line
endif
if filereadable(gitdir . '/' . ref)
return get(readfile(gitdir . '/' . ref), 0, '')
endif
if filereadable(gitdir . '/packed-refs')
for line in readfile(gitdir . '/packed-refs')
if line =~# ' ' . ref
return matchstr(line, '^[0-9a-f]*')
endif
endfor
endif
return ''
endfunction
function! s:git_local_branch(dir) abort
let gitdir = s:git_dir(a:dir)
let head = gitdir . '/HEAD'
if empty(gitdir) || !filereadable(head)
return ''
endif
let branch = matchstr(get(readfile(head), 0, ''), '^ref: refs/heads/\zs.*')
return len(branch) ? branch : 'HEAD'
endfunction
function! s:git_origin_branch(spec)
if len(a:spec.branch)
return a:spec.branch
endif
" The file may not be present if this is a local repository
let gitdir = s:git_dir(a:spec.dir)
let origin_head = gitdir.'/refs/remotes/origin/HEAD'
if len(gitdir) && filereadable(origin_head)
return matchstr(get(readfile(origin_head), 0, ''),
\ '^ref: refs/remotes/origin/\zs.*')
endif
" The command may not return the name of a branch in detached HEAD state
let result = s:lines(s:system('git symbolic-ref --short HEAD', a:spec.dir))
return v:shell_error ? '' : result[-1]
endfunction
if s:is_win
function! s:plug_call(fn, ...)
let shellslash = &shellslash
@ -154,6 +242,8 @@ function! plug#begin(...)
let home = s:path(s:plug_fnamemodify(s:plug_expand(a:1), ':p'))
elseif exists('g:plug_home')
let home = s:path(g:plug_home)
elseif has('nvim')
let home = stdpath('data') . '/plugged'
elseif !empty(&rtp)
let home = s:path(split(&rtp, ',')[0]) . '/plugged'
else
@ -179,7 +269,7 @@ function! s:define_commands()
endif
if has('win32')
\ && &shellslash
\ && (&shell =~# 'cmd\.exe' || &shell =~# 'powershell\.exe')
\ && (&shell =~# 'cmd\(\.exe\)\?$' || s:is_powershell(&shell))
return s:err('vim-plug does not support shell, ' . &shell . ', when shellslash is set.')
endif
if !has('nvim')
@ -262,7 +352,7 @@ function! plug#end()
endif
let lod = { 'ft': {}, 'map': {}, 'cmd': {} }
if exists('g:did_load_filetypes')
if get(g:, 'did_load_filetypes', 0)
filetype off
endif
for name in g:plugs_order
@ -317,7 +407,7 @@ function! plug#end()
for [map, names] in items(lod.map)
for [mode, map_prefix, key_prefix] in
\ [['i', '<C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
\ [['i', '<C-\><C-O>', ''], ['n', '', ''], ['v', '', 'gv'], ['o', '', '']]
execute printf(
\ '%snoremap <silent> %s %s:<C-U>call <SID>lod_map(%s, %s, %s, "%s")<CR>',
\ mode, map, map_prefix, string(map), string(names), mode != 'i', key_prefix)
@ -372,7 +462,7 @@ endfunction
function! s:git_version_requirement(...)
if !exists('s:git_version')
let s:git_version = map(split(split(s:system('git --version'))[2], '\.'), 'str2nr(v:val)')
let s:git_version = map(split(split(s:system(['git', '--version']))[2], '\.'), 'str2nr(v:val)')
endif
return s:version_requirement(s:git_version, a:000)
endfunction
@ -419,7 +509,7 @@ if s:is_win
let batchfile = s:plug_tempname().'.bat'
call writefile(s:wrap_cmds(a:cmd), batchfile)
let cmd = plug#shellescape(batchfile, {'shell': &shell, 'script': 0})
if &shell =~# 'powershell\.exe'
if s:is_powershell(&shell)
let cmd = '& ' . cmd
endif
return [batchfile, cmd]
@ -632,16 +722,38 @@ function! plug#(repo, ...)
let g:plugs[name] = spec
let s:loaded[name] = get(s:loaded, name, 0)
catch
return s:err(v:exception)
return s:err(repo . ' ' . v:exception)
endtry
endfunction
function! s:parse_options(arg)
let opts = copy(s:base_spec)
let type = type(a:arg)
let opt_errfmt = 'Invalid argument for "%s" option of :Plug (expected: %s)'
if type == s:TYPE.string
if empty(a:arg)
throw printf(opt_errfmt, 'tag', 'string')
endif
let opts.tag = a:arg
elseif type == s:TYPE.dict
for opt in ['branch', 'tag', 'commit', 'rtp', 'dir', 'as']
if has_key(a:arg, opt)
\ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt]))
throw printf(opt_errfmt, opt, 'string')
endif
endfor
for opt in ['on', 'for']
if has_key(a:arg, opt)
\ && type(a:arg[opt]) != s:TYPE.list
\ && (type(a:arg[opt]) != s:TYPE.string || empty(a:arg[opt]))
throw printf(opt_errfmt, opt, 'string or list')
endif
endfor
if has_key(a:arg, 'do')
\ && type(a:arg.do) != s:TYPE.funcref
\ && (type(a:arg.do) != s:TYPE.string || empty(a:arg.do))
throw printf(opt_errfmt, 'do', 'string or funcref')
endif
call extend(opts, a:arg)
if has_key(opts, 'dir')
let opts.dir = s:dirpath(s:plug_expand(opts.dir))
@ -698,7 +810,7 @@ function! s:syntax()
syn match plugNumber /[0-9]\+[0-9.]*/ contained
syn match plugBracket /[[\]]/ contained
syn match plugX /x/ contained
syn match plugDash /^-/
syn match plugDash /^-\{1}\ /
syn match plugPlus /^+/
syn match plugStar /^*/
syn match plugMessage /\(^- \)\@<=.*/
@ -716,6 +828,7 @@ function! s:syntax()
syn match plugError /^x.*/
syn region plugDeleted start=/^\~ .*/ end=/^\ze\S/
syn match plugH2 /^.*:\n-\+$/
syn match plugH2 /^-\{2,}/
syn keyword Function PlugInstall PlugStatus PlugUpdate PlugClean
hi def link plug1 Title
hi def link plug2 Repeat
@ -828,7 +941,7 @@ function! s:prepare(...)
call s:new_window()
endif
nnoremap <silent> <buffer> q :if b:plug_preview==1<bar>pc<bar>endif<bar>bd<cr>
nnoremap <silent> <buffer> q :call <SID>close_pane()<cr>
if a:0 == 0
call s:finish_bindings()
endif
@ -850,6 +963,15 @@ function! s:prepare(...)
endif
endfunction
function! s:close_pane()
if b:plug_preview == 1
pc
let b:plug_preview = -1
else
bd
endif
endfunction
function! s:assign_name()
" Assign buffer name
let prefix = '[Plugins]'
@ -864,8 +986,15 @@ endfunction
function! s:chsh(swap)
let prev = [&shell, &shellcmdflag, &shellredir]
if !s:is_win && a:swap
set shell=sh shellredir=>%s\ 2>&1
if !s:is_win
set shell=sh
endif
if a:swap
if s:is_powershell(&shell)
let &shellredir = '2>&1 | Out-File -Encoding UTF8 %s'
elseif &shell =~# 'sh' || &shell =~# 'cmd\(\.exe\)\?$'
set shellredir=>%s\ 2>&1
endif
endif
return prev
endfunction
@ -898,7 +1027,7 @@ function! s:regress_bar()
endfunction
function! s:is_updated(dir)
return !empty(s:system_chomp('git log --pretty=format:"%h" "HEAD...HEAD@{1}"', a:dir))
return !empty(s:system_chomp(['git', 'log', '--pretty=format:%h', 'HEAD...HEAD@{1}'], a:dir))
endfunction
function! s:do(pull, force, todo)
@ -935,6 +1064,7 @@ function! s:do(pull, force, todo)
endif
elseif type == s:TYPE.funcref
try
call s:load_plugin(spec)
let status = installed ? 'installed' : (updated ? 'updated' : 'unchanged')
call spec.do({ 'name': name, 'status': status, 'force': a:force })
catch
@ -961,10 +1091,11 @@ endfunction
function! s:checkout(spec)
let sha = a:spec.commit
let output = s:system('git rev-parse HEAD', a:spec.dir)
if !v:shell_error && !s:hash_match(sha, s:lines(output)[0])
let output = s:git_revision(a:spec.dir)
if !empty(output) && !s:hash_match(sha, s:lines(output)[0])
let credential_helper = s:git_version_requirement(2) ? '-c credential.helper= ' : ''
let output = s:system(
\ 'git fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
\ 'git '.credential_helper.'fetch --depth 999999 && git checkout '.plug#shellescape(sha).' --', a:spec.dir)
endif
return output
endfunction
@ -1079,11 +1210,17 @@ function! s:update_impl(pull, force, args) abort
normal! 2G
silent! redraw
let s:clone_opt = get(g:, 'plug_shallow', 1) ?
\ '--depth 1' . (s:git_version_requirement(1, 7, 10) ? ' --no-single-branch' : '') : ''
" Set remote name, overriding a possible user git config's clone.defaultRemoteName
let s:clone_opt = ['--origin', 'origin']
if get(g:, 'plug_shallow', 1)
call extend(s:clone_opt, ['--depth', '1'])
if s:git_version_requirement(1, 7, 10)
call add(s:clone_opt, '--no-single-branch')
endif
endif
if has('win32unix') || has('wsl')
let s:clone_opt .= ' -c core.eol=lf -c core.autocrlf=input'
call extend(s:clone_opt, ['-c', 'core.eol=lf', '-c', 'core.autocrlf=input'])
endif
let s:submodule_opt = s:git_version_requirement(2, 8) ? ' --jobs='.threads : ''
@ -1171,7 +1308,7 @@ function! s:update_finish()
call s:log4(name, 'Checking out '.tag)
let out = s:system('git checkout -q '.plug#shellescape(tag).' -- 2>&1', spec.dir)
else
let branch = get(spec, 'branch', 'master')
let branch = s:git_origin_branch(spec)
call s:log4(name, 'Merging origin/'.s:esc(branch))
let out = s:system('git checkout -q '.plug#shellescape(branch).' -- 2>&1'
\. (has_key(s:update.new, name) ? '' : ('&& git merge --ff-only '.plug#shellescape('origin/'.branch).' 2>&1')), spec.dir)
@ -1264,7 +1401,7 @@ function! s:job_cb(fn, job, ch, data)
endfunction
function! s:nvim_cb(job_id, data, event) dict abort
return a:event == 'stdout' ?
return (a:event == 'stdout' || a:event == 'stderr') ?
\ s:job_cb('s:job_out_cb', self, 0, join(a:data, "\n")) :
\ s:job_cb('s:job_exit_cb', self, 0, a:data)
endfunction
@ -1273,12 +1410,15 @@ function! s:spawn(name, cmd, opts)
let job = { 'name': a:name, 'running': 1, 'error': 0, 'lines': [''],
\ 'new': get(a:opts, 'new', 0) }
let s:jobs[a:name] = job
let cmd = has_key(a:opts, 'dir') ? s:with_cd(a:cmd, a:opts.dir, 0) : a:cmd
let argv = s:is_win ? ['cmd', '/s', '/c', '"'.cmd.'"'] : ['sh', '-c', cmd]
if s:nvim
if has_key(a:opts, 'dir')
let job.cwd = a:opts.dir
endif
let argv = a:cmd
call extend(job, {
\ 'on_stdout': function('s:nvim_cb'),
\ 'on_stderr': function('s:nvim_cb'),
\ 'on_exit': function('s:nvim_cb'),
\ })
let jid = s:plug_call('jobstart', argv, job)
@ -1291,9 +1431,16 @@ function! s:spawn(name, cmd, opts)
\ 'Invalid arguments (or job table is full)']
endif
elseif s:vim8
let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"script": 0})'))
if has_key(a:opts, 'dir')
let cmd = s:with_cd(cmd, a:opts.dir, 0)
endif
let argv = s:is_win ? ['cmd', '/s', '/c', '"'.cmd.'"'] : ['sh', '-c', cmd]
let jid = job_start(s:is_win ? join(argv, ' ') : argv, {
\ 'out_cb': function('s:job_cb', ['s:job_out_cb', job]),
\ 'err_cb': function('s:job_cb', ['s:job_out_cb', job]),
\ 'exit_cb': function('s:job_cb', ['s:job_exit_cb', job]),
\ 'err_mode': 'raw',
\ 'out_mode': 'raw'
\})
if job_status(jid) == 'run'
@ -1304,7 +1451,7 @@ function! s:spawn(name, cmd, opts)
let job.lines = ['Failed to start job']
endif
else
let job.lines = s:lines(call('s:system', [cmd]))
let job.lines = s:lines(call('s:system', has_key(a:opts, 'dir') ? [a:cmd, a:opts.dir] : [a:cmd]))
let job.error = v:shell_error != 0
let job.running = 0
endif
@ -1401,8 +1548,14 @@ while 1 " Without TCO, Vim stack is bound to explode
let [error, _] = s:git_validate(spec, 0)
if empty(error)
if pull
let fetch_opt = (has_tag && !empty(globpath(spec.dir, '.git/shallow'))) ? '--depth 99999999' : ''
call s:spawn(name, printf('git fetch %s %s 2>&1', fetch_opt, prog), { 'dir': spec.dir })
let cmd = s:git_version_requirement(2) ? ['git', '-c', 'credential.helper=', 'fetch'] : ['git', 'fetch']
if has_tag && !empty(globpath(spec.dir, '.git/shallow'))
call extend(cmd, ['--depth', '99999999'])
endif
if !empty(prog)
call add(cmd, prog)
endif
call s:spawn(name, cmd, { 'dir': spec.dir })
else
let s:jobs[name] = { 'running': 0, 'lines': ['Already installed'], 'error': 0 }
endif
@ -1410,12 +1563,14 @@ while 1 " Without TCO, Vim stack is bound to explode
let s:jobs[name] = { 'running': 0, 'lines': s:lines(error), 'error': 1 }
endif
else
call s:spawn(name,
\ printf('git clone %s %s %s %s 2>&1',
\ has_tag ? '' : s:clone_opt,
\ prog,
\ plug#shellescape(spec.uri, {'script': 0}),
\ plug#shellescape(s:trim(spec.dir), {'script': 0})), { 'new': 1 })
let cmd = ['git', 'clone']
if !has_tag
call extend(cmd, s:clone_opt)
endif
if !empty(prog)
call add(cmd, prog)
endif
call s:spawn(name, extend(cmd, [spec.uri, s:trim(spec.dir)]), { 'new': 1 })
endif
if !s:jobs[name].running
@ -1452,7 +1607,7 @@ G_NVIM = vim.eval("has('nvim')") == '1'
G_PULL = vim.eval('s:update.pull') == '1'
G_RETRIES = int(vim.eval('get(g:, "plug_retries", 2)')) + 1
G_TIMEOUT = int(vim.eval('get(g:, "plug_timeout", 60)'))
G_CLONE_OPT = vim.eval('s:clone_opt')
G_CLONE_OPT = ' '.join(vim.eval('s:clone_opt'))
G_PROGRESS = vim.eval('s:progress_opt(1)')
G_LOG_PROB = 1.0 / int(vim.eval('s:update.threads'))
G_STOP = thr.Event()
@ -1989,7 +2144,7 @@ function! s:update_ruby()
end
} if VIM::evaluate('s:mac_gui') == 1
clone_opt = VIM::evaluate('s:clone_opt')
clone_opt = VIM::evaluate('s:clone_opt').join(' ')
progress = VIM::evaluate('s:progress_opt(1)')
nthr.times do
mtx.synchronize do
@ -2055,13 +2210,29 @@ function! s:shellesc_sh(arg)
return "'".substitute(a:arg, "'", "'\\\\''", 'g')."'"
endfunction
" Escape the shell argument based on the shell.
" Vim and Neovim's shellescape() are insufficient.
" 1. shellslash determines whether to use single/double quotes.
" Double-quote escaping is fragile for cmd.exe.
" 2. It does not work for powershell.
" 3. It does not work for *sh shells if the command is executed
" via cmd.exe (ie. cmd.exe /c sh -c command command_args)
" 4. It does not support batchfile syntax.
"
" Accepts an optional dictionary with the following keys:
" - shell: same as Vim/Neovim 'shell' option.
" If unset, fallback to 'cmd.exe' on Windows or 'sh'.
" - script: If truthy and shell is cmd.exe, escape for batchfile syntax.
function! plug#shellescape(arg, ...)
if a:arg =~# '^[A-Za-z0-9_/:.-]\+$'
return a:arg
endif
let opts = a:0 > 0 && type(a:1) == s:TYPE.dict ? a:1 : {}
let shell = get(opts, 'shell', s:is_win ? 'cmd.exe' : 'sh')
let script = get(opts, 'script', 1)
if shell =~# 'cmd\.exe'
if shell =~# 'cmd\(\.exe\)\?$'
return s:shellesc_cmd(a:arg, script)
elseif shell =~# 'powershell\.exe' || shell =~# 'pwsh$'
elseif s:is_powershell(shell)
return s:shellesc_ps1(a:arg)
endif
return s:shellesc_sh(a:arg)
@ -2105,8 +2276,24 @@ function! s:system(cmd, ...)
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = a:0 > 0 ? s:with_cd(a:cmd, a:1) : a:cmd
if s:is_win
if type(a:cmd) == s:TYPE.list
" Neovim's system() supports list argument to bypass the shell
" but it cannot set the working directory for the command.
" Assume that the command does not rely on the shell.
if has('nvim') && a:0 == 0
return system(a:cmd)
endif
let cmd = join(map(copy(a:cmd), 'plug#shellescape(v:val, {"shell": &shell, "script": 0})'))
if s:is_powershell(&shell)
let cmd = '& ' . cmd
endif
else
let cmd = a:cmd
endif
if a:0 > 0
let cmd = s:with_cd(cmd, a:1, type(a:cmd) != s:TYPE.list)
endif
if s:is_win && type(a:cmd) != s:TYPE.list
let [batchfile, cmd] = s:batchfile(cmd)
endif
return system(cmd)
@ -2126,18 +2313,17 @@ endfunction
function! s:git_validate(spec, check_branch)
let err = ''
if isdirectory(a:spec.dir)
let result = s:lines(s:system('git rev-parse --abbrev-ref HEAD 2>&1 && git config -f .git/config remote.origin.url', a:spec.dir))
let result = [s:git_local_branch(a:spec.dir), s:git_origin_url(a:spec.dir)]
let remote = result[-1]
if v:shell_error
if empty(remote)
let err = join([remote, 'PlugClean required.'], "\n")
elseif !s:compare_git_uri(remote, a:spec.uri)
let err = join(['Invalid URI: '.remote,
\ 'Expected: '.a:spec.uri,
\ 'PlugClean required.'], "\n")
elseif a:check_branch && has_key(a:spec, 'commit')
let result = s:lines(s:system('git rev-parse HEAD 2>&1', a:spec.dir))
let sha = result[-1]
if v:shell_error
let sha = s:git_revision(a:spec.dir)
if empty(sha)
let err = join(add(result, 'PlugClean required.'), "\n")
elseif !s:hash_match(sha, a:spec.commit)
let err = join([printf('Invalid HEAD (expected: %s, actual: %s)',
@ -2145,8 +2331,9 @@ function! s:git_validate(spec, check_branch)
\ 'PlugUpdate required.'], "\n")
endif
elseif a:check_branch
let branch = result[0]
let current_branch = result[0]
" Check tag
let origin_branch = s:git_origin_branch(a:spec)
if has_key(a:spec, 'tag')
let tag = s:system_chomp('git describe --exact-match --tags HEAD 2>&1', a:spec.dir)
if a:spec.tag !=# tag && a:spec.tag !~ '\*'
@ -2154,25 +2341,26 @@ function! s:git_validate(spec, check_branch)
\ (empty(tag) ? 'N/A' : tag), a:spec.tag)
endif
" Check branch
elseif a:spec.branch !=# branch
elseif origin_branch !=# current_branch
let err = printf('Invalid branch: %s (expected: %s). Try PlugUpdate.',
\ branch, a:spec.branch)
\ current_branch, origin_branch)
endif
if empty(err)
let [ahead, behind] = split(s:lastline(s:system(printf(
\ 'git rev-list --count --left-right HEAD...origin/%s',
\ a:spec.branch), a:spec.dir)), '\t')
let [ahead, behind] = split(s:lastline(s:system([
\ 'git', 'rev-list', '--count', '--left-right',
\ printf('HEAD...origin/%s', origin_branch)
\ ], a:spec.dir)), '\t')
if !v:shell_error && ahead
if behind
" Only mention PlugClean if diverged, otherwise it's likely to be
" pushable (and probably not that messed up).
let err = printf(
\ "Diverged from origin/%s (%d commit(s) ahead and %d commit(s) behind!\n"
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', a:spec.branch, ahead, behind)
\ .'Backup local changes and run PlugClean and PlugUpdate to reinstall it.', origin_branch, ahead, behind)
else
let err = printf("Ahead of origin/%s by %d commit(s).\n"
\ .'Cannot update until local changes are pushed.',
\ a:spec.branch, ahead)
\ origin_branch, ahead)
endif
endif
endif
@ -2185,7 +2373,9 @@ endfunction
function! s:rm_rf(dir)
if isdirectory(a:dir)
call s:system((s:is_win ? 'rmdir /S /Q ' : 'rm -rf ') . plug#shellescape(a:dir))
return s:system(s:is_win
\ ? 'rmdir /S /Q '.plug#shellescape(a:dir)
\ : ['rm', '-rf', a:dir])
endif
endfunction
@ -2267,6 +2457,7 @@ endfunction
function! s:delete(range, force)
let [l1, l2] = a:range
let force = a:force
let err_count = 0
while l1 <= l2
let line = getline(l1)
if line =~ '^- ' && isdirectory(line[2:])
@ -2275,11 +2466,22 @@ function! s:delete(range, force)
let answer = force ? 1 : s:ask('Delete '.line[2:].'?', 1)
let force = force || answer > 1
if answer
call s:rm_rf(line[2:])
let err = s:rm_rf(line[2:])
setlocal modifiable
if empty(err)
call setline(l1, '~'.line[1:])
let s:clean_count += 1
call setline(4, printf('Removed %d directories.', s:clean_count))
else
delete _
call append(l1 - 1, s:format_message('x', line[1:], err))
let l2 += len(s:lines(err))
let err_count += 1
endif
let msg = printf('Removed %d directories.', s:clean_count)
if err_count > 0
let msg .= printf(' Failed to remove %d directories.', err_count)
endif
call setline(4, msg)
setlocal nomodifiable
endif
endif
@ -2294,7 +2496,7 @@ function! s:upgrade()
let new = tmp . '/plug.vim'
try
let out = s:system(printf('git clone --depth 1 %s %s', plug#shellescape(s:plug_src), plug#shellescape(tmp)))
let out = s:system(['git', 'clone', '--depth', '1', s:plug_src, tmp])
if v:shell_error
return s:err('Error upgrading vim-plug: '. out)
endif
@ -2419,26 +2621,34 @@ function! s:preview_commit()
let sha = matchstr(getline('.'), '^ \X*\zs[0-9a-f]\{7,9}')
if empty(sha)
let name = matchstr(getline('.'), '^- \zs[^:]*\ze:$')
if empty(name)
return
endif
let title = 'HEAD@{1}..'
let command = 'git diff --no-color HEAD@{1}'
else
let title = sha
let command = 'git show --no-color --pretty=medium '.sha
let name = s:find_name(line('.'))
endif
if empty(name) || !has_key(g:plugs, name) || !isdirectory(g:plugs[name].dir)
return
endif
if exists('g:plug_pwindow') && !s:is_preview_window_open()
execute g:plug_pwindow
execute 'e' sha
execute 'e' title
else
execute 'pedit' sha
execute 'pedit' title
wincmd P
endif
setlocal previewwindow filetype=git buftype=nofile nobuflisted modifiable
setlocal previewwindow filetype=git buftype=nofile bufhidden=wipe nobuflisted modifiable
let batchfile = ''
try
let [sh, shellcmdflag, shrd] = s:chsh(1)
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && git show --no-color --pretty=medium '.sha
let cmd = 'cd '.plug#shellescape(g:plugs[name].dir).' && '.command
if s:is_win
let [batchfile, cmd] = s:batchfile(cmd)
endif
@ -2488,12 +2698,16 @@ function! s:diff()
endif
call s:append_ul(2, origin ? 'Pending updates:' : 'Last update:')
for [k, v] in plugs
let range = origin ? '..origin/'.v.branch : 'HEAD@{1}..'
let cmd = 'git log --graph --color=never '
\ . (s:git_version_requirement(2, 10, 0) ? '--no-show-signature ' : '')
\ . join(map(['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range], 'plug#shellescape(v:val)'))
let branch = s:git_origin_branch(v)
if len(branch)
let range = origin ? '..origin/'.branch : 'HEAD@{1}..'
let cmd = ['git', 'log', '--graph', '--color=never']
if s:git_version_requirement(2, 10, 0)
call add(cmd, '--no-show-signature')
endif
call extend(cmd, ['--pretty=format:%x01%h%x01%d%x01%s%x01%cr', range])
if has_key(v, 'rtp')
let cmd .= ' -- '.plug#shellescape(v.rtp)
call extend(cmd, ['--', v.rtp])
endif
let diff = s:system_chomp(cmd, v.dir)
if !empty(diff)
@ -2501,6 +2715,7 @@ function! s:diff()
call append(5, extend(['', '- '.k.':'.ref], map(s:lines(diff), 's:format_git_log(v:val)')))
let cnts[origin] += 1
endif
endif
let bar .= '='
call s:progress_bar(2, bar, len(total))
normal! 2G
@ -2559,9 +2774,9 @@ function! s:snapshot(force, ...) abort
1
let anchor = line('$') - 3
let names = sort(keys(filter(copy(g:plugs),
\'has_key(v:val, "uri") && !has_key(v:val, "commit") && isdirectory(v:val.dir)')))
\'has_key(v:val, "uri") && isdirectory(v:val.dir)')))
for name in reverse(names)
let sha = s:system_chomp('git rev-parse --short HEAD', g:plugs[name].dir)
let sha = has_key(g:plugs[name], 'commit') ? g:plugs[name].commit : s:git_revision(g:plugs[name].dir)
if !empty(sha)
call append(anchor, printf("silent! let g:plugs['%s'].commit = '%s'", name, sha))
redraw

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
set termguicolors
set background=light
set background=dark
let g:one_allow_italics = 1 " I love italic for comments
let g:airline_theme='one'
colorscheme one

@ -34,17 +34,6 @@ nmap ,r <Plug>(coc-format)
" Add `:Format` command to format current buffer.
command! -nargs=0 Format :call CocAction('format')
nmap f <Plug>(coc-smartf-forward)
nmap F <Plug>(coc-smartf-backward)
nmap ; <Plug>(coc-smartf-repeat)
nmap , <Plug>(coc-smartf-repeat-opposite)
augroup Smartf
autocmd User SmartfEnter :hi Conceal ctermfg=220 guifg=#6638F0
autocmd User SmartfLeave :hi Conceal ctermfg=239 guifg=#504945
augroup end
" Use tab for trigger completion with characters ahead and navigate.
" Use command ':verbose imap <tab>' to make sure tab is not mapped by other plugin.
inoremap <silent><expr> <TAB>
@ -53,8 +42,6 @@ inoremap <silent><expr> <TAB>
\ coc#refresh()
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>"
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
function! s:check_back_space() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'

@ -6,9 +6,6 @@ Plug 'rakr/vim-one'
Plug 'tpope/vim-fugitive'
"Plug 'sheerun/vim-polyglot'
" auto-detect indentation
Plug 'tpope/vim-sleuth'
" Fuzzy open
Plug 'cloudhead/neovim-fuzzy'
@ -26,7 +23,7 @@ Plug 'jparise/vim-graphql'
Plug 'posva/vim-vue'
" Python formatter
Plug 'psf/black'
Plug 'psf/black' , { 'branch': 'main' }
" tag finder
Plug 'majutsushi/tagbar'

Loading…
Cancel
Save