clean bashrc
This commit is contained in:
parent
e90821e960
commit
41057419f9
211
.bashrc
211
.bashrc
|
@ -26,8 +26,6 @@ shopt -s checkwinsize
|
||||||
## autocd
|
## autocd
|
||||||
shopt -s 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
|
# LESS options
|
||||||
# colorize with vimcolor
|
# colorize with vimcolor
|
||||||
|
@ -45,13 +43,11 @@ PROMPT_COMMAND='PS1="[\u@\h] -- \w "; echo -ne "\033]0;${USER}@${HOSTNAME}: ${P
|
||||||
export BROWSER=w3m
|
export BROWSER=w3m
|
||||||
# ... and vim is the Best
|
# ... and vim is the Best
|
||||||
export EDITOR=vim
|
export EDITOR=vim
|
||||||
|
|
||||||
export PAGER=less
|
export PAGER=less
|
||||||
# very min bash aliases
|
# very min bash aliases
|
||||||
alias ls='ls -F --color'
|
alias ls='ls --color'
|
||||||
alias l='ls -l'
|
alias l='ls -l'
|
||||||
alias ll='ls -al'
|
alias ll='ls -al'
|
||||||
alias wa='ssh warhol'
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# bash stuff
|
# bash stuff
|
||||||
|
@ -64,21 +60,31 @@ test -f ~/.dircolors && eval $(dircolors ~/.dircolors)
|
||||||
test -d ~/dotfiles/bash_completion && {
|
test -d ~/dotfiles/bash_completion && {
|
||||||
for f in ~/dotfiles/bash_completion/*.bash;
|
for f in ~/dotfiles/bash_completion/*.bash;
|
||||||
do
|
do
|
||||||
# echo "BASH completion $f"
|
|
||||||
source "$f"
|
source "$f"
|
||||||
done;
|
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 MANPAGER="less -R --use-color -Dsc -Dk+r -Dd+g -Du+c -DPgb -DEbR"
|
||||||
export MANROFFOPT="-P -c"
|
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/
|
# https://starship.rs/
|
||||||
# echo as faint
|
#
|
||||||
# echo as faint
|
|
||||||
# echo as faint
|
|
||||||
type -t starship >/dev/null && {
|
type -t starship >/dev/null && {
|
||||||
eval "$(starship init bash)"
|
eval "$(starship init bash)"
|
||||||
eval "$(starship completions bash)"
|
eval "$(starship completions bash)"
|
||||||
|
@ -86,42 +92,20 @@ type -t starship >/dev/null && {
|
||||||
|
|
||||||
|
|
||||||
#==-- archlinux --==#
|
#==-- archlinux --==#
|
||||||
# command not find
|
# function command_not_found_handle ()
|
||||||
# shellcheck disable=SC1091
|
# shellcheck disable=SC1091
|
||||||
test -f /usr/share/doc/pkgfile/command-not-found.bash && source /usr/share/doc/pkgfile/command-not-found.bash
|
test -f /usr/share/doc/pkgfile/command-not-found.bash && source /usr/share/doc/pkgfile/command-not-found.bash
|
||||||
|
|
||||||
### .local stuffs
|
#
|
||||||
# manpath
|
# nix
|
||||||
export MANPATH=$HOME/.local/share/man:
|
#
|
||||||
# path for updatedn / locate
|
# if [ -e /home/patrick/.nix-profile/etc/profile.d/nix.sh ]; then . /home/patrick/.nix-profile/etc/profile.d/nix.sh; fi
|
||||||
# export LOCATE_PATH=$HOME/.local/share/locate
|
|
||||||
# test -d "$LOCATE_PATH" || mkdir -p "$LOCATE_PATH"
|
|
||||||
|
|
||||||
# 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
|
# fuzzyFinder
|
||||||
|
#
|
||||||
# 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
|
|
||||||
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
|
[ -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 ##################################################
|
### PATH ##################################################
|
||||||
# see ~/devel/dotfiles/bashrc_func
|
# see ~/devel/dotfiles/bashrc_func
|
||||||
|
@ -135,8 +119,8 @@ function _append_path() {
|
||||||
local append_infront=0
|
local append_infront=0
|
||||||
if test "$1" = '-r'
|
if test "$1" = '-r'
|
||||||
then
|
then
|
||||||
append_infront=1
|
append_infront=1
|
||||||
shift
|
shift
|
||||||
fi
|
fi
|
||||||
local path="$1"
|
local path="$1"
|
||||||
local str="$2"
|
local str="$2"
|
||||||
|
@ -148,14 +132,14 @@ function _append_path() {
|
||||||
}
|
}
|
||||||
if echo "$path" | grep -q "$str"
|
if echo "$path" | grep -q "$str"
|
||||||
then
|
then
|
||||||
echo "$path"
|
echo "$path"
|
||||||
else
|
else
|
||||||
if test $append_infront = 1
|
if test $append_infront = 1
|
||||||
then
|
then
|
||||||
echo "$str:$path"
|
echo "$str:$path"
|
||||||
else
|
else
|
||||||
echo "$path:$str"
|
echo "$path:$str"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
@ -164,26 +148,48 @@ function _append_path() {
|
||||||
function _prepend_path() { _append_path -r "$1" "$2"; }
|
function _prepend_path() { _append_path -r "$1" "$2"; }
|
||||||
|
|
||||||
### rust
|
### 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"
|
export GOPATH="$HOME/go"
|
||||||
test -d "$HOME"/go/bin && PATH=$(_prepend_path "$PATH" "$HOME/go/bin")
|
PATH=$(_prepend_path "$PATH" "$HOME/go/bin")
|
||||||
type -t buffalo > /dev/null 2>&1 && eval "$(buffalo completion bash)"
|
|
||||||
|
|
||||||
function bt {
|
#
|
||||||
echo "bash bt $*"
|
# gobuffalo
|
||||||
local opt=
|
#
|
||||||
test "$#" -ne 0 && opt="-m ""$*"
|
type -t buffalo > /dev/null 2>&1 && {
|
||||||
# shellcheck disable=SC2086
|
eval "$(buffalo completion bash)"
|
||||||
buffalo test $opt | _gotestcolored | less -RF
|
|
||||||
}
|
function bt {
|
||||||
function btv {
|
echo "bash bt $*"
|
||||||
echo "bash btv $*"
|
local opt=
|
||||||
local opt=
|
test "$#" -ne 0 && opt="-m ""$*"
|
||||||
test "$#" -ne 0 && opt="-m ""$*"
|
# shellcheck disable=SC2086
|
||||||
# shellcheck disable=SC2086
|
buffalo test $opt | _gotestcolored | less -RF
|
||||||
buffalo test -v $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
|
# host specific bash
|
||||||
|
@ -198,70 +204,6 @@ PATH=$(_append_path "$PATH" /home/patrick/.gem/ruby/3.0.0/bin)
|
||||||
# dont modify PATH below
|
# dont modify PATH below
|
||||||
export PATH
|
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
|
# mkcd
|
||||||
function mkcd {
|
function mkcd {
|
||||||
test -n "$1" || return 1
|
test -n "$1" || return 1
|
||||||
|
@ -296,8 +238,8 @@ function clean_comment () {
|
||||||
sed $opts '/^#/d;s/#.*$//;/^ *$/d' "$1"
|
sed $opts '/^#/d;s/#.*$//;/^ *$/d' "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function faint () {
|
|
||||||
# echo as faint
|
# echo as faint
|
||||||
|
function faint () {
|
||||||
test -n "$1" || return 0
|
test -n "$1" || return 0
|
||||||
echo -e "\e[2m$*\e[m"
|
echo -e "\e[2m$*\e[m"
|
||||||
}
|
}
|
||||||
|
@ -549,6 +491,9 @@ then
|
||||||
# eval "$(pyenv virtualenv-init -)"
|
# eval "$(pyenv virtualenv-init -)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# export
|
||||||
|
export PATH
|
||||||
|
|
||||||
#_ shellcheck
|
#_ shellcheck
|
||||||
export SHELLCHECK_OPTS="-x"
|
export SHELLCHECK_OPTS="-x"
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue