add bash and emacs init files

This commit is contained in:
2023-07-11 13:16:29 +02:00
parent e65ef9889e
commit 6feb928205
7 changed files with 5303 additions and 0 deletions

194
config/home/.bashrc.br Normal file
View File

@@ -0,0 +1,194 @@
#!/usr/bin/env bash
#
# ~/.bashrc.br - user specific initialization
#
# (C) Bruno Raoult ("br"), 2001-2023
# Licensed under the GNU General Public License v3.0 or later.
# Some rights reserved. See COPYING.
#
# You should have received a copy of the GNU General Public License along with this
# program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
#
# SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
#
# Usage: to be invoked from .bashrc.
# i.e., add at the end of .bashrc:
# [ -f "$HOME/.bashrc.$USER" ] && . "$HOME/.bashrc.$USER"
# _remove $1 from PATH
_path_del() {
local _l=":$PATH:"
while [[ $_l =~ :$1: ]]; do
_l=${_l//:$1:/:}
done
_l=${_l%:}
_l=${_l#:}
PATH="$_l"
}
# _prepend : prepend $1 to PATH.
_path_prepend() {
_path_del "$1"
PATH="$1:$PATH"
}
# _append : append $1 to PATH.
_path_append() {
_path_del "$1"
PATH="$PATH:$1"
}
# adjust PATH. Below paths will be added at beginning.
_lpath=("$HOME/bin/$(uname -s)-$(uname -m)"
"$HOME/bin"
"$HOME/.cargo/bin"
"/usr/local/bin")
# loop array in reverse order. Note: We do not test for path existence and add it
# unconditionally, to avoid automounter interference.
for (( _i = ${#_lpath[@]} - 1; _i >= 0; --_i )); do
_path_prepend "${_lpath[_i]}"
done
unset _lpath
_path_append /usr/games
# enable core file
ulimit -Sc 102400 # in 1024 bytes, 100Mb
# ... and set PAGER to less (for man(1) and others)
if hash less 2>/dev/null; then
export PAGER=less
# do not clear screen after "less", exit immediately if one page only
export LESS="-XFB"
# ... and just alias more... to less ;-)
alias more=less
fi
# no output split for dc and bc / make bc silent
export DC_LINE_LENGTH=0
export BC_LINE_LENGTH=0
export BC_ENV_ARGS=--quiet
# both ubuntu and debian assume we want colors if TERM contains "color"
# this is surely not true, as TERM is often forced by terminal emulator
# shellcheck disable=SC2154
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# trim prompt path
export PROMPT_DIRTRIM=3
# find a suitable editor
e() {
$VISUAL "$@"
}
export -f e
if hash emacs 2>/dev/null; then
# uncomment below to use full emacs
#export EDITOR=emacs
# ... OR: uncomment below to use emacsclient
#export ALTERNATE_EDITOR="/usr/bin/emacs"
#export EDITOR="emacs.sh"
#alias emacs="emacs.sh"
export ALTERNATE_EDITOR=""
export VISUAL="emacsclient -c"
alias emacs="emacsclient -c"
#alias crontab="VISUAL=emacsclient crontab -e"
#alias crontab="emacs-crontab.sh"
else
# emacs clones, then vim/vi, then... whatever left.
_VISUALS=(zile jed mg vim vi nano ed)
for e in "${_VISUALS[@]}"; do
if hash "$e" 2>/dev/null; then
export VISUAL="$e"
break
fi
done
unset _VISUALS
fi
export EDITOR=$VISUAL
# append to the history file, don't overwrite it
shopt -s histappend
# write history after each command
export PROMPT_COMMAND="history -a"
# Add timestamp in history
export HISTTIMEFORMAT="%d/%m %H:%M "
# ignore history dups, delete all previous dups
export HISTCONTROL=ignoredups:erasedups
# history size
HISTSIZE=5000
HISTFILESIZE=5000
# remove new stupid Debian "ls" quoting, and colors...
# Many complains, one of them:
# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=813164#226
export QUOTING_STYLE=literal
[[ -v BASH_ALIASES[ls] ]] && unalias ls
# avoid these stupid systemd defaults (horizontal scroll and pager)
alias systemctl="systemctl --no-pager --full"
# aliases for ls and history
alias l='ls -F'
alias ls='ls -F'
alias l1='ls -1F'
alias la='ls -aF'
alias ll='ls -lF'
alias lla='ls -laF'
alias ldl='ls -l | grep ^d'
[[ -v BASH_ALIASES[lrt] ]] && unalias lrt
lrt() {
local -i _l=20
if (( $# > 0 )) && [[ $1 =~ [[:digit:]]+ ]]; then
_l="$1"
shift
fi
# shellcheck disable=2012
ls -lrt "${1:-.}" | tail -"$_l"
}
[[ -v BASH_ALIASES[lart] ]] && unalias lart
lart() {
local -i _l=20
if (( $# > 0 )) && [[ $1 =~ [[:digit:]]+ ]]; then
_l="$1"
shift
fi
# shellcheck disable=2012
ls -laFrt "${1:-.}" | tail -"$_l"
}
alias h="history 10" # short
alias hl="history 25" # long
alias hll="history 100" # very long
alias hlll="history" # all history
# user temp directory
export USERTMP=~/tmp
# :)
alias fuck='sudo $(history -p \!\!)'
# french-> english and english->french translation
alias trans="trans.sh"
alias rtrans="trans.sh -fen -tfr"
# host specific initialization
# shellcheck disable=SC1090
[ -f "$HOME/.bashrc.$USER.$(hostname)" ] && . "$HOME/.bashrc.$USER.$(hostname)"
# Indent style for emacs
# Local Variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indentation: 4
# indent-tabs-mode: nil
# End:

View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
#
# ~/.bashrc.br.lorien - host specific initialization
#
# (C) Bruno Raoult ("br"), 2001-2023
# Licensed under the GNU General Public License v3.0 or later.
# Some rights reserved. See COPYING.
#
# You should have received a copy of the GNU General Public License along with this
# program. If not, see <https://www.gnu.org/licenses/gpl-3.0-standalone.html>.
#
# SPDX-License-Identifier: GPL-3.0-or-later <https://spdx.org/licenses/GPL-3.0-or-later.html>
#
# Usage: to be invoked from .bashrc.$USER
# i.e., add at the end of .bashrc.$USER:
# [ -f "$HOME/.bashrc.$USER.$(hostname)" ] && . "$HOME/.bashrc.$USER.$(hostname)"
# look for a pdf viewer
hash atril 2> /dev/null && alias acroread=atril
# mysql aliases. Will match any "[client-XXX]" lines in ~/.my.cnf
# and generate "myXXX" aliases.
if [[ -r ~/.my.cnf ]]; then
mapfile -t MYSQL_ARRAY < ~/.my.cnf
for line in "${MYSQL_ARRAY[@]}"; do
if [[ $line =~ ^\[client-(.+)\]$ ]]; then
SUFFIX="${BASH_REMATCH[1]}"
# shellcheck disable=SC2139,SC2140
alias my"$SUFFIX"="mysql --defaults-group-suffix=-$SUFFIX"
fi
done
fi
# shortcuts to commonly used directories
# alias dev="cd ~/dev/www/cf.bodi" # Clash of Clans
alias eud="cd ~/dev/eudyptula; . ./bin/ENV.sh" # Eudyptula
alias aoc="cd ~/dev/advent-of-code/2022/; . ../env.sh" # Advent of Code
alias wchess="cd ~/dev/www/com.raoult/devs/chess" # raoult.com chess
alias chess="cd ~/dev/brchess; . env.sh" # brchess
alias tools="cd ~/dev/tools" # tools
# Indent style for emacs
# Local Variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indentation: 4
# indent-tabs-mode: nil
# End:

2444
config/home/.emacs.d/init.el Executable file

File diff suppressed because it is too large Load Diff

22
config/home/graphic.el Executable file
View File

@@ -0,0 +1,22 @@
;; ~/.emacs.d/graphic.el
;;
;; emacs configuration - this file will be loaded only when emacs runs on graphic
;; system.
;;
;; br, 2010-2019
;; avoids calling this twice
(when (not (boundp 'my/graphic-loaded))
;; disable toolbar
(tool-bar-mode -1)
;; initial frame size
(set-frame-size (selected-frame) 180 50)
(setq
;; split windows and assign them references
my/upper-window (selected-window)
my/main-window (split-window-right)
my/below-window (split-window-below)
my/graphic-loaded t))

2444
config/home/init.el Executable file

File diff suppressed because it is too large Load Diff

141
config/home/lorien.el Executable file
View File

@@ -0,0 +1,141 @@
;; ~/.emacs.d/lorien.el
;;
;; Emacs configuration - this file will be loaded only when run on lorien.
;;
;; br, 2010-2019
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; pre-load often-visited files
;; avoids calling this twice
(when (not (boundp 'my/lorien-loaded))
(setq my/lorien-loaded t)
;; use ESC as C-g
;; (global-set-key [escape] 'keyboard-escape-quit)
;; (global-unset-key [escape])
(define-key key-translation-map (kbd "ESC") (kbd "C-g"))
;; mail
(require 'message)
(setq message-send-mail-function 'smtpmail-send-it
smtpmail-default-smtp-server "localhost"
smtpmail-smtp-server "localhost"
smtpmail-debug-info t
mail-signature "\n\n-- \n2 + 2 = 5, for very large values of 2.\n"
mail-default-headers "CC: \n"
send-mail-function 'smtpmail-send-it
)
;; shortcuts for tramp
;; (my/add-to-list
;; 'directory-abbrev-alist
;; '(("^/root" . "/su:/")
;; ("^/rebel" . "/ssh:arwen:www/cf.bodi/rebels21/")
;; ("^/strat" . "/ssh:arwen:www/cf.bodi/strat-dom/")))
(defconst my/loaded-files-at-startup
(list
"~/dev/brchess/Makefile"
"~/dev/tools/c/Makefile"
"~/org/boot-disk.org"
"~/org/beaglebone-buster-setup.org"
;;"~/dev/www/cf.bodi/sql/coc.sql"
;;"~/dev/www/cf.bodi/sql/coc-sql.org"
user-init-file
"~/org/emacs-cheatsheet.org"
;;"~/dev/g910/g910-gkey-macro-support/lib/data_mappers/char_uinput_mapper.py"
"~/dev/advent-of-code/2022/Makefile"
"~/dev/www/com.raoult/devs/php/chess/list-pgn-games.php")
;; "~/dev/eudyptula/ID")
"personal files always loaded at startup (no visible window).")
(let ((num 1))
(dolist
(filename my/loaded-files-at-startup)
(if (file-exists-p filename)
(progn
;; set variable "my/buffer-1" to buffer returned by find-file
(set
(intern (concat "my/buffer-" (number-to-string num)))
(find-file-noselect filename nil nil nil))
(message "file: [%s] loaded." filename))
(message "cannot load file: [%s]." filename))
(cl-incf num)))
;; set windows for current work buffers
(when (boundp 'my/graphic-loaded)
(set-window-buffer my/main-window my/buffer-1)
(set-window-buffer my/upper-window "*Messages*")
(set-window-buffer my/below-window my/buffer-2))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Coc sync
;; mysql CoC connection (dev)
;;(defun my/connect-coc ()
;;(interactive)
;;(my/sql-connect-preset 'coc))
(defun my/connect-coc ()
(interactive)
(sql-connect "coc"))
;; sync from/to idril
(defun my/coc-get-db ()
"get last coc db from arwen"
(interactive)
;; force run on local machine when in tramp buffer
(with-current-buffer (get-buffer "*scratch*")
(async-shell-command "sync-coc-db-from-idril.sh")))
(defun my/sync-www ()
"sync www to arwen - dry run"
(interactive)
(with-current-buffer (get-buffer "*scratch*")
(async-shell-command "sync-www-to-idril.sh")))
(defun my/sync-www-doit ()
"sync www to arwen"
(interactive)
(with-current-buffer (get-buffer "*scratch*")
(async-shell-command "sync-www-to-idril.sh -d")))
(setq org-publish-project-alist
'(("org"
:base-directory "~/org"
:base-extension "org"
:publishing-directory "~/dev/www/cf.bodi/org"
:recursive t
:publishing-function org-html-publish-to-html
;;:headline-levels 4
;;:section-numbers nil
;;:html-head nil
:html-head-include-default-style nil
:html-head-include-scripts nil
;; :html-preamble my-blog-header
;;:html-postamble my-blog-footer
)
("static"
:base-directory "~/org/"
:base-extension "css\\|js\\|png\\|jpg\\|gif\\|pdf\\|mp3\\|ogg\\|swf"
:publishing-directory "~/dev/www/cf.bodi/org/"
:recursive t
:publishing-function org-publish-attachment)
;; Define any other projects here...
))
(global-set-key (kbd "s-c c c") 'my/connect-coc)
(global-set-key (kbd "s-c c g") 'my/coc-get-db)
(global-set-key (kbd "s-c c s") 'my/sync-www)
(global-set-key (kbd "s-c c w") 'my/sync-www-doit))
;; (Define-key my/keys-mode-map
;; (kbd "s-c c g") 'my/coc-gewt-db)
;; (define-key my/keys-mode-map
;; (kbd "s-c c s") 'my/coc-sync-www)
;; (set-window-buffer current-buffer (get-buffer "*messages*"))))
;; (set-window-buffer "*messages*")
;; Local Variables:
;; flycheck-disabled-checkers: (emacs-lisp-checkdoc)
;; End:

9
config/home/term.el Executable file
View File

@@ -0,0 +1,9 @@
;; ~/.emacs.d/term.el
;;
;; emacs configuration - this file will be loaded only in terminal mode
;;
;; br, 2010-2018
;;(print "loading term.el")