|
|
|
@@ -1,7 +1,5 @@
|
|
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
|
|
iatest=$(expr index "$-" i)
|
|
|
|
|
|
|
|
|
|
#Source global definitions
|
|
|
|
|
if [ -f /etc/bashrc ]; then
|
|
|
|
|
. /etc/bashrc
|
|
|
|
@@ -14,12 +12,6 @@ elif [ -f /etc/bash_completion ]; then
|
|
|
|
|
. /etc/bash_completion
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
reminder_output=$(remind -h ~/.config/remind/reminders)
|
|
|
|
|
|
|
|
|
|
# Check if the reminder_output is not empty
|
|
|
|
|
if [ -n "$reminder_output" ]; then
|
|
|
|
|
remind -h ~/.config/remind/reminders
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
#######################################################
|
|
|
|
|
# EXPORTS
|
|
|
|
@@ -42,13 +34,6 @@ PROMPT_COMMAND='history -a'
|
|
|
|
|
# Allow ctrl-S for history navigation (with ctrl-R)
|
|
|
|
|
stty -ixon
|
|
|
|
|
|
|
|
|
|
# Ignore case on auto-completion
|
|
|
|
|
# Note: bind used instead of sticking these in .inputrc
|
|
|
|
|
if [[ $iatest > 0 ]]; then bind "set completion-ignore-case on"; fi
|
|
|
|
|
|
|
|
|
|
# Show auto-completion list automatically, without double tab
|
|
|
|
|
if [[ $iatest > 0 ]]; then bind "set show-all-if-ambiguous On"; fi
|
|
|
|
|
|
|
|
|
|
# Set the default editor
|
|
|
|
|
export EDITOR=vim
|
|
|
|
|
export VISUAL=vim
|
|
|
|
@@ -67,6 +52,7 @@ export LESS_TERMCAP_se=$'\E[0m'
|
|
|
|
|
export LESS_TERMCAP_so=$'\E[01;44;33m'
|
|
|
|
|
export LESS_TERMCAP_ue=$'\E[0m'
|
|
|
|
|
export LESS_TERMCAP_us=$'\E[01;32m'
|
|
|
|
|
|
|
|
|
|
export LC_WHO=rorlando
|
|
|
|
|
|
|
|
|
|
# Scripts Path
|
|
|
|
@@ -75,7 +61,6 @@ PATH=$PATH:~/.local/bin
|
|
|
|
|
PATH=$PATH:~/bin
|
|
|
|
|
PATH=$PATH:/usr/local/go/bin
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Doom Path
|
|
|
|
|
PATH=$PATH:~/.config/emacs/bin/
|
|
|
|
|
|
|
|
|
@@ -83,8 +68,22 @@ PATH=$PATH:~/.config/emacs/bin/
|
|
|
|
|
PATH=$PATH:/var/lib/flatpak/exports/bin
|
|
|
|
|
PATH=$PATH:/var/lib/flatpak/app
|
|
|
|
|
|
|
|
|
|
# deadbeef path
|
|
|
|
|
PATH=$PATH:/opt/deadbeef/bin
|
|
|
|
|
|
|
|
|
|
#######################################################
|
|
|
|
|
# GOPASS
|
|
|
|
|
#######################################################
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Ensure gopass autocompletion is sourced
|
|
|
|
|
source <(gopass completion bash)
|
|
|
|
|
|
|
|
|
|
# Gopass aliases
|
|
|
|
|
alias gpi='gopass insert --multiline'
|
|
|
|
|
alias gpl='gopass ls'
|
|
|
|
|
alias gps='gopass show'
|
|
|
|
|
alias gpsclip='gopass show --clip'
|
|
|
|
|
alias gpe='gopass edit'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#######################################################
|
|
|
|
|
# ALIAS
|
|
|
|
@@ -92,7 +91,7 @@ PATH=$PATH:/opt/deadbeef/bin
|
|
|
|
|
# To temporarily bypass an alias, we preceed the command with a \
|
|
|
|
|
# EG: the ls command is aliased, but to use the normal ls command you would type \ls
|
|
|
|
|
|
|
|
|
|
# Pacman aliases
|
|
|
|
|
# Apt aliases
|
|
|
|
|
alias install='sudo apt install'
|
|
|
|
|
alias update='sudo apt update'
|
|
|
|
|
alias update='sudo apt upgrade'
|
|
|
|
@@ -100,13 +99,6 @@ alias uu='sudo apt update && sudo apt upgrade'
|
|
|
|
|
alias search='apt search'
|
|
|
|
|
alias remove='sudo apt remove'
|
|
|
|
|
|
|
|
|
|
# Rsync push music to jellyfin
|
|
|
|
|
alias music_hd_to_cleric="rsync -r -e 'ssh -p 46668' --info=progress2 /run/media/opal/e1f36c5c-4775-4549-8edc-1fa4d273b82e/music cleric:/data/media/"
|
|
|
|
|
|
|
|
|
|
# Add an "alert" alias for long running commands. Use like so:
|
|
|
|
|
# sleep 10; alert
|
|
|
|
|
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
|
|
|
|
|
|
|
|
|
|
# alias to show the date
|
|
|
|
|
alias da='date "+%Y-%m-%d %A %T %Z"'
|
|
|
|
|
|
|
|
|
@@ -154,9 +146,6 @@ alias h="history | grep "
|
|
|
|
|
# Search files in the current folder
|
|
|
|
|
alias f="find . | grep "
|
|
|
|
|
|
|
|
|
|
# Count all files (recursively) in the current folder
|
|
|
|
|
alias countfiles="for t in files links directories; do echo \`find . -type \${t:0:1} | wc -l\` \$t; done 2> /dev/null"
|
|
|
|
|
|
|
|
|
|
# Show current network connections to the server
|
|
|
|
|
alias ipview="netstat -anpl | grep :80 | awk {'print \$5'} | cut -d\":\" -f1 | sort | uniq -c | sort -n | sed -e 's/^ *//' -e 's/ *\$//'"
|
|
|
|
|
|
|
|
|
@@ -179,19 +168,10 @@ alias untar='tar -xvf'
|
|
|
|
|
alias unbz2='tar -xvjf'
|
|
|
|
|
alias ungz='tar -xvzf'
|
|
|
|
|
|
|
|
|
|
# Show all logs in /var/log
|
|
|
|
|
alias logs="sudo find /var/log -type f -exec file {} \; | grep 'text' | cut -d' ' -f1 | sed -e's/:$//g' | grep -v '[0-9]$' | xargs tail -f"
|
|
|
|
|
|
|
|
|
|
# SHA1
|
|
|
|
|
alias sha1='openssl sha1'
|
|
|
|
|
|
|
|
|
|
# Wireguard
|
|
|
|
|
alias wgup='sudo wg-quick up /etc/wireguard/wg0.conf'
|
|
|
|
|
alias wgdown='sudo wg-quick down /etc/wireguard/wg0.conf'
|
|
|
|
|
|
|
|
|
|
# Hugo
|
|
|
|
|
alias hss='hugo server --noHTTPCache'
|
|
|
|
|
|
|
|
|
|
# Work
|
|
|
|
|
alias stork='ssh stork'
|
|
|
|
|
alias mail='ssh mail'
|
|
|
|
@@ -201,61 +181,11 @@ alias keys='eval $(keychain --eval --quiet ry_ecdsa) && eval $(keychain --eval -
|
|
|
|
|
# Wget (keeps hsts files out of $HOME)
|
|
|
|
|
alias wget='wget --hsts-file="$XDG_CACHE_HOME/wget-hsts"'
|
|
|
|
|
|
|
|
|
|
alias transbr='trans :pt-BR'
|
|
|
|
|
alias tbr='trans :pt-BR'
|
|
|
|
|
|
|
|
|
|
# #######################################################
|
|
|
|
|
# # SPECIAL FUNCTIONS
|
|
|
|
|
# #######################################################
|
|
|
|
|
|
|
|
|
|
# Searches for text in all files in the current folder
|
|
|
|
|
ftext() {
|
|
|
|
|
# -i case-insensitive
|
|
|
|
|
# -I ignore binary files
|
|
|
|
|
# -H causes filename to be printed
|
|
|
|
|
# -r recursive search
|
|
|
|
|
# -n causes line number to be printed
|
|
|
|
|
# optional: -F treat search term as a literal, not a regular expression
|
|
|
|
|
# optional: -l only print filenames and not the matching lines ex. grep -irl "$1" *
|
|
|
|
|
grep -iIHrn --color=always "$1" . | less -r
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Copy file with a progress bar
|
|
|
|
|
cpp() {
|
|
|
|
|
set -e
|
|
|
|
|
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 |
|
|
|
|
|
awk '{
|
|
|
|
|
count += $NF
|
|
|
|
|
if (count % 10 == 0) {
|
|
|
|
|
percent = count / total_size * 100
|
|
|
|
|
printf "%3d%% [", percent
|
|
|
|
|
for (i=0;i<=percent;i++)
|
|
|
|
|
printf "="
|
|
|
|
|
printf ">"
|
|
|
|
|
for (i=percent;i<100;i++)
|
|
|
|
|
printf " "
|
|
|
|
|
printf "]\r"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Copy and go to the directory
|
|
|
|
|
cpg() {
|
|
|
|
|
if [ -d "$2" ]; then
|
|
|
|
|
cp $1 $2 && cd $2
|
|
|
|
|
else
|
|
|
|
|
cp $1 $2
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Move and go to the directory
|
|
|
|
|
mvg() {
|
|
|
|
|
if [ -d "$2" ]; then
|
|
|
|
|
mv $1 $2 && cd $2
|
|
|
|
|
else
|
|
|
|
|
mv $1 $2
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
#######################################################
|
|
|
|
|
# SPECIAL FUNCTIONS
|
|
|
|
|
#######################################################
|
|
|
|
|
|
|
|
|
|
# Create and go to the directory
|
|
|
|
|
mkdirg() {
|
|
|
|
@@ -263,57 +193,6 @@ mkdirg() {
|
|
|
|
|
cd $1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Goes up a specified number of directories (i.e. up 4)
|
|
|
|
|
up() {
|
|
|
|
|
local d=""
|
|
|
|
|
limit=$1
|
|
|
|
|
for ((i = 1; i <= limit; i++)); do
|
|
|
|
|
d=$d/..
|
|
|
|
|
done
|
|
|
|
|
d=$(echo $d | sed 's/^\///')
|
|
|
|
|
if [ -z "$d" ]; then
|
|
|
|
|
d=..
|
|
|
|
|
fi
|
|
|
|
|
cd $d
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Show current network information
|
|
|
|
|
netinfo() {
|
|
|
|
|
echo "--------------- Network Information ---------------"
|
|
|
|
|
/sbin/ifconfig | awk /'inet addr/ {print $2}'
|
|
|
|
|
echo ""
|
|
|
|
|
/sbin/ifconfig | awk /'Bcast/ {print $3}'
|
|
|
|
|
echo ""
|
|
|
|
|
/sbin/ifconfig | awk /'inet addr/ {print $4}'
|
|
|
|
|
|
|
|
|
|
/sbin/ifconfig | awk /'HWaddr/ {print $4,$5}'
|
|
|
|
|
echo "---------------------------------------------------"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# IP address lookup
|
|
|
|
|
alias whatismyip="whatsmyip"
|
|
|
|
|
function whatsmyip() {
|
|
|
|
|
# Dumps a list of all IP addresses for every device
|
|
|
|
|
# /sbin/ifconfig |grep -B1 "inet addr" |awk '{ if ( $1 == "inet" ) { print $2 } else if ( $2 == "Link" ) { printf "%s:" ,$1 } }' |awk -F: '{ print $1 ": " $3 }';
|
|
|
|
|
|
|
|
|
|
# Internal IP Lookup
|
|
|
|
|
echo -n "Internal IP: "
|
|
|
|
|
/sbin/ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'
|
|
|
|
|
|
|
|
|
|
# External IP Lookup
|
|
|
|
|
echo -n "External IP: "
|
|
|
|
|
wget http://smart-ip.net/myip -O - -q
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# View Apache logs
|
|
|
|
|
apachelog() {
|
|
|
|
|
if [ -f /etc/httpd/conf/httpd.conf ]; then
|
|
|
|
|
cd /var/log/httpd && ls -xAh && multitail --no-repeat -c -s 2 /var/log/httpd/*_log
|
|
|
|
|
else
|
|
|
|
|
cd /var/log/apache2 && ls -xAh && multitail --no-repeat -c -s 2 /var/log/apache2/*.log
|
|
|
|
|
fi
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#######################################################
|
|
|
|
|
# Prompt
|
|
|
|
|