diff --git a/.bashrc b/.bashrc index ca17751..f45fe50 100755 --- a/.bashrc +++ b/.bashrc @@ -26,8 +26,6 @@ shopt -s checkwinsize ## autocd shopt -s autocd -# make less more friendly for non-text input files, see lesspipe(1) -[ -x /usr/bin/lesspipe.sh ] && eval "$(/usr/bin/lesspipe.sh)" # LESS options # colorize with vimcolor @@ -45,13 +43,11 @@ PROMPT_COMMAND='PS1="[\u@\h] -- \w "; echo -ne "\033]0;${USER}@${HOSTNAME}: ${P export BROWSER=w3m # ... and vim is the Best export EDITOR=vim - export PAGER=less # very min bash aliases -alias ls='ls -F --color' +alias ls='ls --color' alias l='ls -l' alias ll='ls -al' -alias wa='ssh warhol' # # bash stuff @@ -64,21 +60,31 @@ test -f ~/.dircolors && eval $(dircolors ~/.dircolors) test -d ~/dotfiles/bash_completion && { for f in ~/dotfiles/bash_completion/*.bash; do - # echo "BASH completion $f" source "$f" done; } - +# +# man +# +export MANPATH=$HOME/.local/share/man:$MANPATH export MANPAGER="less -R --use-color -Dsc -Dk+r -Dd+g -Du+c -DPgb -DEbR" export MANROFFOPT="-P -c" -# startship -# echo as faint +# +# less +# +if [ -x /usr/bin/lesspipe.sh ] +then + eval "$(lesspipe.sh)" + export LESSCOLORIZER=vimcolor +fi +export LESS="-FRX" + +# +# startship # https://starship.rs/ -# echo as faint -# echo as faint -# echo as faint +# type -t starship >/dev/null && { eval "$(starship init bash)" eval "$(starship completions bash)" @@ -86,42 +92,20 @@ type -t starship >/dev/null && { #==-- archlinux --==# -# command not find +# function command_not_found_handle () # shellcheck disable=SC1091 test -f /usr/share/doc/pkgfile/command-not-found.bash && source /usr/share/doc/pkgfile/command-not-found.bash -### .local stuffs -# manpath -export MANPATH=$HOME/.local/share/man: -# path for updatedn / locate -# export LOCATE_PATH=$HOME/.local/share/locate -# test -d "$LOCATE_PATH" || mkdir -p "$LOCATE_PATH" +# +# nix +# +# if [ -e /home/patrick/.nix-profile/etc/profile.d/nix.sh ]; then . /home/patrick/.nix-profile/etc/profile.d/nix.sh; fi -# added by Nix installer -# od it in .bash_profile if [ -e /home/patrick/.nix-profile/etc/profile.d/nix.sh ]; then . /home/patrick/.nix-profile/etc/profile.d/nix.sh; fi - -# tmux dirty hack : TERM and SSH_AGENT_PID -# test -n "$TMUX" && export TERM="xterm-256color" - -# use gpg-agent for gpg -# from gpg-agent(1) -# if [ -f "~/.gnupg/.gpg-agent-info" ]; then -# . "~/.gnupg/.gpg-agent-info" -# export GPG_AGENT_INFO -# # export SSH_AUTH_SOCK -# fi -# GPG_TTY=$(tty) -# export GPG_TTY - -# fuzzyFinder FIXME bloque la completion +# +# fuzzyFinder +# [ -f ~/.fzf.bash ] && source ~/.fzf.bash -### tuir / fork of rtv : reddit terminal Viewer -export TUIR_BROWSER=urlportal.sh -export TUIR_URLVIEWER=urlview - -# XDG -export XDG_MUSIC_DIR=~/perso/Musique/ ### PATH ################################################## # see ~/devel/dotfiles/bashrc_func @@ -135,8 +119,8 @@ function _append_path() { local append_infront=0 if test "$1" = '-r' then - append_infront=1 - shift + append_infront=1 + shift fi local path="$1" local str="$2" @@ -148,14 +132,14 @@ function _append_path() { } if echo "$path" | grep -q "$str" then - echo "$path" + echo "$path" else - if test $append_infront = 1 - then - echo "$str:$path" - else - echo "$path:$str" - fi + if test $append_infront = 1 + then + echo "$str:$path" + else + echo "$path:$str" + fi fi return 0 } @@ -164,26 +148,48 @@ function _append_path() { function _prepend_path() { _append_path -r "$1" "$2"; } ### rust -test -d "$HOME/.cargo/bin" && PATH=$(_prepend_path "$PATH" "$HOME/.cargo/bin") +PATH=$(_prepend_path "$PATH" "$HOME/.cargo/bin") -### golang - default is $HOME/go/bin +### nodejs +PATH=$(_prepend_path "$PATH" "$HOME/download/nodejs/latest/bin") +PATH=$(_prepend_path "$PATH" "$HOME/src/node/current/bin") + +### npm in user mode +# test -d "${HOME}/.npm-packages" || mkdir "${HOME}/.npm-packages" +# export NPM_PACKAGES="${HOME}/.npm-packages" +# PATH=$(_prepend_path "$PATH" "$NPM_PACKAGES/bin") +# MANPATH=$(_append_path "$MANPATH" "$NPM_PACKAGES/share/man") + +### yarn +PATH=$(_prepend_path "$PATH" "$HOME/src/yarn/latest/bin") + +# +# golang +# - default is $HOME/go/bin +# export GOPATH="$HOME/go" -test -d "$HOME"/go/bin && PATH=$(_prepend_path "$PATH" "$HOME/go/bin") -type -t buffalo > /dev/null 2>&1 && eval "$(buffalo completion bash)" +PATH=$(_prepend_path "$PATH" "$HOME/go/bin") -function bt { - echo "bash bt $*" - local opt= - test "$#" -ne 0 && opt="-m ""$*" - # shellcheck disable=SC2086 - buffalo test $opt | _gotestcolored | less -RF -} -function btv { - echo "bash btv $*" - local opt= - test "$#" -ne 0 && opt="-m ""$*" - # shellcheck disable=SC2086 - buffalo test -v $opt | _gotestcolored | less -RF +# +# gobuffalo +# +type -t buffalo > /dev/null 2>&1 && { + eval "$(buffalo completion bash)" + + function bt { + echo "bash bt $*" + local opt= + test "$#" -ne 0 && opt="-m ""$*" + # shellcheck disable=SC2086 + buffalo test $opt | _gotestcolored | less -RF + } + function btv { + echo "bash btv $*" + local opt= + test "$#" -ne 0 && opt="-m ""$*" + # shellcheck disable=SC2086 + buffalo test -v $opt | _gotestcolored | less -RF + } } # host specific bash @@ -198,70 +204,6 @@ PATH=$(_append_path "$PATH" /home/patrick/.gem/ruby/3.0.0/bin) # dont modify PATH below export PATH -# TERM -# echo " TERM=$TERM ($(tput colors) colors)" -# echo " DISPLAY=$DISPLAY" - -# -# SSH -# -# ssh-add -# from https://www.revsys.com/tidbits/ssh_auth_sock-tmux-and-you/ -function _check_ssh_agent() { - ssh-add -l -} - -# from https://wiki.archlinux.org/title/SSH_keys#ssh-agent -if ! pgrep -u "$USER" ssh-agent > /dev/null; then - ssh-agent -t 1h > "$XDG_RUNTIME_DIR/ssh-agent.env" - echo " ssh-agent created" -fi -if [ ! -f "$SSH_AUTH_SOCK" ]; then - source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null - echo " ssh-agent loaded" -fi - - -# find le last ssh-agent and export as SSH_AUTH_SOCK -# /!\ Dont launch at login -function _ssh_agent2 () { - local pid f - pid=$(pgrep --newest ssh-[a]gent) - test $? = 0 || { echo " Cant find process ssh-[a]gent";return 1; } - # echo "[D] pid=$pid" - f=$(sudo lsof -F n -p "$pid" -a -U | grep ^n | head -1) - test $? = 0 || { echo "Cant find lsof ssh-agent [pid=$pid]";return 1; } - # echo "[D] lsof=$f" - f=${f:1} - f=$(awk '{print $1}' <<<"$f") - # echo "[D] lsof|awk =$f" - # f=$(sudo lsof -p "$pid" | grep 'unix.*type=STREAM' | awk '{print $9}') - test -S "$f" || { echo "Cant find unix socket $f of ssh-agent [pid=$pid]"; return 1; } - export SSH_AUTH_SOCK="$f" - # echo " (new) export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" -} - - -function u () { - local o="$SSH_AUTH_SOCK" - echo " export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" - _ssh_agent2 - test "$o" = "$SSH_AUTH_SOCK" || echo " (new) export SSH_AUTH_SOCK=$SSH_AUTH_SOCK" -} - -# -# SSH_ASKPASS -# -# if test -f /usr/lib/ssh/x11-ssh-askpass -# then -# export SSH_ASKPASS=/usr/lib/ssh/x11-ssh-askpass -# echo "-> play with SSH_ASKPASS" -# elif test -f /usr/lib/openssh/x11-ssh-askpass -# then -# export SSH_ASKPASS=/usr/lib/openssh/x11-ssh-askpass -# echo "-> play with SSH_ASKPASS" -# fi - # mkcd function mkcd { test -n "$1" || return 1 @@ -296,8 +238,8 @@ function clean_comment () { sed $opts '/^#/d;s/#.*$//;/^ *$/d' "$1" } -function faint () { # echo as faint +function faint () { test -n "$1" || return 0 echo -e "\e[2m$*\e[m" } @@ -549,6 +491,9 @@ then # eval "$(pyenv virtualenv-init -)" fi +# export +export PATH + #_ shellcheck export SHELLCHECK_OPTS="-x"