From b968e42f103cd316112def0b73bebc724e7b9561 Mon Sep 17 00:00:00 2001 From: pvincent Date: Mon, 18 Sep 2023 21:50:01 +0400 Subject: [PATCH] better inputrc --- inputrc | 21 +++++++++++++-------- install.sh | 2 +- tools/erase_lines | 42 ++++++++++++++++++++++++++++++++++++++++++ tools/ssl_check_domain | 5 ----- 4 files changed, 56 insertions(+), 14 deletions(-) create mode 100755 tools/erase_lines delete mode 100755 tools/ssl_check_domain diff --git a/inputrc b/inputrc index 2092970..73031ed 100644 --- a/inputrc +++ b/inputrc @@ -1,15 +1,20 @@ -## arrow up, down for history search +## completion case-insentivive +set completion-ignore-case on + +## ARROW up, down for history search "\e[A":history-search-backward "\e[B":history-search-forward -# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving +# CTRL + Right, Left for word suppressing "\e[1;5C": forward-word "\e[1;5D": backward-word -"\e[5C": forward-word -"\e[5D": backward-word -"\e\e[C": forward-word -"\e\e[D": backward-word -## completion case-insentivive -set completion-ignore-case on \ No newline at end of file +# ALT + BACKSPACE for left line suppressing +"\e[3;3~": kill-line +# ALT + DELETE for right line suppressing +"\e\C-?": backward-kill-line + +# CTRL + BACKSPACE for left word suppressing +"\C-H": backward-kill-word + diff --git a/install.sh b/install.sh index ffcbbb9..2168fb4 100755 --- a/install.sh +++ b/install.sh @@ -15,7 +15,7 @@ function install_host() { [ "$(id -u)" -ne 0 ] && echo 'root privilege required' && exit 1 if [[ ! $CURDIR == '/opt/debian-bash' ]]; then - # download and filfull /opt/debian-bash, then run it from folder + # download and fullfill /opt/debian-bash, then run it from folder if [[ -L /opt/debian-bash ]]; then cd /opt/debian-bash && ./install.sh "$PARAM1" diff --git a/tools/erase_lines b/tools/erase_lines new file mode 100755 index 0000000..c84209c --- /dev/null +++ b/tools/erase_lines @@ -0,0 +1,42 @@ +#!/bin/bash + +# Clears the entire current line regardless of terminal size. +# See the magic by running: +# { sleep 1; clear_this_line ; }& +clear_this_line(){ + printf '\r' + cols="$(tput cols)" + for i in $(seq "$cols"); do + printf ' ' + done + printf '\r' +} + +# Erases the amount of lines specified. +# Usage: erase_lines [AMOUNT] +# See the magic by running: +# { sleep 1; erase_lines 2; }& +erase_lines(){ + # Default line count to 1. + test -z "$1" && lines="1" || lines="$1" + + # This is what we use to move the cursor to previous lines. + UP='\033[1A' + + # Exit if erase count is zero. + [ "$lines" = 0 ] && return + + # Erase. + if [ "$lines" = 1 ]; then + clear_this_line + else + lines=$((lines-1)) + clear_this_line + for i in $(seq "$lines"); do + printf "$UP" + clear_this_line + done + fi +} + +erase_lines "$1" diff --git a/tools/ssl_check_domain b/tools/ssl_check_domain deleted file mode 100755 index d1214c2..0000000 --- a/tools/ssl_check_domain +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -DOMAIN_NAME=$1 -curl --insecure -v https://$DOMAIN_NAME 2>&1 | awk 'BEGIN { cert=0 } /^\* Server certificate:/ { cert=1 } /^\*/ { if (cert) print }' -