From 0cb65dc37f8b4c50adcba203ddf41cc0dec68e2b Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 12:47:20 +0100 Subject: [PATCH 01/11] Update aliases --- files/bash_aliases | 152 ++++++++++++++++++++++++++++----------------- 1 file changed, 96 insertions(+), 56 deletions(-) diff --git a/files/bash_aliases b/files/bash_aliases index 90efdf7..b988834 100644 --- a/files/bash_aliases +++ b/files/bash_aliases @@ -1,70 +1,110 @@ -### ALIASES SUDO -alias apt-get='sudo apt-get' -alias apt-cache='sudo apt-cache' -alias dpkg='sudo dpkg' -alias photo_dl='sudo gphoto2 --auto-detect -P' -alias gnux_dvd='sudo /home/warbrain/bin/gnux_dvd' - -alias svnforget='svn st | egrep '\''^(\!|\?).*\.(cpp|cc|am|h|hh|hxx|tex|png)$'\''' - -## ALIASES -alias atodo='todo -G' -alias tdg='todo -G' -alias be='bundle exec' - -alias ls='ls --color=auto -F' -alias makepatch='LC_ALL=C TZ=UTC0 diff -Naur ' -alias timidity='timidity -Oe' -alias synaptic='gksu synaptic' -alias sl='ls' -#alias cmake='colormake' -alias music123='esddsp music123' -alias xdu='du > ~/.tmp/du.out && xdu -n -c 7 ~/.tmp/du.out' -alias gnux_bgfiles='find -exec du -sh "{}" \; | egrep [0-9]M | sort -n | tail -n 11 | head -n 10' -alias fr='file-roller' -alias mp3blaster='esddsp mp3blaster' -alias ll='ls -lh' -alias llla='ls -la | less' -alias lsd="ls -F | egrep '\/$'" -alias speech='esddsp festival --tts' -alias gvimr='gvim --remote-tab' -alias grep='grep --color' -## SERVERS SSH - -alias host_dptmaths='ssh -X -C ssh.dptmaths.ens-cachan.fr -l rolland' -alias host_shamox='ssh -X -c arcfour -C -p 22 shamox.ath.cx -l warbrain' -alias host_darby='ssh -X -c arcfour -C darby -l warbrain' -alias host_daka='ssh -X -c arcfour -C daka -l warbrain' -# pass 'noir' -alias tunnel_murlock='ssh -L8882:localhost:8888 bewan@murlock.hd.free.fr -N' -#alias diades='ssh -X -c arcfour -C diades.glenux.net -l warbrain' -#alias dungeon='ssh -X -c blowfish -C dungeon -l warbrain' -#alias djeke='ssh -X -c blowfish -C djeke -l warbrain' -#alias sword='ssh -X -c blowfish -C sword.ath.cx -l warbrain' -alias ykhoo='ssh -X -c blowfish -C ykhoo.ath.cx -l warbrain' -alias daneel='ssh -X -c blowfish -C daneel.glenux.net -l warbrain' -alias ef='LD_PRELOAD=libefence.so.0.0 ' +# ## ALIASES SUDO +## MOLLY-GUARD alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' -alias divx='find /cdrom -name \*.[Aa][Vv][Ii] -o -name \*.[oO][Gg][Mm] -ok mplayer \-fs \-x 512 \-y 300 {} \;' -#alias ip='/sbin/ifconfig eth0 | grep adr | sed -e "s/^.*adr://" |sed -e "s/ Bcast.*//" ' +## BROWSING FILESYSTEM +alias ls='$( if hash exa 2>&1 >/dev/null; then echo exa ; else ls ; fi ) -F --group-directories-first ' +alias sl='ls' +alias ll='ls -lh' +alias llla='ls -la | less' +alias lsd="ls -F | egrep '\/$'" +alias xdu='du > ~/.tmp/du.out && xdu -n -c 7 ~/.tmp/du.out' +alias iexplore='xdg-open .' -alias rmplayer="mplayer -ao esd -nocache" +alias cat='$( if hash batcat 2>&1 >/dev/null ; then echo batcat ; else echo cat ; fi )' +alias bat='$( if hash batcat 2>&1 >/dev/null ; then echo batcat ; else echo cat ; fi )' -alias filter_video="egrep -i '\.(avi|mov|mpe?g|mkv|wmv|rm)$'" -alias filter_audio="egrep -i '\.(wav|flac|mp3|aac|m4a|ogg|wma)$'" + +## FILES FILTERING +alias filter_video="egrep -i '\.(avi|mov|mpe?g|mkv|wmv|rm|mp4)$'" +alias filter_audio="egrep -i '\.(wav|flac|mp3|aac|m4a|ogg|wma|opus|ape)$'" alias filter_image="egrep -i '\.(jpe?g|png|xcf(.gz)|eps|svg|gif)$'" alias filter_imageart="egrep -i '\.(xcf(.gz)?|psd|ora|svg)$'" alias filter_archive="egrep -i '\.(tar\.)?(gz|bz2|7z|tgz|zip|rar|ace|zoo|arj|lha)$'" -alias filter_document="egrep -i '\.(txt|pdf|ps|sxw|odt|doc|rtf)$'" +alias filter_document="egrep -i '\.(txt|pdf|ps|sxw|odt|doc|docx|xls|xlsx|rtf)$'" -alias pwgen="pwgen -B 10 14" -alias http_serve="python -m SimpleHTTPServer 5001" -alias scp="BINARY_SSH=scp $HOME/bin/ssh" -alias rsync="BINARY_SSH=rsync $HOME/bin/ssh" +## DEVELOPMENT +alias be='bundle exec' +alias pe='pipenv run' +alias dcp='docker-compose' +alias preload_efence='LD_PRELOAD=libefence.so.0.0 ' +alias svnforget='svn st | egrep '\''^(\!|\?).*\.(cpp|cc|am|h|hh|hxx|tex|png)$'\''' + + +## MULTIMEDIA +alias photo_dl='sudo gphoto2 --auto-detect -P' +alias rmplayer="mplayer -ao esd -nocache" +alias timidity='timidity -Oe' +alias music123='esddsp music123' +alias speech='esddsp festival --tts' +alias paria='aria2c -k 2M -x 10 -s 10' + + +## HOSTING +alias dokku='/usr/bin/ssh dokku@apps.glenux.net' +alias ge="ghostwriter" + + +## PRODUCTIVITY +alias atodo='todo -G' +alias tdg='todo -G' + +alias makepatch='LC_ALL=C TZ=UTC0 diff -Naur ' +#alias cmake='colormake' +alias gnux_bgfiles='find -exec du -sh "{}" \; | egrep [0-9]M | sort -n | tail -n 11 | head -n 10' +alias gvimr='gvim --remote-tab' +alias grep='grep --color' + +## SERVERS SSH +# pass 'noir' +#alias ip='/sbin/ifconfig eth0 | grep adr | sed -e "s/^.*adr://" |sed -e "s/ Bcast.*//" ' + +alias pwgen="pwgen -s -n -B 24 30" +alias http_serve='$( if hash python3 ; then echo python3 -m http.server 5001 ; else echo python2 -m SimpleHTTPServer 5001 ; fi )' + +# alias scp="BINARY_SSH=scp $HOME/bin/ssh" +# alias rsync="BINARY_SSH=rsync $HOME/bin/ssh" alias fuck='$(thefuck $(fc -ln -1))' alias baloostatus='balooctl status 2>/dev/null |grep Indexed |awk -v p=200 "{print int(p * \$2/\$4)/p; }"' + +alias docker_ip="docker inspect -f '{{ .NetworkSettings.IPAddress}}'" + +alias ctrlc='xclip -selection clipboard -i' +alias ctrlv='xclip -selection clipboard -o' +alias vimfm=vifm +alias mkhash='head -c 1000 /dev/urandom |sha256sum |cut -c1-9' +alias dotenv='eval "$(sed -e "/^[[:space:]]*$/d" -e "s/^/export /" < .env)"' +alias rot13="tr 'A-Za-z' 'N-ZA-Mn-za-m'" + +alias proxy_nextformation_etoile='http_proxy=http://172.16.102.254:3128 https_proxy=http://172.16.102.254:3128 no_proxy=127.0.0.1,localhost' +alias proxy_nextformation_firmingillot8='http_proxy=http://172.16.108.254:3128 https_proxy=http://172.16.108.254:3128 no_proxy=127.0.0.1,localhost' +alias proxy_nextformation_firmingillot9='http_proxy=http://172.16.109.254:3128 https_proxy=http://172.16.109.254:3128 no_proxy=127.0.0.1,localhost' +alias proxy_local8080='http_proxy=socks5://localhost:8080 https_proxy=socks5://localhost:8080' + +alias diff_code='diff --color=always -Nur -x node_modules' +alias mkemail='echo "$(date +"%Y").$(cat /dev/urandom | tr -dc "a-z0-9" | head -c 8)@glenux.net"' + + +alias pouet="echo pouet" +alias reddit=tuir +alias ebook=epr + +alias tt=timew +alias ttd='timew day :week :id' +alias tts='timew sum :week :id' +alias xc-libreoffice="libreoffice \"-env:UserInstallation=file://$HOME/.config/libreoffice/4/xopetotec\"" +alias unlock_screen='kill -9 $(pgrep [k]screenlocker)' + +alias unfmt="awk '{printf \"%s \",$0} /^$/{print \"\n\"} END{print \"\"}'" +alias cast='go-chromecast --first' +alias edit_goyo="EDITOR=goyo RAND_EDITOR=goyo" +alias edit_ghostwriter="EDITOR=ghostwriter RAND_EDITOR=ghostwriter" +alias khal_report="khal list 2021-06-01 2021-12-01 --format ' {start-time} .. {end-time} {title}'" +alias vpn_stop="nmcli connect down \$(nmcli connect show --active |awk '/wireg/ {print \$1; }' )" +alias vpn_start_rand="nmcli connect up \$(nmcli connect |awk '/wireg/ {print \$1; }' |shuf -n1)" +alias vpn_status="nmcli connection show --active | awk '/wireguard/ { print \$1; }'" + From 2a096589cd2d628c76a94249320a68be832a1395 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 12:58:18 +0100 Subject: [PATCH 02/11] Add .local/bin directory --- files/bashrc.d/00-bin-private.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/bashrc.d/00-bin-private.sh b/files/bashrc.d/00-bin-private.sh index 5b36358..8c01d5e 100644 --- a/files/bashrc.d/00-bin-private.sh +++ b/files/bashrc.d/00-bin-private.sh @@ -8,3 +8,6 @@ if [ -d "$HOME/bin" ] ; then export PATH="$HOME/bin:$PATH" fi +if [ -d "$HOME/.local/bin" ] ; then + export PATH="$HOME/.local/bin:$PATH" +fi From 91353682db19ccd8228c985487523ddd4265175f Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 13:00:04 +0100 Subject: [PATCH 03/11] Fix GREP_OPTIONS --- files/bashrc.d/70-util-grep.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/files/bashrc.d/70-util-grep.sh b/files/bashrc.d/70-util-grep.sh index 60e0992..6801543 100644 --- a/files/bashrc.d/70-util-grep.sh +++ b/files/bashrc.d/70-util-grep.sh @@ -5,5 +5,5 @@ #export GREP_COLORS # disable deprecated variable -export GREP_OPTIONS= +unset GREP_OPTIONS From f363d28c416ffd4543de938c25c03d728881ef44 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 13:00:36 +0100 Subject: [PATCH 04/11] Do not share history between sessions --- files/bashrc.d/90-shell-history.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/files/bashrc.d/90-shell-history.sh b/files/bashrc.d/90-shell-history.sh index 080813b..e581f67 100644 --- a/files/bashrc.d/90-shell-history.sh +++ b/files/bashrc.d/90-shell-history.sh @@ -1,3 +1,10 @@ +export HISTSIZE=10000 +export HISTFILESIZE=10000 + # don't put duplicate lines in the history. See bash(1) for more options -export HISTCONTROL=ignoredups +export HISTCONTROL=ignoredups:erasedups +shopt -s histappend +# Reload history on each command +#PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND" + From 5fb0244720e10b123d402936cac19d6e9c344ca1 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 13:01:17 +0100 Subject: [PATCH 05/11] Add timetracking support to prompt --- files/bashrc.d/90-prompt.sh | 107 +++++++++++++++++++++++++++--------- 1 file changed, 82 insertions(+), 25 deletions(-) diff --git a/files/bashrc.d/90-prompt.sh b/files/bashrc.d/90-prompt.sh index 36bbd64..129b1a7 100644 --- a/files/bashrc.d/90-prompt.sh +++ b/files/bashrc.d/90-prompt.sh @@ -7,13 +7,56 @@ ps1_show() { local format=$1 local fun=$2 - local str=$($fun) + local str="" + str=$($fun) if [ ! -z "$str" ]; then printf "$format\n" "$str" fi } +ps1_timetracking() { + local active_tracking="" + local active_tags_count="" + local active_tags="" + local current_tag="" + local bar_icon="" + local dom_prefix="" + # exit if timew is not installed + if ! hash timew > /dev/null 2>&1 ; then + return 0 + fi + + # exit if no active tracking + active_tracking="$(timew get dom.active)" + if [ "$active_tracking" -eq 1 ]; then + bar_icon="[▶]" + dom_prefix="dom.active" + else + bar_icon="[■]" + dom_prefix="dom.tracked.1" + fi + + active_tags_count="$(timew get "$dom_prefix.tag.count")" + if [ "$active_tags_count" -gt 0 ]; then + suffix="" + active_tags="" + if [ "$active_tags_count" -gt 1 ] && [ "$active_tracking" -eq 0 ]; then + # Bug when accessing multiple tags on non-active tasks + suffix="…" + active_tags_count=1 + fi + for tagidx in $(seq 1 "$active_tags_count") ; do + current_tag="$(timew get "$dom_prefix.tag.$tagidx")" + active_tags="$active_tags,$current_tag" + done + active_tags="$(echo "$active_tags" |cut -c2-)$suffix" + else + active_tags="(tag?)" + fi + echo "$bar_icon $active_tags " +} + ps1_vcs_branch() { local vcs="" local vcs_branch="" @@ -22,39 +65,53 @@ ps1_vcs_branch() { local vcs_root_url="" local vcs_branch_url="" - { - if hash git && git rev-parse; then - vcs='git' - vcs_branch=$(git branch |sed -n "s/\* \(.*\)/\1/p") - elif hash hg && hg -q status; then - vcs='hg' - vcs_branch=$(hg branch) - elif hash svn && svn info; then - vcs='svn' - vcs_root_path=$(LANG=C LC_ALL=C svn info |sed -n 's/^Working Copy Root Path: //p') - vcs_root_url=$(cd "$vcs_root" ; LANG=C LC_ALL=C svn info |sed -n 's/^Repository Root: //p') - vcs_branch_url=$(cd "$vcs_root" ; LANG=C LC_ALL=C svn info |sed -n 's/^URL: //p') - vcs_branch=$(echo "$vcs_branch_url" |sed "s#^$vcs_root_url/##") - fi - } >/dev/null 2>&1 + if hash git > /dev/null 2>&1 && git rev-parse > /dev/null 2>&1; then + vcs="git" + vcs_branch=$(git symbolic-ref --short -q HEAD 2>/dev/null) + vcs_branch=${vcs_branch:-(detached head)} + elif hash hg > /dev/null 2>&1 && hg -q status > /dev/null 2>&1; then + vcs="hg" + vcs_branch=$(hg branch) + elif hash svn > /dev/null 2>&1 && svn info > /dev/null 2>&1; then + vcs="svn" + # vcs_root_path=$(LANG=C LC_ALL=C svn info |sed -n "s/^Working Copy Root Path: //p") + vcs_root_url=$(cd "$vcs_root" || return ; LANG=C LC_ALL=C svn info |sed -n "s/^Repository Root: //p") + vcs_branch_url=$(cd "$vcs_root" || return ; LANG=C LC_ALL=C svn info |sed -n "s/^URL: //p") + vcs_branch=$(echo "$vcs_branch_url" |sed "s#^$vcs_root_url/##") + fi if [ -z "$vcs" ]; then echo "" else - echo "$vcs:$vcs_branch" + echo "$vcs $vcs_branch" fi } #export PS1=" \t [#\#]\n[\u@\h \w]\\$ " #PS1='\[\033[1;32m\][\t|\d]\[\033[1;33m\][\u@\h] \[\033[0;36m\]\w\$\[\033[0m\]\n ' +PS1="${ps1_context:-}" +PS1=$PS1"▪ \[\e[1;0m\]\w\[\e[0m\] " -PS1="$ps1_context ." -PS1=$PS1": \[\e[1;33m\]\w\[\e[0m\] :" -PS1=$PS1"\`ps1_show ': \[\e[1;34m\]%s\[\e[0m\] :' ps1_vcs_branch\`" # vcs branch -PS1=$PS1": \[\e[0;32m\]\t\[\e[0m\] :" -#PS1=$PS1": \[\e[1;34m\]#\#\[\e[0m\] :" #command count -PS1=$PS1": \[\e[0;31m\]\u@\h " #username -PS1=$PS1"("`uname -m`")\[\e[0m\] :" # architecture -PS1=$PS1":.\n\$ " +# Include VCS Info (eval at each line) +# shellcheck disable=SC2089 +PS1=$PS1"\$(ps1_show '▪ \[\e[1;34m\]%s\[\e[0m\] ' ps1_vcs_branch)" # vcs branch + +# Include DATETIME +# PS1=$PS1"▪ \[\e[0;32m\]\t\[\e[0m\] " + +# Include TIME TRACKING (timewarrior) +PS1=$PS1"\$(ps1_show '▪ \[\e[1;32m\]%s\[\e[0m\] ' ps1_timetracking)" # timetracking + +# Include command count +# PS1=$PS1": \[\e[1;34m\]#\#\[\e[0m\] :" + +# Include USERNAME +PS1=$PS1"▪ \[\e[0;31m\]\u@\h " + +# Include ARCHITECTURE (eval only once) +PS1=$PS1"($(uname -m))\[\e[0m\] " +PS1=$PS1"\n\$ " + +# shellcheck disable=SC2090 export PS1 From 04dd9dabf6f6d08f54d5d2ffd1a0db039b1f6542 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 13:02:25 +0100 Subject: [PATCH 06/11] Set default editors --- files/bashrc.d/70-util-editor.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/files/bashrc.d/70-util-editor.sh b/files/bashrc.d/70-util-editor.sh index 3b1a08a..ea195aa 100644 --- a/files/bashrc.d/70-util-editor.sh +++ b/files/bashrc.d/70-util-editor.sh @@ -8,3 +8,6 @@ for pager in vim nano emacs ; do fi done +export EDITOR="vim" +export MARKDOWN_DOC_EDITOR="ghostwriter" +export MARKDOWN_SLIDES_EDITOR="Marp" From d55cb58d69badeb124fce522ada8d942cd6f2782 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 13:03:01 +0100 Subject: [PATCH 07/11] Protect darcs variables --- files/bashrc.d/70-util-darcs.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/files/bashrc.d/70-util-darcs.sh b/files/bashrc.d/70-util-darcs.sh index ec2c2a4..526eee6 100644 --- a/files/bashrc.d/70-util-darcs.sh +++ b/files/bashrc.d/70-util-darcs.sh @@ -1,6 +1,6 @@ # Help darcs on network mounts -if hash darcs >/dev/null 2>&1 ; then -export DARCS_SLOPPY_LOCKS=1 +if hash darcs > /dev/null 2>&1 ; then + export DARCS_SLOPPY_LOCKS=1 fi From 80547553ad3ec4796eb0135dbcb318abdad0bfac Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 13:03:26 +0100 Subject: [PATCH 08/11] Protect ansible variables --- files/bashrc.d/70-util-ansible.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/files/bashrc.d/70-util-ansible.sh b/files/bashrc.d/70-util-ansible.sh index d2401df..35d0091 100644 --- a/files/bashrc.d/70-util-ansible.sh +++ b/files/bashrc.d/70-util-ansible.sh @@ -1,4 +1,6 @@ # Disable ansible cowsay -export ANSIBLE_NOCOWS=1 +if hash ansible > /dev/null 2>&1 ; then + export ANSIBLE_NOCOWS=1 +fi From eb14a6d8ecaee505917553a780316acd177de8b4 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 13:03:38 +0100 Subject: [PATCH 09/11] Add more config --- files/bashrc.d/50-dev-asdf.sh | 9 +++++ files/bashrc.d/50-dev-opam.sh | 5 +-- files/bashrc.d/55-dev-android.sh | 15 ++++++++ files/bashrc.d/55-dev-bash.sh | 14 ++++++++ files/bashrc.d/55-dev-debian.sh | 6 ++++ files/bashrc.d/55-dev-go.sh | 20 +++++++++++ files/bashrc.d/55-dev-opam.sh | 11 ++++++ files/bashrc.d/55-dev-rbenv.sh | 16 +++++++++ files/bashrc.d/70-util-asdf.sh | 46 ++++++++++++++++++++++++ files/bashrc.d/70-util-docker.sh | 41 +++++++++++++++++++++ files/bashrc.d/70-util-fzf.sh | 5 +++ files/bashrc.d/70-util-git.sh | 13 +++++++ files/bashrc.d/70-util-konsole.sh | 9 +++++ files/bashrc.d/70-util-mail.sh | 2 ++ files/bashrc.d/70-util-ncdu.sh | 7 ++++ files/bashrc.d/70-util-trello.sh | 5 +++ files/bashrc.d/70-util-vim.sh | 4 +++ files/bashrc.d/99-completion-cht-sh.sh | 17 +++++++++ files/bashrc.d/99-completion-helm.sh | 5 +++ files/bashrc.d/99-completion-kind.sh | 5 +++ files/bashrc.d/99-completion-kompose.sh | 5 +++ files/bashrc.d/99-completion-kubectl.sh | 5 +++ files/bashrc.d/99-completion-rmplayer.sh | 19 ++++++++++ 23 files changed, 282 insertions(+), 2 deletions(-) create mode 100644 files/bashrc.d/50-dev-asdf.sh create mode 100644 files/bashrc.d/55-dev-android.sh create mode 100644 files/bashrc.d/55-dev-bash.sh create mode 100644 files/bashrc.d/55-dev-debian.sh create mode 100644 files/bashrc.d/55-dev-go.sh create mode 100644 files/bashrc.d/55-dev-opam.sh create mode 100644 files/bashrc.d/55-dev-rbenv.sh create mode 100644 files/bashrc.d/70-util-asdf.sh create mode 100644 files/bashrc.d/70-util-docker.sh create mode 100644 files/bashrc.d/70-util-fzf.sh create mode 100644 files/bashrc.d/70-util-git.sh create mode 100644 files/bashrc.d/70-util-konsole.sh create mode 100644 files/bashrc.d/70-util-mail.sh create mode 100644 files/bashrc.d/70-util-ncdu.sh create mode 100644 files/bashrc.d/70-util-trello.sh create mode 100644 files/bashrc.d/70-util-vim.sh create mode 100644 files/bashrc.d/99-completion-cht-sh.sh create mode 100644 files/bashrc.d/99-completion-helm.sh create mode 100644 files/bashrc.d/99-completion-kind.sh create mode 100644 files/bashrc.d/99-completion-kompose.sh create mode 100644 files/bashrc.d/99-completion-kubectl.sh create mode 100644 files/bashrc.d/99-completion-rmplayer.sh diff --git a/files/bashrc.d/50-dev-asdf.sh b/files/bashrc.d/50-dev-asdf.sh new file mode 100644 index 0000000..0229c5c --- /dev/null +++ b/files/bashrc.d/50-dev-asdf.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +### +# Set up Multi-language (asdf) environment +# +if [ -d "$HOME/.asdf" ] && [ -f "$HOME/.asdf/asdf.sh" ]; then + . "$HOME/.asdf/asdf.sh" + . "$HOME/.asdf/completions/asdf.bash" +fi diff --git a/files/bashrc.d/50-dev-opam.sh b/files/bashrc.d/50-dev-opam.sh index a2cb195..39da4e7 100644 --- a/files/bashrc.d/50-dev-opam.sh +++ b/files/bashrc.d/50-dev-opam.sh @@ -5,7 +5,8 @@ # if hash opam > /dev/null 2>&1 ; then eval $(opam config env) + + # OPAM configuration + . /home/warbrain/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true fi -# OPAM configuration -#. /home/warbrain/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true diff --git a/files/bashrc.d/55-dev-android.sh b/files/bashrc.d/55-dev-android.sh new file mode 100644 index 0000000..b7bce87 --- /dev/null +++ b/files/bashrc.d/55-dev-android.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +### +# Set up Android environment +# +ANDROIDDIR="$HOME/src/Android" +if [ -d "$ANDROIDDIR" ]; then + export PATH=$ANDROIDDIR/Sdk/platform-tools:$ANDROIDDIR/Sdk/tools:$PATH +fi + +if [ -d "$HOME/android-sdk-linux" ]; then + export PATH="$HOME/android-sdk-linux/build-tools/19.1.0:$PATH" + export PATH="$HOME/android-sdk-linux/tools:$PATH" + export ANDROID_HOME="$HOME/android-sdk-linux/" +fi diff --git a/files/bashrc.d/55-dev-bash.sh b/files/bashrc.d/55-dev-bash.sh new file mode 100644 index 0000000..dd0f614 --- /dev/null +++ b/files/bashrc.d/55-dev-bash.sh @@ -0,0 +1,14 @@ + +# Change tab behaviour +# - inline completion (menu-complete) +# - of simple suggestion (complete) => default + +# bind TAB:menu-complete +case "${-:-}" in +*i*) # This shell is interactive + bind TAB:complete + ;; +*) # This shell is not interactive + ;; +esac + diff --git a/files/bashrc.d/55-dev-debian.sh b/files/bashrc.d/55-dev-debian.sh new file mode 100644 index 0000000..ca88e00 --- /dev/null +++ b/files/bashrc.d/55-dev-debian.sh @@ -0,0 +1,6 @@ +#!/bin/sh + +export DEBEMAIL="glenux@glenux.net" +export DEBFULLNAME="Glenn Y. Rolland" +export buildArea=$HOME/debian/build-area + diff --git a/files/bashrc.d/55-dev-go.sh b/files/bashrc.d/55-dev-go.sh new file mode 100644 index 0000000..92bea48 --- /dev/null +++ b/files/bashrc.d/55-dev-go.sh @@ -0,0 +1,20 @@ +#!/bin/sh + +## +# Set up Go environment +# + +if hash go > /dev/null 2>&1; then + if [ -d "$HOME/bin" ]; then + export GOPATH="$HOME/src/Go" + export PATH="$GOPATH/bin:$PATH" + + # For QT + export CGO_CXXFLAGS_ALLOW=".*" + export CGO_LDFLAGS_ALLOW=".*" + export CGO_CFLAGS_ALLOW=".*" + + export QT_DIR=/usr/lib/x86_64-linux-gnu/qt5 + export QT_PKG_CONFIG=true + fi +fi diff --git a/files/bashrc.d/55-dev-opam.sh b/files/bashrc.d/55-dev-opam.sh new file mode 100644 index 0000000..9079308 --- /dev/null +++ b/files/bashrc.d/55-dev-opam.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +## +# Set up OCaml environment +# +#if hash opam > /dev/null 2>&1 ; then +# eval $(opam config env) +#fi + +# OPAM configuration +#. /home/warbrain/.opam/opam-init/init.sh > /dev/null 2> /dev/null || true diff --git a/files/bashrc.d/55-dev-rbenv.sh b/files/bashrc.d/55-dev-rbenv.sh new file mode 100644 index 0000000..a9f3175 --- /dev/null +++ b/files/bashrc.d/55-dev-rbenv.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +### +# Set up Ruby environment +# +#export PATH=/var/lib/gems/1.8/bin:$PATH +if [ -s "$HOME/.rbenv/bin/rbenv" ]; then + export PATH="$HOME/.rbenv/bin:$PATH" + eval "$(rbenv init -)" +fi + + +SONARPATH="/usr/local/sonar-scanner-3.3.0.1492-linux" +if [ -d "$SONARPATH" ]; then + export PATH="$PATH:$SONARPATH/bin" +fi diff --git a/files/bashrc.d/70-util-asdf.sh b/files/bashrc.d/70-util-asdf.sh new file mode 100644 index 0000000..7a07b82 --- /dev/null +++ b/files/bashrc.d/70-util-asdf.sh @@ -0,0 +1,46 @@ + +# Install one or more versions of specified language +# e.g. `vmi rust` # => fzf multimode, tab to mark, enter to install +# if no plugin is supplied (e.g. `vmi`), fzf will list them for you +# Mnemonic [V]ersion [M]anager [I]nstall +asdf_install() { + local lang="$1" + local versions="" + + if [ -z "$lang" ]; then + lang=$(asdf plugin-list | fzf) + fi + + if [ -n "$lang" ]; then + versions=$(asdf list-all "$lang" | fzf -m) + if [ -n "$versions" ]; then + for version in $versions; do + asdf install "$lang" "$version" + done + fi + fi +} + +# Remove one or more versions of specified language +# e.g. `vmi rust` # => fzf multimode, tab to mark, enter to remove +# if no plugin is supplied (e.g. `vmi`), fzf will list them for you +# Mnemonic [V]ersion [M]anager [C]lean +asdf_clean() { + local lang="$1" + local versions="" + + if [ -z "$lang" ]; then + lang=$(asdf plugin-list | fzf) + fi + + if [ -n "$lang" ]; then + versions="$(asdf list "$lang" | fzf -m)" + if [ -n "$versions" ]; then + for version in $versions; do + asdf uninstall "$lang" "$version" + done + fi + fi +} + +. $HOME/.asdf/asdf.sh diff --git a/files/bashrc.d/70-util-docker.sh b/files/bashrc.d/70-util-docker.sh new file mode 100644 index 0000000..08559da --- /dev/null +++ b/files/bashrc.d/70-util-docker.sh @@ -0,0 +1,41 @@ + +WP_UID="${WP_UID:-"$(id -u)"}" +WP_GID="${WP_GID:-"$(id -g)"}" + +export WP_UID +export WP_GID + +docker_tags () { + request="$1" + repo="$(echo "$request" | awk '{split($0,a,"/"); print a[1];}')" + name="$(echo "$request" | awk '{split($0,a,"/"); print a[2];}')" + # >&2 echo "repo: $repo" + # >&2 echo "name: $name" + if [ -z "$name" ]; then + # >&2 echo "Using 'library' as repository name" + name="$repo" + repo="library" + fi + >&2 echo "Looking for $repo/$name" + + # Initial URL + url="https://registry.hub.docker.com/v2/repositories/$repo/$name/tags/?page_size=100" + ( + # Keep looping until the variable URL is empty + while [ ! -z "$url" ]; do + # >&2 echo "$url" + # Every iteration of the loop prints out a single dot to show progress as it got through all the pages (this is inline dot) + >&2 printf "." + # Curl the URL and pipe the output to Python. Python will parse the JSON and print the very first line as the next URL (it will leave it blank if there are no more pages) + # then continue to loop over the results extracting only the name; all will be stored in a variable called content + content="$(curl -s "$url" | python -c 'import sys, json; data = json.load(sys.stdin); print(data.get("next", "") or ""); print("\n".join([x["name"] for x in data["results"]]))')" + # Let's get the first line of content which contains the next URL for the loop to continue + url="$(echo "$content" | head -n 1)" + # Print the content without the first line (yes +2 is counter intuitive) + echo "$content" | tail -n +2 + done; + # Finally break the line of dots + >&2 echo + ) | cut -d '-' -f 1 | sort --version-sort --unique; +} + diff --git a/files/bashrc.d/70-util-fzf.sh b/files/bashrc.d/70-util-fzf.sh new file mode 100644 index 0000000..9e56801 --- /dev/null +++ b/files/bashrc.d/70-util-fzf.sh @@ -0,0 +1,5 @@ + +if hash fzf >/dev/null 2>&1 ; then + export FZF_DEFAULT_OPTS='--height 40% --layout=reverse --border' +fi + diff --git a/files/bashrc.d/70-util-git.sh b/files/bashrc.d/70-util-git.sh new file mode 100644 index 0000000..39201e5 --- /dev/null +++ b/files/bashrc.d/70-util-git.sh @@ -0,0 +1,13 @@ +# Go forward in Git commit hierarchy, towards particular commit +# Usage: +# gofwd v1.2.7 +# Does nothing when the parameter is not specified. +gitfwd() { + git checkout "$(git rev-list --topo-order HEAD.."$*" | tail -1)" +} + +# Go back in Git commit hierarchy +# Usage: +# goback +alias gitback='git checkout HEAD~' + diff --git a/files/bashrc.d/70-util-konsole.sh b/files/bashrc.d/70-util-konsole.sh new file mode 100644 index 0000000..e49c1ae --- /dev/null +++ b/files/bashrc.d/70-util-konsole.sh @@ -0,0 +1,9 @@ + +KONSOLE_PROFILE_NAME="" +if hash qdbus 2>&1 >/dev/null ; then + if [ -n "$KONSOLE_DBUS_SERVICE" ] && [ -n "$KONSOLE_DBUS_SESSION" ]; then + KONSOLE_PROFILE_NAME="$(qdbus $KONSOLE_DBUS_SERVICE $KONSOLE_DBUS_SESSION profile)" + fi +fi + +export KONSOLE_PROFILE_NAME diff --git a/files/bashrc.d/70-util-mail.sh b/files/bashrc.d/70-util-mail.sh new file mode 100644 index 0000000..0f9b8f5 --- /dev/null +++ b/files/bashrc.d/70-util-mail.sh @@ -0,0 +1,2 @@ + +export EMAIL=glenux@glenux.net diff --git a/files/bashrc.d/70-util-ncdu.sh b/files/bashrc.d/70-util-ncdu.sh new file mode 100644 index 0000000..95d6bb7 --- /dev/null +++ b/files/bashrc.d/70-util-ncdu.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +# NCDU +if hash ncdu 2> /dev/null ; then + export NCDU_SHELL=bash +fi + diff --git a/files/bashrc.d/70-util-trello.sh b/files/bashrc.d/70-util-trello.sh new file mode 100644 index 0000000..cb169a7 --- /dev/null +++ b/files/bashrc.d/70-util-trello.sh @@ -0,0 +1,5 @@ + +export TRELLO_USER=glenux +export TRELLO_KEY=58117ebf843d49b05bca074c5fd520ee +export TRELLO_TOKEN=011311626e32209450bb05fafad4bd6c64f1f95355f2f853b919a4d7ff2c89cf + diff --git a/files/bashrc.d/70-util-vim.sh b/files/bashrc.d/70-util-vim.sh new file mode 100644 index 0000000..2339378 --- /dev/null +++ b/files/bashrc.d/70-util-vim.sh @@ -0,0 +1,4 @@ + +export VIM_NOTES_TEMPLATE="$HOME/.vim/templates/vim-notes" +export VIM_NOTES_DIR="$HOME/Documents/GlenuxCloud/Notes" + diff --git a/files/bashrc.d/99-completion-cht-sh.sh b/files/bashrc.d/99-completion-cht-sh.sh new file mode 100644 index 0000000..4a9ae4a --- /dev/null +++ b/files/bashrc.d/99-completion-cht-sh.sh @@ -0,0 +1,17 @@ +_cht_complete() +{ + local cur prev opts + _get_comp_words_by_ref -n : cur + + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + opts="$(curl -s cheat.sh/:list)" + + if [ ${COMP_CWORD} = 1 ]; then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + __ltrim_colon_completions "$cur" + fi + return 0 +} +complete -F _cht_complete cht.sh diff --git a/files/bashrc.d/99-completion-helm.sh b/files/bashrc.d/99-completion-helm.sh new file mode 100644 index 0000000..c3384f0 --- /dev/null +++ b/files/bashrc.d/99-completion-helm.sh @@ -0,0 +1,5 @@ + +if hash helm >/dev/null 2>&1 ; then + eval "$(helm completion bash)" +fi + diff --git a/files/bashrc.d/99-completion-kind.sh b/files/bashrc.d/99-completion-kind.sh new file mode 100644 index 0000000..3d8021a --- /dev/null +++ b/files/bashrc.d/99-completion-kind.sh @@ -0,0 +1,5 @@ + +if hash kind >/dev/null 2>&1 ; then + eval "$(kind completion bash)" +fi + diff --git a/files/bashrc.d/99-completion-kompose.sh b/files/bashrc.d/99-completion-kompose.sh new file mode 100644 index 0000000..3baa347 --- /dev/null +++ b/files/bashrc.d/99-completion-kompose.sh @@ -0,0 +1,5 @@ + +if hash kompose >/dev/null 2>&1 ; then + eval "$(kompose completion bash)" +fi + diff --git a/files/bashrc.d/99-completion-kubectl.sh b/files/bashrc.d/99-completion-kubectl.sh new file mode 100644 index 0000000..7857d1a --- /dev/null +++ b/files/bashrc.d/99-completion-kubectl.sh @@ -0,0 +1,5 @@ + +if hash kubectl >/dev/null 2>&1 ; then + eval "$(kubectl completion bash)" +fi + diff --git a/files/bashrc.d/99-completion-rmplayer.sh b/files/bashrc.d/99-completion-rmplayer.sh new file mode 100644 index 0000000..eb31044 --- /dev/null +++ b/files/bashrc.d/99-completion-rmplayer.sh @@ -0,0 +1,19 @@ + +# completion programmable sur les URLs qui vont bien + +# mpv +# complete -W " 'mms://vip7.yacast.fr/encoderouifm' +# 'mms://vipbu.yacast.fr/encoderouifm' +# 'mms://vip2.yacast.fr/encoderfun1' +# 'mms://vipbu.yacast.fr/encoderfun' +# 'mms://vip1.yacast.fr/encodernrj' +# 'mms://vipbu.yacast.fr/encodernrj' +# 'mms://vip1.yacast.fr/encodernostalgie' +# " mpv +# + +_complete_mpv() { + COMPREPLY=() +} + +complete -o default -o nospace -F _complete_mpv mpv From 52b766e18e1bf7e51be4e99d3aa1f0ad55333d80 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 15:00:17 +0100 Subject: [PATCH 10/11] Add more tools --- files/bashrc.d/00-winpty.sh | 9 +++++++++ files/bashrc.d/70-util-moz-vpn.sh | 5 +++++ files/bashrc.d/70-util-travis.sh | 6 ++++++ files/bashrc.d/70-util-trello.sh | 6 +++--- 4 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 files/bashrc.d/00-winpty.sh create mode 100644 files/bashrc.d/70-util-moz-vpn.sh create mode 100644 files/bashrc.d/70-util-travis.sh diff --git a/files/bashrc.d/00-winpty.sh b/files/bashrc.d/00-winpty.sh new file mode 100644 index 0000000..2232a8f --- /dev/null +++ b/files/bashrc.d/00-winpty.sh @@ -0,0 +1,9 @@ + +# HAS_WINPTY="${HAS_WINPTY:-}" +# export HAS_WINPTY +# # Force shell restart in case winpty is not set +# if [ -z "$HAS_WINPTY" ]; then +# HAS_WINPTY=1 +# exec winpty $SHELL +# fi + diff --git a/files/bashrc.d/70-util-moz-vpn.sh b/files/bashrc.d/70-util-moz-vpn.sh new file mode 100644 index 0000000..0bd4f47 --- /dev/null +++ b/files/bashrc.d/70-util-moz-vpn.sh @@ -0,0 +1,5 @@ + +MOZ_TOKEN_FILE="$HOME/.config/mozilla-vpn/token" +if [ -f "$MOZ_TOKEN_FILE" ]; then + . "$MOZ_TOKEN_FILE" +fi diff --git a/files/bashrc.d/70-util-travis.sh b/files/bashrc.d/70-util-travis.sh new file mode 100644 index 0000000..bc51f43 --- /dev/null +++ b/files/bashrc.d/70-util-travis.sh @@ -0,0 +1,6 @@ + +# added by travis gem +if [ -f "$HOME/.travis/travis.sh" ]; then + . "$HOME/.travis/travis.sh" +fi + diff --git a/files/bashrc.d/70-util-trello.sh b/files/bashrc.d/70-util-trello.sh index cb169a7..c07ec3e 100644 --- a/files/bashrc.d/70-util-trello.sh +++ b/files/bashrc.d/70-util-trello.sh @@ -1,5 +1,5 @@ -export TRELLO_USER=glenux -export TRELLO_KEY=58117ebf843d49b05bca074c5fd520ee -export TRELLO_TOKEN=011311626e32209450bb05fafad4bd6c64f1f95355f2f853b919a4d7ff2c89cf +if [ -f "$HOME/.config/trello/glenux" ]; then + . "$HOME/.config/trello/glenux" +fi From c67a7bda49918448c22d266e9a924f92d717cd52 Mon Sep 17 00:00:00 2001 From: "Glenn Y. Rolland" Date: Fri, 31 Dec 2021 15:00:55 +0100 Subject: [PATCH 11/11] Add LIBVA_DRIVER_NAME env var for host dilong --- files/bashrc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/files/bashrc b/files/bashrc index eff621c..03b3743 100644 --- a/files/bashrc +++ b/files/bashrc @@ -11,8 +11,13 @@ if [ -d "$HOME/.bashrc.d" ]; then for script in $(find "$HOME/.bashrc.d/" -name '*.sh' |sort -n) ; do # echo "Loading `basename \"$script\"`..." # >&2 - . $script + . "$script" done fi +case "$(hostname)" in + dilong) export LIBVA_DRIVER_NAME=i965 + ;; + *) ;; +esac