From d6f10829bf3bbbc55737c9acdb0d009ead6a9604 Mon Sep 17 00:00:00 2001 From: Frank Villaro-Dixon Date: Mon, 30 May 2022 22:26:55 +0200 Subject: [PATCH] bashrc: cleanup useless Signed-off-by: Frank Villaro-Dixon --- bash/.bashrc | 404 +-------------------------------------------------- 1 file changed, 3 insertions(+), 401 deletions(-) diff --git a/bash/.bashrc b/bash/.bashrc index 869d318..8e1d6e8 100644 --- a/bash/.bashrc +++ b/bash/.bashrc @@ -63,14 +63,7 @@ source ~/.bash_ps1 ############### # {{{ alias dive='docker run --rm -it -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive:latest' -alias g='grep' -alias hget='curl' -alias hpost='curl -X POST' -alias hdelete='curl -X DELETE' -alias jcurl='curl --header "Content-Type: application/json"' -alias mobatime='~/Programmation/mobatime.pl -u FVD -p $(pass web/mobatime.infomaniak.ch | grep -v login)' -alias nshttp='NSH_HTTP=http NSH_PORT=8888 nsh localhost' alias kl='kubectl' alias klks='kubectl -n kube-system' alias kp='kubectl -n pasika' @@ -80,13 +73,7 @@ alias flake='docker run --rm -v $(pwd):/data -it gitlab.infomaniak.ch:4567/produ alias hadolint='docker run --rm -v $(pwd):/data -it hadolint/hadolint:latest-debian hadolint /data/Dockerfile' alias dockre='docker' alias dokcer='docker' -alias connect='ssh ra "sudo issh ra /home/scripts/connect $1"' -alias activate='source venv/bin/activate' -alias baticolux='cd ~/Documents/baticolux' -alias spotify='spotify --force-device-scale-factor=1.0000001' alias ..='cd ..' -alias vf='cd' -alias xs='cd' alias rm='rm -i' alias cp='cp -i' @@ -102,7 +89,6 @@ if [ "$TERM" != "dumb" ]; then eval "`dircolors -b`" alias ls='ls --color=auto -N' fi -alias sl='ls -N' alias la='ls -lahN' @@ -110,18 +96,9 @@ alias la='ls -lahN' alias sudp='sudo' #fuck tpyos :p alias sudpo='sudo' -alias halt='sudo poweroff' - -#alias pacman='pacman-color' -alias pacmacn='pacman' -# '[r]emove [o]rphans' - recursively remove ALL orphaned packages -alias pacro="/usr/bin/pacman -Qtdq > /dev/null && sudo /usr/bin/pacman -Rns \$(/usr/bin/pacman -Qtdq | sed -e ':a;N;\$!ba;s/\n/ /g')" alias grep='grep --color' -alias b+='xbacklight -inc 10% -steps 1 -time 0' -alias b-='xbacklight -dec 10% -steps 1 -time 0' - alias svim='sudo vim' alias bim='vim' alias vi='vim' @@ -130,12 +107,8 @@ alias ivm='vim' alias vmi='vim' alias gl='git log --graph --abbrev-commit --pretty=oneline --decorate' -alias gitst='git status' alias gti='git' -alias git_mail='git send-email --annotate --compose origin' alias poule='git pull' -alias gs='git status' -alias gci='git commit' alias push='git push' alias makew='make' @@ -144,33 +117,10 @@ alias amke='make' alias mak='make' alias amek='make' -OCTOPUS=~/Programmation/dotfiles/Utils/octopus.sh -alias dual='$OCTOPUS monitor dual' -alias laptop='$OCTOPUS monitor laptop' -alias programming='$OCTOPUS monitor programming' -alias extern='$OCTOPUS monitor extern' -alias proj='$OCTOPUS monitor proj' -alias clone='$OCTOPUS monitor clone' -alias CV='$OCTOPUS monitor CV' - -alias volup='$OCTOPUS volume up' -alias voldown='$OCTOPUS volume down' -alias volmute='$OCTOPUS volume mute' - -alias suspend='$OCTOPUS suspend' - -alias upgrub='sudo grub-mkconfig -o /boot/grub/grub.cfg' - alias upkey='gpg --keyserver subkeys.pgp.net --send-key 6F36914A' alias shm='cd /dev/shm' -alias R='R --quiet' -alias cdu='cdu -idh' -alias dus='du -sh * | sort -h' -alias eclipseJEE='/home/frank/Programmation/J2EE/eclipse/eclipse' -alias mst='mvn install -DskipTests' alias arc='tig' -alias phpserver='php -S localhost:8080' # }}} @@ -194,56 +144,7 @@ function back { cd $MY_LAST } -function pdfsearch #{{{ -{ - for pdf in *.pdf; do - pdftotext "$pdf" - | grep --color --with-filename --label="$pdf" "$1"; - done -} -#}}} -function man { #{{{ - env LESS_TERMCAP_mb=$'\E[01;31m' \ - LESS_TERMCAP_md=$'\E[01;38;5;74m' \ - LESS_TERMCAP_me=$'\E[0m' \ - LESS_TERMCAP_se=$'\E[0m' \ - LESS_TERMCAP_so=$'\E[38;5;246m' \ - LESS_TERMCAP_ue=$'\E[0m' \ - LESS_TERMCAP_us=$'\E[04;38;5;146m' \ - man "$@" -} #}}} - -#if [[ -z $SSH_CLIENT ]]; then -if false; then - alias ssh='my_ssh' - function my_ssh #{{{ - { - ssh-add -l | grep id_rsa.auth > /dev/null - if [ $? -eq 1 ]; then - echo -e "$RED Please enter ssh passphrase ;) $DFT" - ssh-add ~/.ssh/id_rsa.auth - fi; - /usr/bin/ssh "$@" - } - # }}} - - alias scp='my_scp' - function my_scp #{{{ - { - ssh-add -l | grep id_rsa.auth > /dev/null - if [ $? -eq 1 ]; then - echo -e "$RED Please enter ssh passphrase ;) $DFT" - ssh-add ~/.ssh/id_rsa.auth - fi; - /usr/bin/scp "$@" - } - # }}} -fi - -function logs #{{{ -{ - tail -f $1 | ccze -A -} # }}} function mkcd #{{{ { @@ -252,282 +153,6 @@ function mkcd #{{{ } # }}} -function extract #{{{ -{ - local e=0 i c - for i; do - if [ -f $i && -r $i ]; then - c= - case $i in - *.tar.bz2) c='tar xjf' ;; - *.tar.gz) c='tar xzf' ;; - *.bz2) c='bunzip2' ;; - *.gz) c='gunzip' ;; - *.tar) c='tar xf' ;; - *.tbz2) c='tar xjf' ;; - *.tgz) c='tar xzf' ;; - *.7z) c='7z x' ;; - *.Z) c='uncompress' ;; - *.exe) c='cabextract' ;; - *.rar) c='unrar x' ;; - *.xz) c='unxz' ;; - *.zip) c='unzip' ;; - *) echo "$0: cannot extract \`$i': Unrecognized file extension" >&2; e=1 ;; - esac - [ $c ] && command $c "$i" - else - echo "$0: cannot extract \`$i': File is unreadable" >&2; e=2 - fi - done - return $e -} -# }}} - -function study #{{{ -{ - if [ -z $1 ]; then - STUDY_PATH='' - else - if [ -d "$UNI_STUDY_PATH$1" ]; then - STUDY_PATH="$1" - else - STUDY_PATH='' - fi - fi - - builtin cd "$UNI_STUDY_PATH$STUDY_PATH" - if [ -e calendar ]; then - echo -e "$RED WORK TO DO SOON:$BLUE" - calendar -A10 - echo -e "$DFT" - fi - ls -} #}}} - -_StudyCompletion() -{ # {{{ - local cur # Pointer to current completion word. - - COMPREPLY=() # Array variable storing the possible completions. - cur=${COMP_WORDS[COMP_CWORD]} - - _STUDY_ACTUAL_DIR=`pwd` - builtin cd "$UNI_STUDY_PATH" - ALL_POSSIBLE_WORDS=(*) - builtin cd "$_STUDY_ACTUAL_DIR" - - for i in ${ALL_POSSIBLE_WORDS[@]}; do -# echo ">>>$i" - WORD=$(echo $i | grep "^$cur" | tr -d ' ') #ugly - if [ $WORD ]; then - COMPREPLY+=("$WORD"); - fi; - done - - return 0 -} # }}} -complete -F _StudyCompletion -o filenames study - - -RO_ROOT_DIRECTORY=/dev/shm/ro_$USER -ro() -{ # {{{ - if [ ! -d $RO_ROOT_DIRECTORY ]; then - mkdir $RO_ROOT_DIRECTORY - fi - - if [ -z $1 ]; then - my_root_set=`cat $RO_ROOT_DIRECTORY/default 2>/dev/null` - else - my_root_set=`cat $RO_ROOT_DIRECTORY/$1 2>/dev/null` - fi; - - if [ -n "$my_root_set" ]; then - cd $my_root_set; - else - if [ -z $1 ]; then - echo -e "root for flag $1 not set.\nSet-it with roset $1" - else - echo "root not set ! set it with roset !"; - fi - fi; -} # }}} -roset() -{ # {{{ - if [ ! -d $RO_ROOT_DIRECTORY ]; then - mkdir $RO_ROOT_DIRECTORY - fi - - if [ -z $1 ]; then - pwd > $RO_ROOT_DIRECTORY/default - else - pwd > $RO_ROOT_DIRECTORY/$1 - fi -} # }}} -_RoRosetCompletion() -{ # {{{ - local cur # Pointer to current completion word. - - COMPREPLY=() # Array variable storing the possible completions. - cur=${COMP_WORDS[COMP_CWORD]} - - _ROSET_ACTUAL_DIR=`pwd` - builtin cd $RO_ROOT_DIRECTORY - ALL_POSSIBLE_WORDS=(*) - builtin cd $_ROSET_ACTUAL_DIR - -# echo "Cur: >>$cur<<" - - for i in ${ALL_POSSIBLE_WORDS[@]}; do -# echo ">>>$i" - WORD=$(echo $i | grep "^$cur" | tr -d ' ') #ugly - if [ $WORD ]; then -# echo "blah!: >>$WORD<<" - COMPREPLY+=("$WORD"); - fi; - done - - return 0 -} # }}} -complete -F _RoRosetCompletion -o filenames ro roset - -function calc #{{{ -{ - echo "scale=3;$@" | bc -l -} #}}} - -function xournal { #{{{ - if [ -e "$1".xoj ]; then - /usr/bin/xournal "$1".xoj - else - /usr/bin/xournal "$1" - fi -} #}}} - -function mutt { #{{{ - if [ $# -eq 0 ]; then - if [ "$(pidof mutt)" ]; then - /usr/bin/mutt -R - else - /usr/bin/mutt - fi; - else - /usr/bin/mutt $@ - fi; -} #}}} - -function up2frank -{ #{{{ - if [ ! $# -eq 1 ]; then - echo "usage: up2frank FILE" - return - else - file=$(echo $1 | sed 's/ /_/g') - scp "$1" "frank@vi-di.fr:public_html/upload/$file" > /dev/null - echo "https://frank.villaro-dixon.eu/upload/$file" - fi; -} #}}} - -function rfc -{ #{{{ - - firefox http://www.ietf.org/rfc/rfc$1.txt - -} #}}} - -function tobed -{ #{{{ - if [ $? -eq 0 ]; then #want to sleep now - tstmp=`date +%s` - tstmp=$(($tstmp+1000)) #16 min to fall asleep - tomorrow=$(($tstmp + 82800)) - cycles=0; - one_cycle=5580 #93 min - while true; do - tstmp=$(($tstmp + $one_cycle)) - ((cycles++)) - hour=`echo $tstmp | date --date=@$tstmp +%-H` - if [[ $hour -gt 4 && $hour -lt 12 ]]; then - min=`echo $tstmp | date --date=@$tstmp +%M` - stime=`echo "scale=1; $one_cycle * $cycles / 3600" | bc` - - if [ $cycles -lt 5 ]; then #Not quite right: btw 7 and 9 hours -> 5/6 cycles - echo -ne $RED - elif [ $cycles -lt 6 ]; then - echo -ne $YELLOW - else - echo -ne $GREEN - fi - echo -e "$cycles cycles ($stime h)\t\tGet up: [$hour:$min]" - echo -ne $DFT - fi - - if [[ $tstmp -gt $tomorrow && $cycles -gt 6 ]]; then - break; - fi - done; - fi -} #}}} - -function bpm -{ - read n - start=`date +%s` - beats=0 - while true; do - read n - ((beats++)) - actual=`date +%s` - diff=`echo "scale=1; $beats / (($actual - $start) / 60)" | bc` - echo $diff bpm - done -} - -function op -{ - file="$1" - ext=${file##*\.} - echo file is "$ext" - case $ext in - "pdf") - echo "toto" - evince "$1" - ;; - "zip") - file-roller "$1" - ;; - "latex"|"tex") - vim "$1" - ;; - "java") - vim "$1" - ;; - "uxf") - umlet "$1" - ;; - "html") - firefox "$1" - ;; - "odt") - libreoffice "$1" - ;; - "png"|"jpg"|"jpeg") - eog "$i" - ;; - *) - xdg-open "$1" - ;; - esac -} - -function vim -{ - #Pour Ctrl-S sur vim - local STTYOPTS="$(stty --save)" - stty stop '' -ixoff - command vim "$@" - stty "$STTYOPTS" -} #CONS(OLE) function, a pretty useful functions that keeps track of @@ -565,25 +190,6 @@ function cons_set pwd > $CONS_ROOT_DIRECTORY/$TTYNO } -#cttc: Copy To my Tty Cwd -# cttc TTY_NO FILE -function cttc -{ - if [ $# -eq 2 ]; then - cwd=`cat $CONS_ROOT_DIRECTORY/$1` - cp -r "$2" "$cwd" - else - echo "cons to see terminals - cttc TERM FILE" - fi -} - -function dockat -{ - docker exec -ti $1 bash -} -alias dockip='docker inspect --format "{{ .NetworkSettings.IPAddress }}"' - -# }}} SSHAGENT=/usr/bin/ssh-agent SSHAGENTARGS="-s" @@ -607,8 +213,6 @@ export GOPATH=~/Programmation/ export PATH=$PATH:~/Programmation/dotfiles/Utils -export PATH=$PATH:/home/frank/Programmation/frank/ti.py -export PATH=$PATH:/home/frank/Programmation/pasika/utils/tools export HISTCONTROL=erasedups export HISTSIZE=99999999 @@ -624,12 +228,10 @@ PATH=$PATH:$GOPATH/bin #Launch startx when login -[[ -z $DISPLAY && $XDG_VTNR -le 4 && -z $SSH_CLIENT ]] && exec startx +#[[ -z $DISPLAY && $XDG_VTNR -le 4 && -z $SSH_CLIENT ]] && exec startx -export SENTRY_DSN='https://d0e5f2206479445ca88a427171d05f70@sentry.purple.infomaniak.ch/43' -source ~/.env-secrets -export SSH_AUTH_SOCK=/run/user/1000/gnupg/S.gpg-agent.ssh +export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) source /etc/profile.d/bash_completion.sh source <(kubectl completion bash) # completion will save a lot of time and avoid typo source <(kubectl completion bash | sed 's/kubectl/kl/g' ) # so completion works with the alias "k" @@ -637,4 +239,4 @@ source <(kubectl completion bash | sed 's/kubectl/klks/g' ) # so completion work source <(kubectl completion bash | sed 's/kubectl/kp/g' ) # so completion works with the alias "k" . <(flux completion bash) eval "$(direnv hook bash)" -export KUBECONFIG=/home/frank/Programmation/pasika/management/dev-env/pasika_dev_kubeconfig +