.bash_aliases
2021-05-06 / 2024-08-19 | ||
.bash_aliases für meine Linux-Systeme
OS=$(lsb_release -si)
#Apt/Pamac
function update {
if [[ $OS == *"Manjaro"* ]]; then
sudo pamac update && flatpak update
else
sudo apt update && sudo apt dist-upgrade && sudo apt autoremove && flatpak update
fi
}
#Fragen ob apt/pamac oder flatpak?
function install {
if [[ $OS == *"Manjaro"* ]]; then
sudo pamac install $@
else
sudo apt install $@
fi
}
function search {
if [[ $OS == *"Manjaro"* ]]; then
pamac search $@ && echo '' && echo '--------' && echo '' && flatpak search $@
else
apt search $@ && echo '--------' && echo '' && flatpak search $@
fi
}
#Verzeichnis auflisten
alias ll='ls -lh'
alias lla='ls -lha'
#Copy
alias cpb='cp --backup=numbered'
#Größe von Verzeichnissen ermitteln
alias dux='du -hs *'
alias duxa='du -hs .[!.]* *'
# -h = Dynamische Göße in K/M/G
# -s = Rekursiv die Summe des Verzeichnisses (Fehlt der Parameter wird jeder Unterordner einzeln gelistet)
# * jedes Verzeichnis einzeln in diesem Ordner
# .[!.]* hiddenfiles
#Verzeichnis
alias ~='cd ~'
alias cd..='cd ..'
alias ..='cd ..'
alias ...='cd ../..'
alias ....='cd ../../..'
#Sudo
alias fuck='sudo $(fc -ln -1)' #letzten Befehl als Sudo
alias _='sudo'
#Clear
alias c='clear'
alias cls='clear'
#Taskmanager
alias psm='ps -AF'
alias ps?='ps -AF | grep' #Suchbegriff
#History
alias ?='history | grep' #Suchbegriff
alias ?x='history -d' #Zeilennummer löschen
#GO
alias goupdate='sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go*.linux-amd64.tar.gz'
# Docker
alias d='docker'
alias dimg='docker images'
alias dps='docker ps'
alias dpsa='docker ps -a'
alias drun='docker run -d --name'
alias dk='docker kill'
alias dlog='docker logs'
alias drm='docker rm'
alias drmi='docker rmi'
alias dbui='docker build . -t'
#minikube
function mykube {
minikube start --cni calico
# Bei der Erstinstallation Addons Aktivieren...
minikube addons enable metrics-server
minikube addons enable registry
# Sleep vor Push notwendig!
for i in {0..99}; do if [ $i -lt 10 ]; then echo -ne 'wait for push ... '$i'%\r'; else echo -ne 'wait for push ... '$i'%\r'; fi; sleep 0.3s; done; echo 'wait for push ... 100%'
# Push Images
docker push 192.168.49.2:5000/js-motd-kubernetes-example
docker push 192.168.49.2:5000/ubuntu-bash
}
alias majortom='mykube'
#Copilot
alias gh?='gh copilot suggest'
alias gh!='gh copilot explain'
alias ghu='gh extension upgrade gh-copilot'
#SSH Connect
function m~ssh {
mkdir -p /tmp/xbashalias/
sshfs -o idmap=user $1:/home/mani /tmp/xbashalias/
cp -f ~/.bash_aliases /tmp/xbashalias/
cp -f ~/.blerc /tmp/xbashalias/
fusermount -u /tmp/xbashalias/
ssh $1
}
alias r4g9='m~ssh 192.168.3.4'
alias k2so='ssh root@192.168.3.9'
alias l0la53='m~ssh 192.168.3.53'
alias tc14='m~ssh 192.168.5.14'
alias k4k1='m~ssh 192.168.6.41'
alias k4k2='m~ssh 192.168.6.42'
alias wac47='m~ssh 192.168.7.47'
alias l0la57='m~ssh 192.168.7.57'
alias k8z8='ssh root@192.168.9.9'
#
alias k8z8-wan='ssh root@5.75.158.2'
alias strato='ssh heister.email@ssh.strato.de'
alias r5d4='ssh -p23 u344274@95.217.92.103'
#
#SSHFS
alias mnt='sshfs -o idmap=user 192.168.3.4:/media/nas ~/nas && sshfs -o idmap=user 192.168.3.4:/var/www/html ~/web-r4g9 && sshfs -o idmap=user 192.168.5.14:/var/www/html ~/web-tc14'
alias umnt='fusermount -u ~/nas && fusermount -u ~/web-r4g9 && fusermount -u ~/web-tc14'
function m~sshfs {
mkdir ~/tmp-mnt &>/dev/null
fusermount -u ~/tmp-mnt &>/dev/null
sshfs -o idmap=user $1:/$2 ~/tmp-mnt
}
alias mnt-r4g9='m~sshfs 192.168.3.4'
alias mnt-bb8='m~sshfs 192.168.3.8'
alias mnt-k2so='m~sshfs root@192.168.3.9'
alias mnt-ig11='m~sshfs 192.168.3.11'
alias mnt-l0la53='m~sshfs 192.168.3.53'
alias mnt-tc14='m~sshfs 192.168.5.14'
alias mnt-wac47='m~sshfs 192.168.7.47'
alias mnt-l0la57='m~sshfs 192.168.7.57'
alias mnt-k8z8='m~sshfs root@192.168.9.9'
#
♯crypt♯
#
alias umntt='fusermount -u ~/tmp-mnt'
#NAS
alias nas='if [[ -d /media/nas ]]; then cd /media/nas; else cd ~/nas; fi'
alias nas1hour='cd /media/nas1hour/nas'
alias nas1day='cd /media/nas1day/nas'
alias nas1week='cd /media/nas1week'
alias nas1month='cd /media/nas1month'
#Taschenrechner
alias calc='gnome-calculator&'
#Rechte auf/für www-data
function fight {
if [[ $OS == *"Manjaro"* ]]; then
sudo chown -R http:http /srv/http && sudo chmod -R 775 /srv/http
else
sudo chown -R www-data:www-data /var/www/html && sudo chmod -R 775 /var/www/html
fi
}
#Bash-it
alias bashitfix='sed -i "s/en_US/en_GB/g" /home/mani/.bash_it/lib/command_duration.bash'
alias bashitunfix='sed -i "s/en_GB/en_EN/g" /home/mani/.bash_it/lib/command_duration.bash'