.bash* zusammengefasst (#3)
Co-authored-by: Michael Grote <michael.grote@posteo.de> Reviewed-on: #3 Co-authored-by: mg <michael.grote@posteo.de> Co-committed-by: mg <michael.grote@posteo.de>
This commit is contained in:
parent
507dd88c84
commit
c30bcc6bbc
5 changed files with 140 additions and 135 deletions
|
@ -1,29 +0,0 @@
|
|||
# tmux
|
||||
alias tmuxa="tmux a -t "
|
||||
alias tmuxn="tmux new -s "
|
||||
alias tmuxl="tmux ls"
|
||||
alias tmuxk="tmux kill-session -t"
|
||||
# abkuerzungen
|
||||
alias cls="clear"
|
||||
alias df="df -h"
|
||||
alias du="du -h"
|
||||
alias grep="grep -i --color=auto"
|
||||
alias ll="ls -lah"
|
||||
alias hostname="hostname -f"
|
||||
alias untar="tar -xzf"
|
||||
alias unmount="umount"
|
||||
# git
|
||||
alias gsps="git stash && git pull && git stash pop"
|
||||
alias gcm="git commit -m"
|
||||
alias gdel="git add . && git stash"
|
||||
# vim
|
||||
alias v="view"
|
||||
# docker
|
||||
alias dcu="docker-compose up"
|
||||
alias dcd="docker-compose down"
|
||||
alias dcr="docker-compose down && docker-compose up -d"
|
||||
alias lzd="docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock lazyteam/lazydocker"
|
||||
# safeguard
|
||||
alias mv="mv -i "
|
||||
alias cp="cp -i "
|
||||
alias rm="rm -i "
|
144
.bash_extra
144
.bash_extra
|
@ -1,13 +1,6 @@
|
|||
# PS1
|
||||
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
|
||||
# https://gist.github.com/justintv/168835
|
||||
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
|
||||
|
||||
# git-symbole
|
||||
# * unstaged
|
||||
# + staged
|
||||
# $ stashed
|
||||
# % untracked
|
||||
#!/bin/bash
|
||||
### PS1
|
||||
# git-symbole: * unstaged, + staged, $ stashed, % untracked
|
||||
export GIT_PS1_SHOWUNTRACKEDFILES=1
|
||||
export GIT_PS1_SHOWDIRTYSTATE=1
|
||||
export GIT_PS1_SHOWSTASHSTATE=1
|
||||
|
@ -17,10 +10,15 @@ export PS1='\n\[\e[34m\]\u@\[\e[34m\]\h \[\e[94m\]\w\[\e[33m\]$(__git_ps1) \[\e[
|
|||
#Blau User @ Bue Hostname Light Gray LightBlue Verzeichnis Yellow Git-Script LightBlue Zeilenumbruch Standard-Vordergrund-Farbe
|
||||
# https://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly
|
||||
# alle Farben sind mit \[<wert>\] escaped, sonst kann die shelle die länge nicht richtig ausrechnen
|
||||
# https://github.com/git/git/blob/master/contrib/completion/git-prompt.sh
|
||||
# https://gist.github.com/justintv/168835
|
||||
# https://misc.flogisoft.com/bash/tip_colors_and_formatting
|
||||
|
||||
### Praktische Dinge
|
||||
# Deaktiviere FlowControl
|
||||
# https://unix.stackexchange.com/questions/332791/how-to-permanently-disable-ctrl-s-in-terminal
|
||||
stty -ixon
|
||||
|
||||
# farben fur manpages
|
||||
# https://opensource.com/article/18/5/bash-tricks
|
||||
export LESS_TERMCAP_mb=$'\E[01;31m'
|
||||
|
@ -30,11 +28,137 @@ export LESS_TERMCAP_se=$'\E[0m'
|
|||
export LESS_TERMCAP_so=$'\E[01;42;30m'
|
||||
export LESS_TERMCAP_ue=$'\E[0m'
|
||||
export LESS_TERMCAP_us=$'\E[01;36m'
|
||||
|
||||
# bash history bei mehreren Session
|
||||
shopt -s histappend
|
||||
|
||||
# typo bei cd entfernen
|
||||
shopt -s cdspell
|
||||
|
||||
# enable colors
|
||||
eval "`dircolors -b`"
|
||||
|
||||
# less mit maus scrollen
|
||||
export LESS='--mouse --wheel-lines=3'
|
||||
|
||||
### Funktionen
|
||||
function sgc {
|
||||
case "$1" in
|
||||
--help)
|
||||
echo "Suche in der kompletten git-history nach "\$1""
|
||||
echo "sgc = search git commit"
|
||||
echo "sgc <suchbegriff>"
|
||||
;;
|
||||
"")
|
||||
echo "Suchbegriff fehlt..."
|
||||
;;
|
||||
*)
|
||||
git grep "$1" $(git rev-list --all)
|
||||
esac
|
||||
}
|
||||
function m2m {
|
||||
if [[ "$1" == "--help" ]]; then
|
||||
echo "Sende Datei "\$2" per Mail; Betreff = "\$1""
|
||||
echo "m2m = mail2me"
|
||||
echo "m2m <Pfad zu Datei> <Betreff>"
|
||||
else
|
||||
if [ ! -f "$2" ]; then
|
||||
echo "Dateipfad fehlt..."
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
echo "Betreff fehlt..."
|
||||
else
|
||||
echo "$1" | mail -s "$1" -A "$2" michael.grote@posteo.de
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function psk {
|
||||
if [[ "$1" == "--help" ]]; then
|
||||
echo "Beende Prozess "\$1""
|
||||
echo "psk = ps kill"
|
||||
echo "psk <prozessname>"
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
echo "Prozessname fehlt..."
|
||||
else
|
||||
ps -ef | grep "$1" | grep -v grep | awk '{ print $2 }' | xargs kill -9
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function rgf {
|
||||
if [[ "$1" == "--help" ]]; then
|
||||
echo "Finde alle Dateien die "\$1" im Namen haben."
|
||||
echo "rgf"
|
||||
echo "rgf <string>"
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
echo "Suchbegriff fehlt..."
|
||||
else
|
||||
if [[ $(which rg &> /dev/null) ]]; then
|
||||
rg --files -g *"$1"* --hidden
|
||||
else
|
||||
echo "ripgrep ist nicht installiert... suche mit 'find'"
|
||||
find . -type f -name *"$1"*
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function rgi {
|
||||
if [[ "$1" == "--help" ]]; then
|
||||
echo "Finde alle Dateien die "\$1" im Inhalt haben."
|
||||
echo "rgi"
|
||||
echo "rgi <string>"
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
echo "Suchbegriff fehlt..."
|
||||
else
|
||||
if [[ $(which rg &> /dev/null) ]]; then
|
||||
rg -i "$1"
|
||||
else
|
||||
echo "ripgrep ist nicht installiert... suche mit 'grep'"
|
||||
grep -r -n -i "$1" .
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function ssh {
|
||||
# benennt das aktuelle tmux-windows nach dem ssh-ziel
|
||||
# baut ssh-verbindung auf
|
||||
if [ -n "${TMUX}" ]; then
|
||||
tmux rename-window "$*"
|
||||
fi
|
||||
command ssh "$@"
|
||||
}
|
||||
|
||||
|
||||
### Aliase
|
||||
# tmux
|
||||
alias tmuxa="tmux a -t "
|
||||
alias tmuxn="tmux new -s "
|
||||
alias tmuxl="tmux ls"
|
||||
alias tmuxk="tmux kill-session -t"
|
||||
# abkuerzungen
|
||||
alias cls="clear"
|
||||
alias df="df -h"
|
||||
alias du="du -h"
|
||||
alias grep="grep -i --color=auto"
|
||||
alias ll="ls -lah"
|
||||
alias hostname="hostname -f"
|
||||
alias untar="tar -xzf"
|
||||
alias unmount="umount"
|
||||
# git
|
||||
alias gsps="git stash && git pull && git stash pop"
|
||||
alias gcm="git commit -m"
|
||||
alias gdel="git add . && git stash"
|
||||
# vim
|
||||
alias v="view"
|
||||
# docker
|
||||
alias dcu="docker-compose up"
|
||||
alias dcd="docker-compose down"
|
||||
alias dcr="docker-compose down && docker-compose up -d"
|
||||
alias lzd="docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock lazyteam/lazydocker"
|
||||
# safeguard
|
||||
alias mv="mv -i "
|
||||
alias cp="cp -i "
|
||||
alias rm="rm -i "
|
||||
|
|
|
@ -1,89 +0,0 @@
|
|||
#!/bin/bash
|
||||
function sgc {
|
||||
case "$1" in
|
||||
--help)
|
||||
echo "Suche in der kompletten git-history nach "\$1""
|
||||
echo "sgc = search git commit"
|
||||
echo "sgc <suchbegriff>"
|
||||
;;
|
||||
"")
|
||||
echo "Suchbegriff fehlt..."
|
||||
;;
|
||||
*)
|
||||
git grep "$1" $(git rev-list --all)
|
||||
esac
|
||||
}
|
||||
function m2m {
|
||||
if [[ "$1" == "--help" ]]; then
|
||||
echo "Sende Datei "\$2" per Mail; Betreff = "\$1""
|
||||
echo "m2m = mail2me"
|
||||
echo "m2m <Pfad zu Datei> <Betreff>"
|
||||
else
|
||||
if [ ! -f "$2" ]; then
|
||||
echo "Dateipfad fehlt..."
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
echo "Betreff fehlt..."
|
||||
else
|
||||
echo "$1" | mail -s "$1" -A "$2" michael.grote@posteo.de
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function psk {
|
||||
if [[ "$1" == "--help" ]]; then
|
||||
echo "Beende Prozess "\$1""
|
||||
echo "psk = ps kill"
|
||||
echo "psk <prozessname>"
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
echo "Prozessname fehlt..."
|
||||
else
|
||||
ps -ef | grep "$1" | grep -v grep | awk '{ print $2 }' | xargs kill -9
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function rgf {
|
||||
if [[ "$1" == "--help" ]]; then
|
||||
echo "Finde alle Dateien die "\$1" im Namen haben."
|
||||
echo "rgf"
|
||||
echo "rgf <string>"
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
echo "Suchbegriff fehlt..."
|
||||
else
|
||||
if [[ $(which rg &> /dev/null) ]]; then
|
||||
rg --files -g *"$1"* --hidden
|
||||
else
|
||||
echo "ripgrep ist nicht installiert... suche mit 'find'"
|
||||
find . -type f -name *"$1"*
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function rgi {
|
||||
if [[ "$1" == "--help" ]]; then
|
||||
echo "Finde alle Dateien die "\$1" im Inhalt haben."
|
||||
echo "rgi"
|
||||
echo "rgi <string>"
|
||||
else
|
||||
if [ -z "$1" ]; then
|
||||
echo "Suchbegriff fehlt..."
|
||||
else
|
||||
if [[ $(which rg &> /dev/null) ]]; then
|
||||
rg -i "$1"
|
||||
else
|
||||
echo "ripgrep ist nicht installiert... suche mit 'grep'"
|
||||
grep -r -n -i "$1" .
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
function ssh {
|
||||
# benennt das aktuelle tmux-windows nach dem ssh-ziel
|
||||
# baut ssh-verbindung auf
|
||||
if [ -n "${TMUX}" ]; then
|
||||
tmux rename-window "$*"
|
||||
fi
|
||||
command ssh "$@"
|
||||
}
|
|
@ -1,3 +1,4 @@
|
|||
### grote.lan
|
||||
Host dokuwiki2.grote.lan
|
||||
Host fileserver2.grote.lan
|
||||
Host fileserver2-test.grote.lan
|
||||
|
@ -38,15 +39,19 @@ Host bbs-ubuntu
|
|||
User admindp
|
||||
Host *.grote.lan
|
||||
IdentityFile ~/.ssh/ssh_key_heimserver_mg
|
||||
|
||||
### mgrote.net
|
||||
Host tor1.mgrote.net
|
||||
IdentityFile ~/.ssh/ssh_key_heimserver_mg
|
||||
User mg
|
||||
|
||||
### papa.lan
|
||||
Host qnap-nas
|
||||
HostName 192.168.3.108
|
||||
User extraadmin
|
||||
IdentityFile ~/.ssh/ssh_key_qnap_papa
|
||||
|
||||
### dp-azubiracks-md
|
||||
Host RMPHLPVE1.ausbildung.md
|
||||
Host RMPHLPVE2.ausbildung.md
|
||||
Host PLNEXT001.ausbildung.md
|
||||
|
@ -58,11 +63,10 @@ Host BLGITE001.ausbildung.md
|
|||
Host *.ausbildung.md
|
||||
IdentityFile ~/.ssh/ssh_key_azubiracksmd_mg
|
||||
|
||||
|
||||
### dp-antares
|
||||
Host dp-zcdi-gitlab
|
||||
HostName git.dataport.de
|
||||
User git
|
||||
Port 2200
|
||||
PreferredAuthentications publickey
|
||||
IdentityFile ~/.ssh/zcdi-gitlab-antares
|
||||
|
||||
|
|
|
@ -6,13 +6,8 @@ git clone https://git.mgrote.net/mg/dotfiles ~/dotfiles
|
|||
|
||||
ln -s ~/dotfiles/.tmux.conf ~/.tmux.conf
|
||||
ln -s ~/dotfiles/.vimrc ~/.vimrc
|
||||
ln -s ~/dotfiles/.bash_aliases ~/.bash_aliases
|
||||
ln -s ~/dotfiles/.bash_extra ~/.bash_extra
|
||||
ln -s ~/dotfiles/.bash_functions ~/.bash_functions
|
||||
|
||||
cat <<'EOF' >> ~/.bashrc
|
||||
source ~/dotfiles/.bash_aliases
|
||||
source ~/dotfiles/.bash_functions
|
||||
source ~/dotfiles/.bash_extra
|
||||
|
||||
EOF
|
||||
|
|
Loading…
Reference in a new issue