Update bashrc

Signed-off-by: Aleksandar 'The Cobra' Widulski <thecobra@riseup.net>
This commit is contained in:
Aleksandar 'The Cobra' Widulski 2022-04-30 22:04:04 -04:00
parent fc2e2d8078
commit f7dbd1b694
No known key found for this signature in database
GPG Key ID: C8F7E7CA91BCBA64
2 changed files with 31 additions and 5 deletions

34
.bashrc
View File

@ -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:] </dev/urandom | head -c${1:-256}; }
randstr() {
tr -cd [:graph:] </dev/urandom | read -r -n 256 RAND
echo "$RAND"
}
# Get CPU usage
cpusage() {
@ -42,11 +45,34 @@ update() { boas sh -c "$UPDATE"; }
# Im too lazy to type
copy() {
tee >($COPY_COMMAND)
printf "%s" "$(</dev/stdin)" > >($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() {

View File

@ -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