From f7dbd1b694e6bf43168ed1bc9ff28292d50fb54e Mon Sep 17 00:00:00 2001 From: Aleksandar 'The Cobra' Widulski Date: Sat, 30 Apr 2022 22:04:04 -0400 Subject: [PATCH] Update bashrc Signed-off-by: Aleksandar 'The Cobra' Widulski --- .bashrc | 34 ++++++++++++++++++++++++++++++---- .devspec | 2 +- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/.bashrc b/.bashrc index 7b86558..7f919e6 100644 --- a/.bashrc +++ b/.bashrc @@ -12,7 +12,7 @@ export GPG_TTY=$(tty) # We hate sudo here alias sudo='sh -c "exit 1"' # Other aliases -alias clear="printf '\033[2J\033[H'" +alias clear="printf '\033c'" # faster than ncurses clear by a lot alias c='clear' alias ls='ls --color=auto -FAh' alias ll='ls -l' @@ -30,7 +30,10 @@ alias lc='fc -nl $HISTCMD' complete -cf boas # Random string (passwords) -randstr() { tr -cd [:graph:] ($COPY_COMMAND) + printf "%s" "$( >($COPY_COMMAND) } # Get local IP -lip() { ip a | grep ${1:-$WIFI} | sed 1d | cut -d' ' -f6 | cut -d/ -f1; } +lip() { + local OLD_IFS="$IFS" + local LINE_NUM=0 + local STR_NUM=0 + while read -r LINE; do + if [[ "$LINE" == *"${1:-$WIFI}"* ]]; then + LINE_NUM=$((LINE_NUM+1)) + if [[ $LINE_NUM == 2 ]]; then + for STR in $LINE; do + STR_NUM=$((STR_NUM+1)) + if [[ $STR_NUM == 2 ]]; then + local IP="$STR" + IFS="/" + for STR in $IP; do + echo "$STR" + break 3 + done + fi + done + fi + fi + done <<< "$(ip a)" + IFS="$OLD_IFS" +} # URL-encode stdin urlencode() { diff --git a/.devspec b/.devspec index 96e16be..f172a78 100644 --- a/.devspec +++ b/.devspec @@ -8,6 +8,6 @@ if [[ "$SXMO_WM" ]]; then else UPDATE="apt update && apt upgrade && apt autoremove" COPY_COMMAND="xclip -i -selection clipboard" - PASTE_COMMAND="xclip -o" + PASTE_COMMAND="xclip -o -selection clipboard" WIFI=wlp2s0 fi