Update bash config

This commit is contained in:
Thomas Dehaeze 2020-03-01 21:38:57 +01:00
parent fbd71a4d65
commit ddd338ce1d

View File

@ -23,7 +23,7 @@
:header-args:bash+: :comments both :mkdirp yes
:END:
** TODO What does that do?
** What does that do?
#+BEGIN_SRC bash
[[ $- != *i* ]] && return
#+END_SRC
@ -46,7 +46,7 @@ bind "set show-all-if-ambiguous on"
alias grep='grep --colour=auto'
#+END_SRC
** TODO Set colorful PS1 only on colorful terminals.
** Set colorful PS1 only on colorful terminals.
dircolors --print-database uses its own built-in database instead of using /etc/DIR_COLORS. Try to use the external file first to take advantage of user additions. Use internal bash globbing instead of external grep binary.
#+BEGIN_SRC bash
@ -84,11 +84,10 @@ dircolors --print-database uses its own built-in database instead of using /etc/
fi
#+END_SRC
** Some config
#+BEGIN_SRC bash
unset use_color safe_term match_lhs sh
#+END_SRC
#+BEGIN_SRC bash
xhost +local:root > /dev/null 2>&1
complete -cf sudo
@ -126,7 +125,7 @@ bind '"\e[A": history-search-backward'
bind '"\e[B": history-search-forward'
#+END_SRC
** TODO Aliases
** Aliases
*** Better defaults for some commands
#+BEGIN_SRC bash
alias cp="cp -i" # confirm before overwriting something
@ -166,26 +165,12 @@ bind '"\e[B": history-search-forward'
alias :e=nvim
#+END_SRC
*** Youtube
#+BEGIN_SRC bash
alias yt="youtube-dl --add-metadata -ic" # Download video link
alias yta="yt -x -f bestaudio/best" # Download only audio
#+END_SRC
*** Print each PATH entry on a separate line
#+BEGIN_SRC bash
alias path='echo -e ${PATH//:/\\n}'
#+END_SRC
*** TODO [#B] IP addresses - Remove the use of =dig= and =ifbashig=
Use =addr= instead
#+BEGIN_SRC bash
# alias ip="dig +short myip.opendns.com @resolver1.opendns.com"
# alias localip="ip route get 8.8.4.4 | head -1 | awk '{print $7}'"
# alias ips="ifconfig -a | grep -o 'inet6\? \(addr:\)\?\s\?\(\(\([0-9]\+\.\)\{3\}[0-9]\+\)\|[a-fA-F0-9:]\+\)' | awk '{ sub(/inet6? (addr:)? ?/, \"\"); print }'"
#+END_SRC
** TODO Functions
** Functions
*** Display colors
#+BEGIN_SRC bash
colors() {
@ -216,9 +201,7 @@ colors() {
}
#+END_SRC
*** TODO Meteo - Is Dig mandatory?
To install =dig=, use =yay -S bind-tools=
*** Meteo
#+BEGIN_SRC bash
meteo() {
if [ -n "$*" ]; then
@ -228,7 +211,6 @@ To install =dig=, use =yay -S bind-tools=
curl "$address"
else
address="wttr.in/"
address+=$(ip)
address+="?lang=fr"
curl "$address"
fi
@ -236,7 +218,7 @@ To install =dig=, use =yay -S bind-tools=
alias meteo=meteo
#+END_SRC
*** TODO Upload using transfer.sh
*** Upload using transfer.sh
#+BEGIN_SRC bash
upload() {
# write to output to tmpfile because of progress bar
@ -250,14 +232,6 @@ To install =dig=, use =yay -S bind-tools=
alias upload=upload
#+END_SRC
*** TODO Upload alternative
#+BEGIN_SRC bash
transfer() {
curl --progress-bar --upload-file "$1" https://transfer.sh/$(basename $1) | xclip -in -selection clipboard;
}
alias transfer=transfer
#+END_SRC
*** Extract archive
usage: ex <file>
@ -368,6 +342,11 @@ Force prompt to write history after every command. http://superuser.com/question
PROMPT_COMMAND="history -a; $PROMPT_COMMAND"
#+END_SRC
** Starship Prompt
#+begin_src bash
eval "$(starship init bash)"
#+end_src
* Bash Profile
:PROPERTIES:
:header-args:bash: :tangle ~/.bash_profile
@ -396,6 +375,14 @@ Force prompt to write history after every command. http://superuser.com/question
export SUDO_ASKPASS=~/bin/askpass-rofi
#+END_SRC
** Gnome Keyring Daemon
#+begin_src bash
if [ -n "$DESKTOP_SESSION" ];then
eval $(gnome-keyring-daemon --start)
export SSH_AUTH_SOCK
fi
#+end_src
** Default
#+begin_src bash
export EDITOR="nvim"
@ -431,11 +418,6 @@ Force prompt to write history after every command. http://superuser.com/question
export GOPATH=$HOME/go
#+END_SRC
*** SSH Agent
#+begin_src bash
export SSH_AUTH_SOCK="${XDG_RUNTIME_DIR}/ssh-agent.socket"
#+end_src
** Path
#+begin_src bash
PATH=$HOME/appimages:$PATH