Replace links

This commit is contained in:
2024-02-19 16:07:53 +01:00
parent 5ade3e687f
commit 4dfa0bbe38
37 changed files with 5415 additions and 28 deletions

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/.bash_aliases

142
.bash/.bash_aliases Normal file
View File

@@ -0,0 +1,142 @@
# Make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
alias gitdotfiles='/usr/bin/git --git-dir="$HOME/.dotfiles/" --work-tree="$HOME"'
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
alias dir='dir --color=auto'
alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias diff='diff --color=auto'
fi
alias §rm='rm -vi'
alias §cp='cp -vi'
alias §mv='mv -vi'
alias §df='df -Th'
§du(){
[[ "$1" == '--help' ]] && echo "§du; §du '../*'" && return 0
du -h -x -s -- ${1:-*} | sort -r -h;
}
alias §xclip-copy='xclip -selection clipboard'
alias §xclip-paste='xclip -o -selection clipboard'
LAST_PWD_PATH="$BASH_DOTFILES/.bash_last_pwd"
[ -f "$LAST_PWD_PATH" ] && OLDPWD=`cat $LAST_PWD_PATH`
cd(){ builtin cd "$@" && echo `pwd` > "$LAST_PWD_PATH"; }
history_clean(){ awk '!seen[$0]++ {print $0}' $HOME/.bash_history; }
history_edit(){ vim $HOME/.bash_history; }
history_cat(){ LC_ALL=C cat ~/.bash_history; }
history_most_used(){ LC_ALL=C cat ~/.bash_history | cut -d ';' -f 2- | §awk 1 | sort | uniq -c | sort -r -n | head -n ${1-10}; }
§(){
[[ -z "$1" ]] && clear && return 0
echo "$ [--help]= clear or [print this text]"
alias | grep "alias §" --color=never
declare -F | grep 'declare -f §' --color=never
ls ~/bin | grep -P "^§" | sed 's/^§/~\/bin\/ §/'
}
alias §ls='ls -pQFh --group-directories-first'
alias §less='less -R -S'
alias §cd.='clear;§ls'
§cd..(){ cd $(eval printf '../'%.0s {1..$1}); }
§cd(){
[[ "$1" == '--help' ]] && echo -e "
Usage: §cd NUMBER|PATH
See: dirs -v
" && return 0
[[ -z "$1" ]] && dirs -v | sed 1d && return 0
[[ $1 =~ ^[0-9]+$ ]] && cd "$(dirs -l +$1)" && dirs -v | sed 1d && return 0
builtin pushd "$1" >/dev/null && pushd .
}
alias cd-vifm='cd `vifm --choose-dir -`'
mkcd(){ mkdir -p -- "$1" && cd -P -- "$1"; }
alias §find.='find . -maxdepth 1'
alias pdftk='java -jar $HOME/bin/pdftk-all.jar'
bw-session(){
bw logout
login=`kwallet-query kdewallet -f accounts -r Bitwarden 2> /dev/null`
export BW_CLIENTSECRET=`echo "$login" | jq -r .secret`
export BW_CLIENTID=`echo "$login" | jq -r .id`
bw login --apikey --raw
export BW_SESSION=`bw unlock --raw $(echo "$login" | jq -r .pass)` && echo "Bitwarden session ON" || echo "Bitwarden session FAILED"
unset BW_CLIENTSECRET
unset BW_CLIENTID
}
alias §psmem_all='ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem'
alias §psmem='§psmem_all | head -n 10'
alias §pscpu_all='ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu'
alias §pscpu='§pscpu_all | head -n 10'
alias §psnet_all='lsof -P -i -n'
§ping-test(){ # Pings ip address of noip.com and www.google.com.
ping -c 1 -q 8.23.224.107 | grep --color=never -A 1 -i '\---'
ping -c 1 -q www.google.com | grep --color=never -A 1 -i '\---'
}
§whoami(){
[[ "$1" == '--help' ]] && echo '§whoami; §whoami --ip' && return 0
local ip=$(curl -s ifconfig.me)
[[ "$1" == '--ip' ]] && echo "$ip" && return 0
local L=" %s\n"
printf "\n"
printf "$L" "USER: $(echo $USER)"
printf "$L" "IP ADDR: $ip"
printf "$L" "HOSTNAME: $(hostname -f)"
printf "$L" "KERNEL: $(uname -rms)"
printf "\n"
}
§cmdfu(){ curl "https://www.commandlinefu.com/commands/matching/$@/$(echo -n $@ | openssl base64)/plaintext"; }
aai(){
[[ "$1" == '--help' ]] && ai ask --help && return 0;
echo "ai ask \"$*, thanks for your help\""; ai ask "\"$*, thanks for your help\"";
}
eval "$(zoxide init --cmd cd bash)"
alias npx-wca='npx -y web-component-analyzer'
alias npx-qnm='npx -y qnm'
alias npx-hint='npx -y hint'
alias npx-markdown='nohup npx markserv'
alias zfz=fzf-carroarmato0.fzf
§url-curl(){ curl --silent -I "$1" | grep -i location; }
alias bathelp='bat --plain --language=help'
rpg(){
rpg-cli "$@"
if ( [[ "$1" == "cd" ]] || [[ "$1" == "ls" ]] ); then
[[ "$2" == "" ]] && $1 . && return 0
[[ "$2" == ".." ]] && $1 .. && return 0
[[ "-1" != "$(nodejsscript --print "s.ls().findIndex(e=> e==='$2'.replace(/\/$/, ''))")" ]] && $1 "$2" && return 0
fi
return 0
# [[ "$(rpg-cli pwd)" == "$(pwd)" ]] && return 0
# cd "$(rpg-cli pwd)"
}
rpg-dungeon(){
current=$(basename $PWD)
number_re='^[0-9]+$'
if [[ $current =~ $number_re ]]; then
next=$(($current + 1))
command mkdir -p $next && cd $next && rpg ls
elif [[ -d 1 ]] ; then
cd 1 && rpg ls
else
command mkdir -p dungeon/1 && cd dungeon/1 && rpg ls
fi
}
# alias adb-device='adb devices | tail -n +2 | head -n 1 | §awk 1'
# make-completion-wrapper, see https://gdhnotes.blogspot.com/2014/02/alias-bash-completion.html

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/.bash_completions

49
.bash/.bash_completions Normal file
View File

@@ -0,0 +1,49 @@
eval "$(gh completion -s bash)"
# gh tips: https://gist.github.com/ChristopherA/3cca24936fb2c84786a29f67bacacd3e
# used ectension: heaths/gh-label
[[ $- != *i* ]] && return # dont include rest in Vim
SCRIPT_DIR=$( builtin cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
source "$SCRIPT_DIR/complete-alias/complete_alias"
complete -F _complete_alias gitdotfiles
alias C--asana='eval "$($HOME/bin/asana.mjs completion_bash)"'
alias C--himalaya='\. "$BASH_DOTFILES/himalaya.completion"'
alias C--uu='eval "$($HOME/bin/uu --completion-bash)"'
alias C--bs='eval "$(bs .completion bash)"'
alias C--jc='eval "$(jc -B)" … newer version needed'
\. "$BASH_DOTFILES/cordova.completion"
eval "$(node --completion-bash)"
eval "$(npm completion)"
eval "$(nodejsscript --completion bash)"
_npx() {
local cur="${COMP_WORDS[COMP_CWORD]}"
if [[ $COMP_CWORD != 1 ]]; then
case "${COMP_WORDS[1]}" in
gulp)
local compls=$(npx gulp --tasks-simple)
if [[ $compls == *"__autocomplete_bash"* ]]; then
compls="$compls $(npx gulp -L __autocomplete_bash --_l=$COMP_CWORD --_c=$cur)"
fi
;;
esac
COMPREPLY=($(compgen -W "$compls" -- "$cur"))
return 0;
fi
local dir=$(pwd -P)
while [[ -n "$dir" ]]; do
if [[ ! -d $dir/node_modules/.bin ]]; then
dir=${dir%/*}
continue
fi
local execs=( `cd $dir/node_modules/.bin; find -L . -type f -executable` )
execs=( ${execs[@]/#.\//} )
COMPREPLY=( $(compgen -W "${execs[*]} serve" -- "$cur" ) )
break
done
}
complete -F _npx npx

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/.bash_jaaENV

103
.bash/.bash_jaaENV Normal file
View File

@@ -0,0 +1,103 @@
function jaaENV {
if [ "$1" = "--help" ]; then
echo "Utility to combine nvm/sdk/… in one script/config file '.jaaENV'"
echo " ↘ instead of 'nvm use 16 & sdk use …'"
echo ""
echo "Usage:"
echo " jaaENV"
echo " jaaENV [--help|--ls]"
echo " jaaENV --save …to_save (example: jaaENV --save nodejs php)"
echo ""
echo "Description:"
echo " - Without arguments loads infos from '.jaaENV'"
echo " - 'ls' shows supported options to auto load"
echo " - 'save' cerates config file '.jaaENV'"
echo ""
echo "Usage '.jaaENV' files: "
echo " typical: '\nphp=5.6\nnodejs=16.13.0'"
echo " link: '. ../.jaaENV' … use settings from parent folder"
echo " Options:"
echo " 'android_home': Exports 'ANDROID_HOME' (uses 'ANDROID_HOME_BAK') instead of new 'ANDROID_SDK_ROOT'. Value can be anything (use '1')."
echo " 'jdk': Exports 'JAVA_HOME' based on wanted version (currently 11/1.8)"
echo " 'nodejs'|'php': NodeJS/PHP versions"
echo " 'gradle': Cordova uses folder scoped → so unnecesarly"
echo ""
echo "Install: "
echo " gradle ⇒ https://sdkman.io/"
echo " node ⇒ https://github.com/nvm-sh/nvm"
echo " php ⇒ http://jdem.cz/fgyu56 + https://deb.sury.org/"
echo ""
echo "Tips:"
echo " sudo update-alternatives --set php /usr/bin/php\$php"
return 0
fi
if [ "$1" = "--save" ]; then
shift
rm -vi .jaaENV
while test $# -gt 0
do
case "$1" in
nodejs|node)
local nodejs_version=`node --version`
echo "nodejs=${nodejs_version:1}" >> .jaaENV
;;
gradle)
local gradle_version=`gradle --version | head -n 3 | tail -n 1 | §awk 2`
echo "gradle=$gradle_version" >> .jaaENV
;;
php)
local php_version=`php --version | head -n 1 | §awk 2`
echo "php=$php_version" >> .jaaENV
;;
*)
echo "unknown '$1' skipped"
;;
esac
shift
done
return 0
fi
if [ "$1" = "--ls" ]; then
echo ":: nvm ls ::\n"
nvm ls
echo ":: find /usr/bin/ -name php* ::\n"
find /usr/bin/ -name php*
echo ":: sdk ls gradle | cat :: "
sdk ls gradle | cat
return 0
fi
if [ -f "compose.yaml" ]; then
jdk=$(grep -Po 'VERSION_JAVA=\K.*' compose.yaml)
nodejs=$(grep -Po 'VERSION_NODEJS=\K.*' compose.yaml)
else
. ./.jaaENV
fi
if [ ! -z ${android_home+x} ]; then export ANDROID_HOME=$ANDROID_HOME_BAK; echo "\$ANDROID_HOME=$ANDROID_HOME"; else unset ANDROID_HOME; echo "\$ANDROID_SDK_ROOT=$ANDROID_SDK_ROOT"; fi
if [ ! -z ${android_home_is_sdk+x} ]; then export ANDROID_HOME=$ANDROID_SDK_ROOT; echo "\$ANDROID_HOME=$ANDROID_HOME"; fi
if [ ! -z ${jdk+x} ]; then
if (( $(echo "$jdk > 9" | bc -l) )); then
export JAVA_HOME_bk=$JAVA_HOME
export JAVA_HOME=/snap/android-studio/current/android-studio/jre;
elif [ ! -z ${JAVA_HOME_bk+x} ]; then
export JAVA_HOME=$JAVA_HOME_bk
fi
echo "\$JAVA_HOME=$JAVA_HOME"
fi
if [ ! -z ${nodejs+x} ]; then nvm use $nodejs; fi
if [ ! -z ${gradle+x} ]; then sdk use gradle $gradle | tr -d '\n'; echo ; fi
if [ ! -z ${php+x} ]; then
local php_local=`php --version | head -n 1 | §awk 2`
if [[ "$php_local" == "$php"* ]]; then
echo "php $php"
else
echo "php $php$php_local"
sudo update-alternatives --set php /usr/bin/php$php
sudo -k
fi
fi
unset android_home
unset nodejs
unset gradle
unset php
}

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/.bash_nvm

3
.bash/.bash_nvm Normal file
View File

@@ -0,0 +1,3 @@
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/.bash_promt

61
.bash/.bash_promt Normal file
View File

@@ -0,0 +1,61 @@
function setPromt {
if [ "$color_prompt" != yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
return
fi
case "$TERM" in
xterm*|rxvt*)
;;
*)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
return
;;
esac
PROMPT_COMMAND=updatePromt
PS2="|"
}
function updatePromt {
local prev_exit="$?"
# color_helper_>>color<< (Note: \[\]= escaping)
local chR="\[\e[1;91m\]" #red
local chW="\[\033[00m\]" #white
local chG="\[\033[01;32m\]" #green
local chB="\[\033[0;34m\]" #blue
local chP="\[\033[0;35m\]" #purple
local chY="\[\033[0;33m\]" #yellow
PS1=""
if [ $prev_exit == 0 ]; then
PS1+="$chG$chW"
else
PS1+="$chR$chW"
fi
local jobs="$(jobs | wc -l)"
if [ $jobs != 0 ]; then
PS1+="${chY}$jobs$chW"
fi
PS1+="${debian_chroot:+($debian_chroot)}"
PS1+=" At ${chG}\A${chW}"
PS1+=" by ${chP}\u${chW}"
if sudo -n true 2>/dev/null; then
PS1+="${chR} (sudo)${chW}"
fi
PS1+=" in "
if \git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
local branch="$(\git symbolic-ref -q HEAD)"
PS1+="[${branch#refs/heads/}"
local status="$(git for-each-ref --format='%(upstream:trackshort)' refs/heads | awk '!seen[$1]++ {printf $1}')"
status+="$(git status --porcelain | awk '!seen[$1]++ {printf $1}')"
if [ "$statua"s ]; then
PS1+="|$chY$status$chW"
fi
PS1+="] "
fi
PS1+="${chB}\w${chW}"
PS1+="\n:"
history -a
}
setPromt
unset color_prompt
unset -f setPromt
# vim: set filetype=sh tabstop=4 shiftwidth=4 textwidth=250 expandtab :

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/.bash_sdkman

3
.bash/.bash_sdkman Normal file
View File

@@ -0,0 +1,3 @@
#THIS MUST BE AT THE END OF THE `$HOME/.bashrc` FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/.profile_androidsdk

View File

@@ -0,0 +1,7 @@
# IMPORT IN `$HOME/.profile`
export ANDROID_HOME_BAK="$HOME/.local/share/umake/android/android-studio"
export ANDROID_SDK_ROOT="$HOME/.local/share/umake/android/android-studio-sdk"
export PATH=$PATH:$ANDROID_SDK_ROOT/tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/platform-tools/
export PATH=$PATH:$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/
export PATH=$PATH:$ANDROID_SDK_ROOT/emulator/

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/cordova.completion

134
.bash/cordova.completion Normal file
View File

@@ -0,0 +1,134 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#
platforms() {
get_cordova && COMPREPLY=( $(compgen -W "$(${CORDOVA_BIN} platform ls | tr -d "[]',")" -- $1) )
}
plugins() {
get_cordova && COMPREPLY=( $(compgen -W "$(${CORDOVA_BIN} plugin ls | tr -d "[]',")" -- $1) )
}
get_cordova() {
local cordova
if [[ -n "${CORDOVA_BIN}" ]]; then return 0; fi
cordova=$(eval echo ${COMP_WORDS[0]})
if [[ -x $cordova ]]; then CORDOVA_BIN=$cordova; return 0; fi
cordova=$(which cordova)
if [[ $? -eq 0 ]]; then CORDOVA_BIN=$cordova; return 0; fi
return 1
}
get_top_level_dir() {
local path
path=$(pwd)
while [ $path != '/' ]; do
if [ -d $path/.cordova ]; then
echo $path
return 0
fi
path=$(dirname $path)
done
return 1
}
_cordova()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
# Skip over any initial command line switches
local i=1
while [[ $i -lt ${#COMP_WORDS[*]} ]] && [[ "${COMP_WORDS[${i}]}" == -* ]]; do
i=$((i+1));
done
# For the first word, supply all of the valid top-level commands
if [[ ${COMP_CWORD} -eq $i ]]; then
opts="help create info platform plugin prepare compile build clean run emulate serve"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
case "${COMP_WORDS[$i]}" in
create)
if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
COMPREPLY=( $(compgen -d -- ${cur}) )
return 0
fi
;;
platform)
if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
opts="add rm remove ls"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
case "${COMP_WORDS[$((i+1))]}" in
add)
opts="ios android wp7 wp8 blackberry www"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0;
;;
rm|remove)
platforms ${cur}
return 0
;;
esac
;;
plugin)
if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
opts="add rm remove ls"
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
return 0
fi
case "${COMP_WORDS[$((i+1))]}" in
add)
COMPREPLY=( $(compgen nospace -d -- ${cur}) )
return 0;
;;
rm|remove)
plugins ${cur}
return 0
;;
esac
;;
prepare|compile|emulate)
platforms ${cur}
return 0
;;
build)
platforms ${cur}
COMPREPLY+=( $(compgen -W '--release --debug --help --device --emulator --buildConfig' -- ${cur}) )
return 0
;;
run)
platforms ${cur}
COMPREPLY+=( $(compgen -W '--list --noprepare --nobuild --target --release --debug --help --device --emulator --buildConfig' -- ${cur}) )
return 0
;;
serve)
if [[ ${COMP_CWORD} -eq $((i+1)) ]]; then
platforms ${cur}
return 0
fi
;;
esac
}
complete -F _cordova cordova

View File

@@ -1 +0,0 @@
/home/jaandrle/Vzdálené/GitHub/dotfiles/bash/.bash/himalaya.completion

2540
.bash/himalaya.completion Normal file

File diff suppressed because it is too large Load Diff