Files
Server-scripts/os_and_install/bash_aliases.universal
T

135 lines
5.1 KiB
Bash
Raw Normal View History

2026-09-14 09:50:00 +02:00
HOST=$(hostname)
2026-10-12 20:40:28 +02:00
LOCAL_SCRIPTS="/home/lucas/scripts"
########################################################################
## NETWORK Commands
#######################################################################
2026-09-14 09:50:00 +02:00
alias pubip="wget -T 5 -qO- ifconfig.co"
alias pubip_country="wget -T 5 -qO- ifconfig.co/country"
alias ipinfo='${LOCAL_SCRIPTS}/ip_info.sh'
# Wake Host
2026-10-12 20:40:28 +02:00
alias mediawake="bash ${LOCAL_SCRIPTS}/network/wol.sh mediahost -c"
alias serverwake="bash ${LOCAL_SCRIPTS}/network/wol.sh serverhost -c"
alias quietwake="bash ${LOCAL_SCRIPTS}/network/wol.sh quiethost"
#no intenet
alias no_inet="sudo -s -g no-internet"
2026-09-14 09:50:00 +02:00
#######################################################################
## SSH Commands
#######################################################################
alias serverhost="ssh -Y serverhost"
alias quiethost="ssh -Y quiethost"
alias mediahost="ssh -Y mediahost"
alias labhost="ssh -Y labhost"
2026-09-14 09:50:00 +02:00
#######################################################################
## PYTHON Commands
#######################################################################
alias py_scripts="/home/lucas/scripts/.venv/bin/python3"
2026-09-14 09:50:00 +02:00
#######################################################################
## UTILS Commands
#######################################################################
alias please="sudo"
alias mv="mv -i"
alias cp_low="ionice -c3 cp"
2026-11-08 08:28:24 +01:00
alias rmf="/usr/bin/rm"
alias rm='trash-put'
2026-11-08 08:28:24 +01:00
alias psgrep="ps -elf | grep -v grep | grep -i "
alias aptgrep="apt list --installed | grep -i "
alias reboot="sudo /sbin/reboot"
alias shutdown="sudo /sbin/shutdown"
alias auto_update="${LOCAL_SCRIPTS}/utils/upgrade.sh"
alias scrsht="bash /home/lucas/scripts/screenschot_grab.sh"
alias mouse_repair="sudo /home/lucas/scripts/repair_mouse.sh"
alias profile="${LOCAL_SCRIPTS}/profile_motd.sh"
#######################################################################
## WALLPAPERCHANGER Commands
#######################################################################
alias WC="bash /home/lucas/scripts/utils/WallpaperChanger.sh"
#######################################################################
## VERA Commands
#######################################################################
# Passwd Mount and Grep
alias passwd_mount="sudo veracrypt -t --mount --non-interactive --stdin $DOC_DIR/Dokumente/Zeug/passwd /media/veracrypt_passwd && clear"
alias passwd_dismount="sudo veracrypt --dismount $DOC_DIR/Dokumente/Zeug/passwd && touch $DOC_DIR/Dokumente/Zeug/passwd"
alias passwd_grep="grep -i -A1 /media/veracrypt_passwd/passwd.txt -e "
# System mounts
alias system_mount="sudo veracrypt -t --mount --non-interactive --stdin /data/SystemData/Sys64/System_Data /media/veracrypt_system && clear"
alias system_dismount="sudo veracrypt --dismount /data/SystemData/Sys64/System_Data"
# Vera Mounts
alias vera_mount="sudo veracrypt -t --mount --non-interactive --stdin //media/veracrypt_system/System32/SystemData/IMG.file /media/veracrypt_vera && clear"
alias vera_dismount="sudo veracrypt --dismount /media/veracrypt_system/System32/SystemData/IMG.file"
#######################################################################
## FUNCTIONS
#######################################################################
DEFAULT_SUBNET=11
if [ "${HOST}" == "quiethost" ]; then
DEFAULT_SUBNET=0
2026-09-14 09:50:00 +02:00
fi
alias tcmcli="/usr/bin/python3 ~/git/calibration_gui/supportScripts/send_cli_command_lucas.py"
raspi() { x=$(echo $1 | grep -o '\.' | wc -l) ; if [[ $x -le 0 ]]; then ssh -X raspi@192.168.$DEFAULT_SUBNET.$1; elif [[ $x -eq 1 ]]; then ssh raspi@192.168.$1; elif [[ $x -eq 2 ]] ; then ssh raspi@192.$1; elif [[ $x -eq 3 ]]; then ssh raspi@$1; fi }
2026-09-14 09:50:00 +02:00
dircreate() {
# Create a directory for every file stem in the current directory
2026-09-14 09:50:00 +02:00
for file in *; do
[ -f "$file" ] || continue
dirname="${file%.*}"
# If no extension exists, use the full filename
[ "$dirname" = "$file" ] && dirname="$file"
mkdir -p "$dirname"
mv "$file" "$dirname/"
done
}
find_multi_video_dirs() {
# Find Dirctory with more than one Video file
local exts='mkv|mp4|avi|mov|m4v|wmv|flv|webm|ts'
find . -type d -print0 |
while IFS= read -r -d '' dir; do
count=$(find "$dir" -maxdepth 1 -type f \
| grep -Ei "\.($exts)$" \
| wc -l)
if (( count > 1 )); then
echo "$count videos: $dir"
fi
done
}
rename_dots() {
#remove dots from filenames: Dexter.1080p.mkv -> Dexter 1080p.mkv
find . -depth | while IFS= read -r path; do
[[ "$path" == "." ]] && continue
base=$(basename "$path")
dir=$(dirname "$path")
if [[ -f "$path" && "$base" == *.tar.gz ]]; then
name="${base%.tar.gz}"
newbase="${name//./ }.tar.gz"
elif [[ -f "$path" && "$base" == *.* ]]; then
name="${base%.*}"
ext="${base##*.}"
newbase="${name//./ }.${ext}"
else
newbase="${base//./ }"
fi
if [[ "$base" != "$newbase" ]]; then
newpath="$dir/$newbase"
echo "Moving: '$path' -> '$newpath'"
mv -n -- "$path" "$newpath"
fi
done
}