Remove functions that are now binaries.

Also, input config is now part of bash.org
This commit is contained in:
Thomas Dehaeze 2020-05-26 08:33:44 +02:00
parent 14d997b598
commit d09e7873c4
2 changed files with 103 additions and 161 deletions

View File

@ -173,90 +173,32 @@ bind '"\e[B": history-search-forward'
** Functions ** Functions
*** Display colors *** Display colors
#+BEGIN_SRC bash #+BEGIN_SRC bash
colors() { colors() {
local fgc bgc vals seq0 local fgc bgc vals seq0
printf "Color escapes are %s\n" '\e[${value};...;${value}m' printf "Color escapes are %s\n" '\e[${value};...;${value}m'
printf "Values 30..37 are \e[33mforeground colors\e[m\n" printf "Values 30..37 are \e[33mforeground colors\e[m\n"
printf "Values 40..47 are \e[43mbackground colors\e[m\n" printf "Values 40..47 are \e[43mbackground colors\e[m\n"
printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n" printf "Value 1 gives a \e[1mbold-faced look\e[m\n\n"
# foreground colors # foreground colors
for fgc in {30..37}; do for fgc in {30..37}; do
# background colors # background colors
for bgc in {40..47}; do for bgc in {40..47}; do
fgc=${fgc#37} # white fgc=${fgc#37} # white
bgc=${bgc#40} # black bgc=${bgc#40} # black
vals="${fgc:+$fgc;}${bgc}" vals="${fgc:+$fgc;}${bgc}"
vals=${vals%%;} vals=${vals%%;}
seq0="${vals:+\e[${vals}m}" seq0="${vals:+\e[${vals}m}"
printf " %-9s" "${seq0:-(default)}" printf " %-9s" "${seq0:-(default)}"
printf " ${seq0}TEXT\e[m" printf " ${seq0}TEXT\e[m"
printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m" printf " \e[${vals:+${vals+$vals;}}1mBOLD\e[m"
done done
echo; echo echo; echo
done done
}
#+END_SRC
*** Meteo
#+BEGIN_SRC bash
meteo() {
if [ -n "$*" ]; then
address="wttr.in/"
address+=$*
address+="?lang=fr"
curl "$address"
else
address="wttr.in/"
address+="?lang=fr"
curl "$address"
fi
} }
alias meteo=meteo
#+END_SRC
*** Upload using transfer.sh
#+BEGIN_SRC bash
upload() {
# write to output to tmpfile because of progress bar
tmpfile=$(mktemp -t transferXXX)
# basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9]/-/g')
curl --progress-bar --upload-file "$1" "https://transfer.sh/" >> $tmpfile;
cat $tmpfile | xsel -ib;
echo "Copied:" $(cat $tmpfile);
rm -f $tmpfile;
}
alias upload=upload
#+END_SRC
*** Extract archive
usage: ex <file>
#+BEGIN_SRC bash
ex ()
{
if [ -f $1 ] ; then
case $1 in
*.tar.bz2) tar xjf $1 ;;
*.tar.gz) tar xzf $1 ;;
*.bz2) bunzip2 $1 ;;
*.rar) unrar x $1 ;;
*.gz) gunzip $1 ;;
*.tar) tar xf $1 ;;
*.tbz2) tar xjf $1 ;;
*.tgz) tar xzf $1 ;;
*.zip) unzip $1 ;;
*.Z) uncompress $1;;
*.7z) 7z x $1 ;;
*) echo "'$1' cannot be extracted via ex()" ;;
esac
else
echo "'$1' is not a valid file"
fi
}
#+END_SRC #+END_SRC
*** Tree display *** Tree display
@ -266,38 +208,38 @@ the =.git= directory, listing directories first. The output gets piped into
small enough for one screen. small enough for one screen.
#+BEGIN_SRC bash #+BEGIN_SRC bash
function tre() { function tre() {
tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX; tree -aC -I '.git|node_modules|bower_components' --dirsfirst "$@" | less -FRNX;
} }
#+END_SRC #+END_SRC
*** Create a new directory and enter it *** Create a new directory and enter it
#+BEGIN_SRC bash #+BEGIN_SRC bash
function mkd() { function mkd() {
mkdir -p "$@" && cd "$_"; mkdir -p "$@" && cd "$_";
} }
#+END_SRC #+END_SRC
*** Filesize of directory *** Filesize of directory
#+BEGIN_SRC bash #+BEGIN_SRC bash
function fs() { function fs() {
if du -b /dev/null > /dev/null 2>&1; then if du -b /dev/null > /dev/null 2>&1; then
local arg=-sbh; local arg=-sbh;
else else
local arg=-sh; local arg=-sh;
fi fi
if [[ -n "$@" ]]; then if [[ -n "$@" ]]; then
du $arg -- "$@"; du $arg -- "$@";
else else
du $arg .[^.]* ./*; du $arg .[^.]* ./*;
fi; fi;
} }
#+END_SRC #+END_SRC
*** Redirect both standard output and standard error, as well as sending to background *** Redirect both standard output and standard error, as well as sending to background
#+BEGIN_SRC bash #+BEGIN_SRC bash
function nullify() { function nullify() {
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1
} }
#+END_SRC #+END_SRC
@ -316,7 +258,7 @@ https://doronbehar.com/articles/using-kdeconnect-to-comfortably-send-sms-message
# echo "${name}"$'\t'"${phone_number}"$'\t'"${phone_type}" > ${_KDECONNECT_SMS_LAST_RECIPIENT} # echo "${name}"$'\t'"${phone_number}"$'\t'"${phone_type}" > ${_KDECONNECT_SMS_LAST_RECIPIENT}
kdeconnect-cli --send-sms "${args}" --destination "${phone_number}" --device 4de3b5de2264a17c kdeconnect-cli --send-sms "${args}" --destination "${phone_number}" --device 4de3b5de2264a17c
# kdeconnect-cli --device ${_KDECONNECT_DEFAULT_DEVICE} --send-sms "${args}" --destination "${phone_number}" && \ # kdeconnect-cli --device ${_KDECONNECT_DEFAULT_DEVICE} --send-sms "${args}" --destination "${phone_number}" && \
# echo sent sms message to ${name} | fribidi # echo sent sms message to ${name} | fribidi
fi fi
} }
@ -429,3 +371,67 @@ This is important for termite to work when sshing in remote machines.
PATH=~/.emacs.d/bin:$PATH PATH=~/.emacs.d/bin:$PATH
export PATH export PATH
#+END_SRC #+END_SRC
* Input
:PROPERTIES:
:header-args: :tangle ~/.inputrc
:header-args+: :comments both :mkdirp yes
:END:
Completion:
#+BEGIN_SRC conf
# Single tab for autocompletion
set show-all-if-ambiguous on
# Ignore case for completion
set completion-ignore-case on
#+END_SRC
vi mode:
#+BEGIN_SRC conf
# VI mode (works in bash and zsh)
set editing-mode vi
# Show which mode (normal or insert)
set show-mode-in-prompt on
# Show the mode by changing the cursor
set vi-ins-mode-string \1\e[6 q\2
set vi-cmd-mode-string \1\e[2 q\2
#+END_SRC
Key-bindings for vi-mode:
#+BEGIN_SRC conf
set keymap vi-command
# these are for vi-command mode
Control-l: clear-screen
Control-a: beginning-of-line
Control-e: end-of-line
Control-w: "\C-aisudo \C-e"
set keymap vi-insert
# these are for vi-insert mode
Control-l: clear-screen
Control-a: beginning-of-line
Control-e: end-of-line
Control-w: "\C-asudo \C-e"
#+END_SRC
Colorized completion
#+begin_src conf
# Color files by types
set colored-stats On
# Append char to indicate type
set visible-stats On
# Mark symlinked directories
set mark-symlinked-directories On
# Color the common prefix
set colored-completion-prefix On
# Color the common prefix in menu-complete
set menu-complete-display-prefix On
#+end_src
Don't echo =^C= after =Ctrl+C= is pressed.
#+begin_src conf
set echo-control-characters off
#+end_src

View File

@ -88,70 +88,6 @@
</fontconfig> </fontconfig>
#+end_src #+end_src
* Input
:PROPERTIES:
:header-args: :tangle ~/.inputrc
:header-args+: :comments both :mkdirp yes
:END:
Completion:
#+BEGIN_SRC conf
# Single tab for autocompletion
set show-all-if-ambiguous on
# Ignore case for completion
set completion-ignore-case on
#+END_SRC
vi mode:
#+BEGIN_SRC conf
# VI mode (works in bash and zsh)
set editing-mode vi
# Show which mode (normal or insert)
set show-mode-in-prompt on
# Show the mode by changing the cursor
set vi-ins-mode-string \1\e[6 q\2
set vi-cmd-mode-string \1\e[2 q\2
#+END_SRC
Key-bindings for vi-mode:
#+BEGIN_SRC conf
set keymap vi-command
# these are for vi-command mode
Control-l: clear-screen
Control-a: beginning-of-line
Control-e: end-of-line
Control-w: "\C-aisudo \C-e"
set keymap vi-insert
# these are for vi-insert mode
Control-l: clear-screen
Control-a: beginning-of-line
Control-e: end-of-line
Control-w: "\C-asudo \C-e"
#+END_SRC
Colorized completion
#+begin_src conf
# Color files by types
set colored-stats On
# Append char to indicate type
set visible-stats On
# Mark symlinked directories
set mark-symlinked-directories On
# Color the common prefix
set colored-completion-prefix On
# Color the common prefix in menu-complete
set menu-complete-display-prefix On
#+end_src
Don't echo =^C= after =Ctrl+C= is pressed.
#+begin_src conf
set echo-control-characters off
#+end_src
* GnuPG * GnuPG
:PROPERTIES: :PROPERTIES:
:header-args: :tangle ~/.gnupg/gpg-agent.conf :header-args: :tangle ~/.gnupg/gpg-agent.conf