Compare commits
21 Commits
nuc_privat
...
master
| Author | SHA1 | Date |
|---|---|---|
|
|
e106b940ce | 3 years ago |
|
|
bde536aada | 3 years ago |
|
|
96ee7bcc1d | 3 years ago |
|
|
b8a0141bc1 | 3 years ago |
|
|
63339290b6 | 3 years ago |
|
|
eb3ab02590 | 3 years ago |
|
|
7ab61312d5 | 3 years ago |
|
|
45ed82a058 | 3 years ago |
|
|
627c2eb18e | 6 years ago |
|
|
ab91196273 | 6 years ago |
|
|
d3666b8d51 | 6 years ago |
|
|
ae6bf3dd47 | 6 years ago |
|
|
900c4f2193 | 6 years ago |
|
|
928bd78ed9 | 6 years ago |
|
|
7a995a28f7 | 6 years ago |
|
|
fed88bfdcb | 6 years ago |
|
|
8ce5e4d47b | 6 years ago |
|
|
1abe77b02d | 6 years ago |
|
|
17edfb6338 | 8 years ago |
|
|
7d91a8d287 | 8 years ago |
|
|
787bbb00d5 | 8 years ago |
@ -0,0 +1 @@
|
|||||||
|
i3/config
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,9 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
TEMPF=$(mktemp ocrscrot.XXXXXXX)
|
||||||
|
rm $TEMPF
|
||||||
|
|
||||||
|
scrot -s $TEMPF.png
|
||||||
|
tesseract -l deu+eng $TEMPF.png - | xsel
|
||||||
|
|
||||||
|
rm $TEMPF.png
|
||||||
@ -0,0 +1,867 @@
|
|||||||
|
#!/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()
|
||||||
|
}'
|
||||||
@ -1,38 +0,0 @@
|
|||||||
general {
|
|
||||||
}
|
|
||||||
|
|
||||||
order += "volume audio"
|
|
||||||
order += "ipv6"
|
|
||||||
order += "disk /"
|
|
||||||
order += "run_watch DHCP"
|
|
||||||
order += "ethernet eth0"
|
|
||||||
order += "battery 0"
|
|
||||||
order += "load"
|
|
||||||
order += "tztime local"
|
|
||||||
|
|
||||||
ethernet eth0 {
|
|
||||||
# if you use %speed, i3status requires the cap_net_admin capability
|
|
||||||
format_up = "E: %ip (%speed)"
|
|
||||||
format_down = "E: down"
|
|
||||||
}
|
|
||||||
|
|
||||||
run_watch DHCP {
|
|
||||||
pidfile = "/var/run/dhclient*.pid"
|
|
||||||
}
|
|
||||||
|
|
||||||
tztime local {
|
|
||||||
format = "%Y-%m-%d %H:%M:%S"
|
|
||||||
}
|
|
||||||
|
|
||||||
volume audio {
|
|
||||||
device = "pulse"
|
|
||||||
}
|
|
||||||
|
|
||||||
load {
|
|
||||||
format = "%5min"
|
|
||||||
}
|
|
||||||
|
|
||||||
disk "/" {
|
|
||||||
format = "%free"
|
|
||||||
}
|
|
||||||
|
|
||||||
Binary file not shown.
@ -0,0 +1,172 @@
|
|||||||
|
#!/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
|
||||||
@ -1,9 +1,18 @@
|
|||||||
mkdir -p ~/.config/
|
mkdir -p ~/.config
|
||||||
if [[ ! -d ~/.config/nvim/ ]] ; then
|
if [[ ! -d ~/.config/nvim ]] ; then
|
||||||
ln -s ~/config/nvim/ ~/.config/nvim
|
ln -s ~/config/nvim ~/.config/nvim
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -d ~/.config/i3 ]] ; then
|
if [[ ! -d ~/.config/i3 ]] ; then
|
||||||
ln -s ~/config/i3/ ~/.config/i3
|
ln -s ~/config/i3 ~/.config/i3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ ! -d ~/.config/kitty ]] ; then
|
||||||
|
ln -s ~/config/kitty ~/.config/kitty
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ ! -f ~/.config/.zshrc.local ]] ; then
|
||||||
|
ln -s ~/config/zsh/.zshrc ~/.zshrc
|
||||||
|
ln -s ~/config/zsh/.zshrc.local ~/.zshrc.local
|
||||||
|
ln -s ~/config/zsh/.zshrc.pre ~/.zshrc.pre
|
||||||
|
fi
|
||||||
|
|||||||
@ -0,0 +1,21 @@
|
|||||||
|
include ./theme.conf
|
||||||
|
|
||||||
|
font_family Liberation Mono
|
||||||
|
bold_font auto
|
||||||
|
italic_font auto
|
||||||
|
bold_italic_font auto
|
||||||
|
font_size 14
|
||||||
|
|
||||||
|
cursor_shape beam
|
||||||
|
scrollback_lines 50000
|
||||||
|
|
||||||
|
map ctrl+shift+s paste_from_selection
|
||||||
|
map ctrl+shift+n paste_from_clipboard
|
||||||
|
|
||||||
|
map ctrl+0 change_font_size all +2.0
|
||||||
|
map ctrl+minus change_font_size all -2.0
|
||||||
|
|
||||||
|
map shift+page_up scroll_page_up
|
||||||
|
map shift+page_down scroll_page_down
|
||||||
|
|
||||||
|
update_check_interval 0
|
||||||
@ -0,0 +1,21 @@
|
|||||||
|
background #fdf6e3
|
||||||
|
foreground #52676f
|
||||||
|
cursor #52676f
|
||||||
|
selection_background #e9e2cb
|
||||||
|
color0 #e4e4e4
|
||||||
|
color8 #ffffd7
|
||||||
|
color1 #d70000
|
||||||
|
color9 #d75f00
|
||||||
|
color2 #5f8700
|
||||||
|
color10 #585858
|
||||||
|
color3 #af8700
|
||||||
|
color11 #626262
|
||||||
|
color4 #0087ff
|
||||||
|
color12 #808080
|
||||||
|
color5 #af005f
|
||||||
|
color13 #5f5faf
|
||||||
|
color6 #00afaf
|
||||||
|
color14 #8a8a8a
|
||||||
|
color7 #262626
|
||||||
|
color15 #1c1c1c
|
||||||
|
selection_foreground #fcf4dc
|
||||||
@ -0,0 +1,8 @@
|
|||||||
|
let g:netrw_dirhistmax =10
|
||||||
|
let g:netrw_dirhistcnt =6
|
||||||
|
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'
|
||||||
@ -0,0 +1,50 @@
|
|||||||
|
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"
|
||||||
@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
//"diagnostic.messageTarget": "echo",
|
||||||
|
//"signature.target": "echo",
|
||||||
|
//"suggest.maxCompleteItemCount": 20,
|
||||||
|
//"coc.preferences.hoverTarget": "echo",
|
||||||
|
//"python.jediEnabled": false,
|
||||||
|
//"python.analysis.memory.keepLibraryAst": true,
|
||||||
|
//"python.analysis.memory.keepLibraryLocalVariables": true,
|
||||||
|
//"coc.preferences.formatOnSaveFiletypes": ["python"],
|
||||||
|
"python.formatting.provider": "black",
|
||||||
|
"python.linting.pylintEnabled": true,
|
||||||
|
"python.analysis.diagnosticMode": "workspace",
|
||||||
|
"python.linting.mypyEnabled": true,
|
||||||
|
"python.analysis.typeCheckingMode": "off"
|
||||||
|
//"suggest.timeout": 15000
|
||||||
|
}
|
||||||
@ -1,8 +0,0 @@
|
|||||||
" Make nerdtree look nice
|
|
||||||
let NERDTreeMinimalUI = 1
|
|
||||||
let NERDTreeDirArrows = 1
|
|
||||||
let g:NERDTreeWinSize = 30
|
|
||||||
|
|
||||||
"tabs
|
|
||||||
" Focus in the main content window
|
|
||||||
let g:nerdtree_tabs_focus_on_files = 1
|
|
||||||
@ -1,14 +0,0 @@
|
|||||||
" use ag
|
|
||||||
if executable('ag')
|
|
||||||
let g:ackprg = 'ag --vimgrep'
|
|
||||||
endif
|
|
||||||
|
|
||||||
" auto-close results window
|
|
||||||
let g:ack_autoclose = 1
|
|
||||||
|
|
||||||
" use background search
|
|
||||||
"let g:ack_use_dispatch = 1
|
|
||||||
|
|
||||||
" C-* to search word under cursor
|
|
||||||
noremap <C-s>* :Ack <cword><cr>
|
|
||||||
|
|
||||||
@ -1,9 +1,9 @@
|
|||||||
set laststatus=2
|
set laststatus=2
|
||||||
|
|
||||||
|
" disable tabline if single buffer
|
||||||
let g:airline#extensions#tabline#enabled = 1
|
let g:airline#extensions#tabline#enabled = 1
|
||||||
" let g:airline_powerline_fonts = 1
|
|
||||||
" let g:airline_left_sep = "\ue0b0"
|
" tagbar integration
|
||||||
" let g:airline_left_alt_sep = "\ue0b1"
|
let g:airline#extensions#tagbar#enabled = 1
|
||||||
" let g:airline_right_sep = "\ue0b6"
|
" show full tag
|
||||||
" let g:airline#extensions#virtualenv#enabled = 1
|
let g:airline#extensions#tagbar#flags = 'f'
|
||||||
" let g:airline_section_z = airline#section#create(["\uE0A1" . '%{line(".")}' . "\uE0A3" . '%{col(".")}'])
|
|
||||||
|
|||||||
@ -0,0 +1,84 @@
|
|||||||
|
" if hidden is not set, TextEdit might fail.
|
||||||
|
set hidden
|
||||||
|
|
||||||
|
" Some servers have issues with backup files, see #649
|
||||||
|
set nobackup
|
||||||
|
set nowritebackup
|
||||||
|
|
||||||
|
" Better display for messages
|
||||||
|
set cmdheight=2
|
||||||
|
|
||||||
|
" You will have bad experience for diagnostic messages when it's default 4000.
|
||||||
|
set updatetime=300
|
||||||
|
|
||||||
|
" don't give |ins-completion-menu| messages.
|
||||||
|
set shortmess+=c
|
||||||
|
|
||||||
|
" always show signcolumns
|
||||||
|
set signcolumn=yes
|
||||||
|
|
||||||
|
" python .env-contains-pythonpath support
|
||||||
|
autocmd FileType python let b:coc_root_patterns = ['.cocroot', '.git', '.env']
|
||||||
|
|
||||||
|
" useful key shortcuts
|
||||||
|
nmap <silent> rn <Plug>(coc-rename)
|
||||||
|
nmap <silent> td <Plug>(coc-definition)
|
||||||
|
nmap <silent> ty <Plug>(coc-type-definition)
|
||||||
|
nmap <silent> ti <Plug>(coc-implementation)
|
||||||
|
nmap <silent> tr <Plug>(coc-references)
|
||||||
|
nmap <silent> te <Plug>(coc-diagnostic-next-error)
|
||||||
|
nmap <silent> tn <Plug>(coc-diagnostic-next)
|
||||||
|
xmap ,r <Plug>(coc-format)
|
||||||
|
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>
|
||||||
|
\ pumvisible() ? "\<C-n>" :
|
||||||
|
\ <SID>check_back_space() ? "\<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'
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Use <c-space> to trigger completion.
|
||||||
|
inoremap <silent><expr> <c-space> coc#refresh()
|
||||||
|
|
||||||
|
" Use <cr> to confirm completion, `<C-g>u` means break undo chain at current position.
|
||||||
|
" Coc only does snippet and additional edit on confirm.
|
||||||
|
inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
|
||||||
|
" Or use `complete_info` if your vim support it, like:
|
||||||
|
" inoremap <expr> <cr> complete_info()["selected"] != "-1" ? "\<C-y>" : "\<C-g>u\<CR>"
|
||||||
|
|
||||||
|
" Use K to show documentation in preview window
|
||||||
|
nnoremap <silent> K :call <SID>show_documentation()<CR>
|
||||||
|
|
||||||
|
function! s:show_documentation()
|
||||||
|
if (index(['vim','help'], &filetype) >= 0)
|
||||||
|
execute 'h '.expand('<cword>')
|
||||||
|
else
|
||||||
|
call CocAction('doHover')
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
" Highlight symbol under cursor on CursorHold
|
||||||
|
autocmd CursorHold * silent call CocActionAsync('highlight')
|
||||||
@ -1,25 +0,0 @@
|
|||||||
set cst
|
|
||||||
set csre
|
|
||||||
|
|
||||||
"list of reference
|
|
||||||
nmap <unique> <C-s>s :cs find s <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
"definition
|
|
||||||
nmap <unique> <C-s>g :cs find g <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
"call
|
|
||||||
nmap <unique> <C-s>c :cs find c <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
nmap <unique> <C-s>t :cs find t <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
nmap <unique> <C-s>e :cs find e <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
nmap <unique> <C-s>f :cs find f <C-R>=expand("<cfile>")<CR><CR>
|
|
||||||
nmap <unique> <C-s>i :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>
|
|
||||||
nmap <unique> <C-s>d :cs find d <C-R>=expand("<cword>")<CR><CR>
|
|
||||||
|
|
||||||
function! LoadCscope()
|
|
||||||
let db = findfile("cscope.out", ".;")
|
|
||||||
if (!empty(db))
|
|
||||||
let path = strpart(db, 0, match(db, "/cscope.out$"))
|
|
||||||
set nocscopeverbose " suppress 'duplicate connection' error
|
|
||||||
exe "cs add " . db . " " . path
|
|
||||||
set cscopeverbose
|
|
||||||
endif
|
|
||||||
endfunction
|
|
||||||
au BufEnter /* call LoadCscope()
|
|
||||||
@ -0,0 +1 @@
|
|||||||
|
nnoremap ,f :CtrlSF<CR>
|
||||||
@ -1,10 +0,0 @@
|
|||||||
set wildmenu "enable ctrl-n and ctrl-p to scroll thru matches
|
|
||||||
set completeopt-=preview
|
|
||||||
|
|
||||||
" deoplete options
|
|
||||||
let g:deoplete#enable_at_startup = 1
|
|
||||||
inoremap <silent><expr> <Tab>
|
|
||||||
\ pumvisible() ? "\<C-n>" : "<Tab>"
|
|
||||||
" deoplete-clang opions
|
|
||||||
let g:deoplete#sources#clang#libclang_path = "/usr/lib/llvm-3.8/lib/libclang.so"
|
|
||||||
let g:deoplete#sources#clang#clang_header = "/usr/lib/llvm-3.8/include/clang"
|
|
||||||
@ -1 +0,0 @@
|
|||||||
autocmd! BufWritePost * Neomake
|
|
||||||
@ -0,0 +1 @@
|
|||||||
|
let g:pydocstring_formatter = 'google'
|
||||||
@ -1,2 +1,2 @@
|
|||||||
nmap <F8> :TagbarToggle<CR>
|
nmap <silent> tb :TagbarOpenAutoClose<CR>
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,49 @@
|
|||||||
|
# fuzzy finder
|
||||||
|
source /usr/share/doc/fzf/examples/key-bindings.zsh
|
||||||
|
source /usr/share/doc/fzf/examples/completion.zsh
|
||||||
|
|
||||||
|
bindkey '^H' fzf-cd-widget
|
||||||
|
time source /usr/share/virtualenvwrapper/virtualenvwrapper.sh
|
||||||
|
|
||||||
|
alias preview="fzf --preview 'bat --color \"always\" {}'"
|
||||||
|
alias rg="rg -S -p"
|
||||||
|
alias ldict="dict.cc.py en de"
|
||||||
|
alias bat='batcat'
|
||||||
|
alias unp='dtrx'
|
||||||
|
alias clearr="printf '\033[2J\033[3J\033[1;1H'"
|
||||||
|
|
||||||
|
ppvagrant() {
|
||||||
|
pushd -q ~/source/ilabs/platform-prov/vagrant
|
||||||
|
export VAGRANT_INET=1
|
||||||
|
export VAGRANT_SYNC_HOST='/home/dario/source/ilabs/'
|
||||||
|
export VAGRANT_SYNC_GUEST='/src'
|
||||||
|
export VAGRANT_SYNC_EXCLUDE='.git|venv|node_modules|.app.tar'
|
||||||
|
export VB_NO_UI=1
|
||||||
|
|
||||||
|
command vagrant $*
|
||||||
|
|
||||||
|
popd -q
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
rga-fzf() {
|
||||||
|
RG_PREFIX="rga --files-with-matches"
|
||||||
|
local file
|
||||||
|
file="$(
|
||||||
|
FZF_DEFAULT_COMMAND="$RG_PREFIX '$1'" \
|
||||||
|
fzf --sort --preview="[[ ! -z {} ]] && rga --pretty --context 5 {q} {}" \
|
||||||
|
--phony -q "$1" \
|
||||||
|
--bind "change:reload:$RG_PREFIX {q}" \
|
||||||
|
--preview-window="70%:wrap"
|
||||||
|
)" &&
|
||||||
|
echo "opening $file" &&
|
||||||
|
xdg-open "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
export PYENV_ROOT="$HOME/source/pyenv"
|
||||||
|
export PATH="$PYENV_ROOT/bin:$PATH"
|
||||||
|
|
||||||
|
export PATH=/usr/lib/cargo/bin/:$PATH:/home/dario/.local/bin/
|
||||||
|
|
||||||
|
export BAT_THEME="ansi-dark"
|
||||||
@ -0,0 +1,15 @@
|
|||||||
|
HISTSIZE=10000000
|
||||||
|
SAVEHIST=10000000
|
||||||
|
setopt BANG_HIST # Treat the '!' character specially during expansion.
|
||||||
|
setopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format.
|
||||||
|
setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits.
|
||||||
|
setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history.
|
||||||
|
setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again.
|
||||||
|
setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate.
|
||||||
|
setopt HIST_FIND_NO_DUPS # Do not display a line previously found.
|
||||||
|
setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file.
|
||||||
|
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry.
|
||||||
|
setopt HIST_VERIFY # Don't execute immediately upon history expansion.
|
||||||
|
|
||||||
|
|
||||||
|
GRML_NO_APT_ALIASES=1
|
||||||
Loading…
Reference in new issue