Compare commits
16 Commits
11b7cf40eb
...
master
Author | SHA1 | Date | |
---|---|---|---|
4d9c134f04 | |||
c1750624c9 | |||
e177a0716f | |||
6aed1cfbfd | |||
cc5ae859a0 | |||
79955bb355 | |||
b0f1f53865 | |||
f1fe945ecd | |||
30a2954514 | |||
d26c60e565 | |||
512c08ea31 | |||
4a14195bcd | |||
6dbd254992 | |||
ee68ec34c2 | |||
e8a218f7cb | |||
63388aaa7a |
@@ -1,8 +1,11 @@
|
|||||||
### Some GNU/Linux tools, for fun...
|
### Some personal GNU/Linux tools.
|
||||||
|
|
||||||
#### bash
|
#### bash
|
||||||
|
|
||||||
- **trans.sh**: a [linguee.com](https://linguee.com) based command-line translator.
|
- **trans.sh**: a [linguee.com](https://linguee.com) based command-line translator.
|
||||||
- **sync.sh**: a rsync/ssh backup tool.
|
- **sync.sh**: a rsync/ssh backup tool.
|
||||||
|
- **sync-view.sh**: view ~sync.sh~ file backups versions.
|
||||||
- **sync-conf-example.sh**: configuration example.
|
- **sync-conf-example.sh**: configuration example.
|
||||||
- **dup-live-disk.sh**: duplicate (**possibly live**) disk partitions.
|
- **dup-live-disk.sh**: duplicate (**possibly live**) disk partitions.
|
||||||
|
- **gen-password.sh**: a password generator.
|
||||||
|
- **base.sh**: bases 2/8/10/16 conversions.
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
### Some GNU/Linux tools, for fun...
|
### Some bash scripts, that I needed at some time...
|
||||||
|
|
||||||
|
|
||||||
#### bash
|
|
||||||
|
|
||||||
- [**trans.sh**](trans.sh): a [linguee.com](https://linguee.com) based command-line translator.
|
- [**trans.sh**](trans.sh): a [linguee.com](https://linguee.com) based command-line translator.
|
||||||
- [**sync.sh**](sync.sh): a rsync/ssh backup tool.
|
- [**sync.sh**](sync.sh): a rsync/ssh backup tool.
|
||||||
- [**sync-conf-example.sh**](share/sync/sync-conf-example.sh): configuration example.
|
- [**sync-conf-example.sh**](share/sync/sync-conf-example.sh): configuration example.
|
||||||
|
- [**sync-view.sh**](sync-view.sh): view `sync.sh` file backups versions.
|
||||||
- [**dup-live-disk.sh**](dup-live-disk.sh): duplicate (possibly live) disk partitions.
|
- [**dup-live-disk.sh**](dup-live-disk.sh): duplicate (possibly live) disk partitions.
|
||||||
- [**gen-password.sh**](gen-password.sh): a password generator
|
- [**gen-password.sh**](gen-password.sh): a password generator
|
||||||
- [**share/gen-password**](share/gen-password): [diceware](https://en.wikipedia.org/wiki/Diceware)-like word lists.
|
- [**share/gen-password**](share/gen-password): [diceware](https://en.wikipedia.org/wiki/Diceware)-like word lists.
|
||||||
|
- [**base**](base.sh): bases 2/8/10/16 conversions.
|
||||||
|
324
bash/base.sh
Executable file
324
bash/base.sh
Executable file
@@ -0,0 +1,324 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# base.sh - convert decimal numbers from/to base 2, 8, 10 and 16.
|
||||||
|
#
|
||||||
|
# (C) Bruno Raoult ("br"), 2024
|
||||||
|
# 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>
|
||||||
|
#
|
||||||
|
|
||||||
|
CMDNAME=${0##*/} # script name
|
||||||
|
|
||||||
|
# some default values (blocks separator padchar)
|
||||||
|
# Attention: For output base 10, obase is 1
|
||||||
|
declare -i ibase=0 obase=0 padding=0 prefix=1 ogroup=0 intbits
|
||||||
|
|
||||||
|
# find out int size (bits) - suppose 2-complement, and 8 bits char
|
||||||
|
printf -v _b "%x" -1
|
||||||
|
(( intbits = ${#_b} * 4 ))
|
||||||
|
|
||||||
|
declare -rA _bases=( # -f/-b accepted values
|
||||||
|
[2]=2 [b]=2 [B]=2
|
||||||
|
[8]=8 [o]=8 [O]=8
|
||||||
|
[10]=10 [d]=10 [D]=10
|
||||||
|
[16]=16 [h]=16 [H]=16
|
||||||
|
[a]=-1 [g]=-1
|
||||||
|
)
|
||||||
|
declare -A _pad=( # group separator
|
||||||
|
[2]=" " [8]=" " [10]="," [16]=" "
|
||||||
|
)
|
||||||
|
declare -rA _ogroup=( # group size
|
||||||
|
[2]=8 [8]=3 [10]=3 [16]=4
|
||||||
|
)
|
||||||
|
declare -rA _oprefix=( # output prefix
|
||||||
|
[2]="2#" [8]="0" [10]="" [16]="0x"
|
||||||
|
)
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
printf "usage: %s [OPTIONS] [NUMBER]...\n" "$CMDNAME"
|
||||||
|
printf "Use '%s -h' for more help\n" "$CMDNAME"
|
||||||
|
}
|
||||||
|
|
||||||
|
help() {
|
||||||
|
cat << _EOF
|
||||||
|
usage: $CMDNAME [OPTIONS] [NUMBER]...
|
||||||
|
-f, --from=BASE input base, see BASE below. Default is "g"
|
||||||
|
-t, --to=BASE output base, see BASE below. Default is "a"
|
||||||
|
-b, -o, -d, -x equivalent to -t2, -t8, -t10, -t16"
|
||||||
|
-g, --group=[SEP] group output (see OUTPUT below)
|
||||||
|
-p, --padding 0-pad output on block boundary (implies -g)
|
||||||
|
-n, --noprefix remove base prefixes in output
|
||||||
|
-h, --help this help
|
||||||
|
-- end of options
|
||||||
|
|
||||||
|
$CMDNAME output the NUMBERS arguments in different bases. If no NUMBER is
|
||||||
|
given, standard input will be used.
|
||||||
|
|
||||||
|
BASE
|
||||||
|
2, b, B binary
|
||||||
|
8, o, O, 0 octal
|
||||||
|
10, d, D decimal
|
||||||
|
16, h, H, 0x hexadecimal
|
||||||
|
a, g all/any: Default, guess format for '-f', output all
|
||||||
|
bases for '-t'
|
||||||
|
|
||||||
|
INPUT NUMBER
|
||||||
|
If input base is not specified, some prefixes are supported.
|
||||||
|
'b' or '2/' for binary, '0', 'o' or '8/' for octal, '0x', 'x' or
|
||||||
|
'16/' for hexadecimal, and 'd' or '10/' for decimal.
|
||||||
|
If no above prefix is found, decimal is assumed.
|
||||||
|
Decimal input may be signed or unsigned, with limits imposed by current
|
||||||
|
Bash (here: $intbits bits).
|
||||||
|
|
||||||
|
OUTPUT
|
||||||
|
Decimal output is always unsigned.
|
||||||
|
By default, the input number is shown converted in the 4 supported
|
||||||
|
bases (16, 10, 8, 2, in this order), separated by one tab character.
|
||||||
|
Without '-n' option, all output numbers but decimal will be prefixed:
|
||||||
|
'2#' for binary, '0' for octal, '0x' for hexadecimal, making them
|
||||||
|
usable for input in some otilities such as bash(1).]
|
||||||
|
With '-g' option, number digits will be grouped by 3 (octal,
|
||||||
|
decimal), 4 (hexadecimal), or 8 (binary). If no SEP character is given,
|
||||||
|
the separator will be ',' (comma) for decimal, space otherwise.
|
||||||
|
This option may be useless for default output, with multiple numbers
|
||||||
|
on one line.
|
||||||
|
The '-p' option add 0 padding up to the base grouping boundary.
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
Converting number in hexadecimal, decimal, octal, and binary, with or without
|
||||||
|
prefixes. Here, '\t' separator is shown as space:
|
||||||
|
$ $CMDNAME 0
|
||||||
|
0x0 0 0 2#0
|
||||||
|
|
||||||
|
$ $CMDNAME 123456
|
||||||
|
0x1e240 123456 0361100 2#11110001001000000
|
||||||
|
|
||||||
|
$ $CMDNAME -n 2/100
|
||||||
|
4 4 4 100
|
||||||
|
|
||||||
|
$ $CMDNAME -n 0x1e240
|
||||||
|
1e240 123456 361100 11110001001000000
|
||||||
|
|
||||||
|
Binary output, no prefix, grouped output:
|
||||||
|
$ $CMDNAME -bng 0x1e240
|
||||||
|
1 11100010 01000000
|
||||||
|
|
||||||
|
Negative input (decimal only):
|
||||||
|
$ $CMDNAME -x -- -1
|
||||||
|
0xffffffffffffffff
|
||||||
|
|
||||||
|
Input base indication, left padding binary output, no prefix:
|
||||||
|
$ $CMDNAME -nbp -f8 361100
|
||||||
|
00000001 11100010 01000000
|
||||||
|
|
||||||
|
Set group separator. Note that the separator *must* immediately follow the '-g'
|
||||||
|
option, without spaces:
|
||||||
|
$ $CMDNAME -nxg: 123456
|
||||||
|
1:e240
|
||||||
|
|
||||||
|
Long options, with separator and padding:
|
||||||
|
$ $CMDNAME --to=16 --noprefix --padding --group=: 12345
|
||||||
|
0001:e240
|
||||||
|
|
||||||
|
TODO
|
||||||
|
Add option for signed/unsigned integer output.
|
||||||
|
Remove useless octal output ?
|
||||||
|
_EOF
|
||||||
|
}
|
||||||
|
|
||||||
|
zero_pad() {
|
||||||
|
local n="$1" str="$2"
|
||||||
|
|
||||||
|
printf "%0.*d%s" $(( n - ${#str} % n)) 0 "$str"
|
||||||
|
}
|
||||||
|
|
||||||
|
split() {
|
||||||
|
local base="$1" str="$2"
|
||||||
|
local res="$str" sep=${_pad[$base]}
|
||||||
|
local -i n=${_ogroup[$base]}
|
||||||
|
|
||||||
|
(( padding )) && str=$(zero_pad "${_ogroup[$base]}" "$str")
|
||||||
|
if (( ogroup )); then
|
||||||
|
res=""
|
||||||
|
while (( ${#str} )); do
|
||||||
|
if (( ${#str} <= n )); then # finished
|
||||||
|
res="${str}${res:+$sep$res}"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
res="${str: -n}${res:+$sep$res}"
|
||||||
|
str="${str:0:-n}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
printf "%s" "$res"
|
||||||
|
}
|
||||||
|
|
||||||
|
bin() {
|
||||||
|
local str=""
|
||||||
|
local -i n dec="$1"
|
||||||
|
|
||||||
|
# take care of negative numbers, as >> operator keeps the sign.
|
||||||
|
# 'intbits' is size of integer in bits in current shell.
|
||||||
|
for (( n = 0 ; dec && (n < intbits); n++ )); do
|
||||||
|
str="$(( dec & 1 ))$str"
|
||||||
|
(( dec >>= 1 ))
|
||||||
|
done
|
||||||
|
printf "%s\n" "${str:-0}"
|
||||||
|
}
|
||||||
|
|
||||||
|
hex() {
|
||||||
|
printf "%lx" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
dec() {
|
||||||
|
printf "%lu" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
oct() {
|
||||||
|
printf "%lo" "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
declare -a args=()
|
||||||
|
|
||||||
|
parse_opts() {
|
||||||
|
# short and long options
|
||||||
|
local sopts="f:t:bodxg::pnh"
|
||||||
|
local lopts="from:,to:,group::,padding,noprefix,help"
|
||||||
|
# set by options
|
||||||
|
local tmp=""
|
||||||
|
|
||||||
|
if ! tmp=$(getopt -o "$sopts" -l "$lopts" -n "$CMDNAME" -- "$@"); then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
eval set -- "$tmp"
|
||||||
|
|
||||||
|
while true; do
|
||||||
|
case "$1" in
|
||||||
|
"-f"|"--from")
|
||||||
|
ibase=${_bases[$2]}
|
||||||
|
if (( ! ibase )); then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"-t"|"--to")
|
||||||
|
obase=${_bases[$2]}
|
||||||
|
if (( ! obase )); then
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"-b") obase=2 ;;
|
||||||
|
"-o") obase=8 ;;
|
||||||
|
"-d") obase=1 ;;
|
||||||
|
"-x") obase=16 ;;
|
||||||
|
"-g"|"--group")
|
||||||
|
ogroup=1
|
||||||
|
if [[ -n "$2" ]]; then
|
||||||
|
for i in 2 8 10 16; do _pad["$i"]="$2"; done
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
"-p"|"--padding") ogroup=1; padding=1 ;;
|
||||||
|
"-n"|"--noprefix") prefix=0 ;;
|
||||||
|
"-h"|"--help") help ; exit 0 ;;
|
||||||
|
"--") shift; break ;;
|
||||||
|
*) usage; echo "Internal error [$1]!" >&2; exit 1 ;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
# next are numbers to convert, if any
|
||||||
|
if (($# > 0)); then
|
||||||
|
args=("$@")
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
addprefix() {
|
||||||
|
local base="$1" number="$2" _prefix=""
|
||||||
|
if (( prefix )); then
|
||||||
|
if [[ $base != 8 || $number != "0" ]]; then
|
||||||
|
_prefix="${_oprefix[$base]}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
printf "%s%s" "$_prefix" "$number"
|
||||||
|
}
|
||||||
|
|
||||||
|
stripprefix() {
|
||||||
|
[[ $1 =~ ^(0x|b|o|d|x|.*/) ]]
|
||||||
|
printf "%s" "${1#"${BASH_REMATCH[1]}"}"
|
||||||
|
}
|
||||||
|
|
||||||
|
guessbase() {
|
||||||
|
local input="$1"
|
||||||
|
local -i base=0
|
||||||
|
if [[ $input =~ ^(b|2/) ]]; then
|
||||||
|
base=2
|
||||||
|
elif [[ $input =~ ^(0x|x|16/) ]]; then
|
||||||
|
base=16
|
||||||
|
elif [[ $input =~ ^(0|o|8/) ]]; then
|
||||||
|
base=8
|
||||||
|
elif [[ $input =~ ^(d|10/) ]]; then
|
||||||
|
base=10
|
||||||
|
fi
|
||||||
|
return $(( base ? base : 10 ))
|
||||||
|
}
|
||||||
|
|
||||||
|
doit() {
|
||||||
|
local number="$2" multi="" val inum
|
||||||
|
local -i base=$1 decval _obase=$obase
|
||||||
|
if (( base <= 0 )); then
|
||||||
|
guessbase "$number"
|
||||||
|
base=$?
|
||||||
|
fi
|
||||||
|
|
||||||
|
inum=$(stripprefix "$number")
|
||||||
|
# convert input value to decimal
|
||||||
|
(( base == 10 )) && (( decval = inum ))
|
||||||
|
(( base != 10 )) && (( decval = "$base#$inum" ))
|
||||||
|
|
||||||
|
# mask for desired output: 1=decimal, others are same as base
|
||||||
|
if (( ! _obase )); then
|
||||||
|
(( _obase = 1|2|8|16 ))
|
||||||
|
multi=$'\t'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( _obase & 16 )); then
|
||||||
|
val=$(addprefix 16 "$(split 16 "$(hex $decval)")")
|
||||||
|
printf "%s%s" "$val" "$multi"
|
||||||
|
fi
|
||||||
|
if (( _obase & 1 )); then
|
||||||
|
val=$(addprefix 10 "$(split 10 "$(dec $decval)")")
|
||||||
|
printf "%s%s" "$val" "$multi"
|
||||||
|
fi
|
||||||
|
if (( _obase & 8 )); then
|
||||||
|
val=$(addprefix 8 "$(split 8 "$(oct $decval)")")
|
||||||
|
printf "%s%s" "$val" "$multi"
|
||||||
|
fi
|
||||||
|
if (( _obase & 2 )); then
|
||||||
|
val=$(addprefix 2 "$(split 2 "$(bin $decval)")")
|
||||||
|
printf "%s%s" "$val" "$multi"
|
||||||
|
fi
|
||||||
|
printf "\n"
|
||||||
|
}
|
||||||
|
|
||||||
|
parse_opts "$@"
|
||||||
|
|
||||||
|
if ! (( ${#args[@]} )); then
|
||||||
|
while read -era line; do
|
||||||
|
for input in "${line[@]}"; do
|
||||||
|
doit "ibase" "$input"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
else
|
||||||
|
for input in "${args[@]}"; do
|
||||||
|
doit "$ibase" "$input"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
exit 0
|
88
config/etc/named.conf
Normal file
88
config/etc/named.conf
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
; raoult.com named.conf (gandi.net)
|
||||||
|
|
||||||
|
; SOA looks ignored when setting gandi DNS
|
||||||
|
@ 3600 IN SOA ns1.gandi.net. hostmaster.gandi.net. (
|
||||||
|
1725266688 ; serial
|
||||||
|
10800 ; refresh (3 hours)
|
||||||
|
3600 ; retry (1h)
|
||||||
|
604800 ; expire (1 week)
|
||||||
|
3600 ; minimum (1h)
|
||||||
|
)
|
||||||
|
|
||||||
|
;;; ---------------------------------- copy from here
|
||||||
|
|
||||||
|
; IP addresses
|
||||||
|
@ 3600 IN A 82.64.229.101
|
||||||
|
moreac 3600 IN A 82.67.122.150
|
||||||
|
|
||||||
|
; forgot what it is
|
||||||
|
@ 3600 IN TXT "google-site-verification=I7AEHSueTj0mpbBvL4QA3WKaPTfBiM0_6N8Var0UpU8"
|
||||||
|
|
||||||
|
; subdomains
|
||||||
|
www 3600 IN CNAME raoult.com.
|
||||||
|
home 3600 IN CNAME raoult.com.
|
||||||
|
devs 3600 IN CNAME raoult.com.
|
||||||
|
ebooks 3600 IN CNAME raoult.com.
|
||||||
|
|
||||||
|
; applications
|
||||||
|
dav 3600 IN CNAME raoult.com.
|
||||||
|
git 3600 IN CNAME raoult.com.
|
||||||
|
webtrees 3600 IN CNAME raoult.com.
|
||||||
|
|
||||||
|
; hostnames
|
||||||
|
idril 3600 IN CNAME raoult.com.
|
||||||
|
arwen 3600 IN CNAME raoult.com.
|
||||||
|
|
||||||
|
idefix 3600 IN CNAME moreac.raoult.com.
|
||||||
|
|
||||||
|
; old shared
|
||||||
|
locations 3600 IN CNAME raoult.com.
|
||||||
|
marcel 3600 IN CNAME raoult.com.
|
||||||
|
xavier 3600 IN CNAME raoult.com.
|
||||||
|
|
||||||
|
;;; ---------------------------------- end of Gandi DNS records
|
||||||
|
|
||||||
|
;;;;; default gandi.net entries
|
||||||
|
; @ 10800 IN A 217.70.184.38
|
||||||
|
; @ 10800 IN MX 10 spool.mail.gandi.net.
|
||||||
|
; @ 10800 IN MX 50 fb.mail.gandi.net.
|
||||||
|
; @ 10800 IN TXT "v=spf1 include:_mailcust.gandi.net ?all"
|
||||||
|
; _imap._tcp 10800 IN SRV 0 0 0 .
|
||||||
|
; _imaps._tcp 10800 IN SRV 0 1 993 mail.gandi.net.
|
||||||
|
; _pop3._tcp 10800 IN SRV 0 0 0 .
|
||||||
|
; _pop3s._tcp 10800 IN SRV 10 1 995 mail.gandi.net.
|
||||||
|
; _submission._tcp 10800 IN SRV 0 1 465 mail.gandi.net.
|
||||||
|
; gm1._domainkey 10800 IN CNAME gm1.gandimail.net.
|
||||||
|
; gm2._domainkey 10800 IN CNAME gm2.gandimail.net.
|
||||||
|
; gm3._domainkey 10800 IN CNAME gm3.gandimail.net.
|
||||||
|
;
|
||||||
|
; webmail 10800 IN CNAME webmail.gandi.net.
|
||||||
|
; www 10800 IN CNAME webredir.vip.gandi.net.
|
||||||
|
|
||||||
|
;;;;; old freenom
|
||||||
|
; raoult.com. 300 IN SOA ns01.freenom.com. soa.freenom.com. (
|
||||||
|
; 1725254393 ; serial
|
||||||
|
; 10800 ; refresh (3 hours)
|
||||||
|
; 3600 ; retry (1 hour)
|
||||||
|
; 604800 ; expire (1 week)
|
||||||
|
; 3600 ; minimum (1 hour)
|
||||||
|
; )
|
||||||
|
; raoult.com. 300 IN NS ns02.freenom.com.
|
||||||
|
; raoult.com. 300 IN NS ns04.freenom.com.
|
||||||
|
; raoult.com. 300 IN NS ns03.freenom.com.
|
||||||
|
; raoult.com. 300 IN NS ns01.freenom.com.
|
||||||
|
; raoult.com. 3600 IN TXT "google-site-verification=I7AEHSueTj0mpbBvL4QA3WKaPTfBiM0_6N8Var0UpU8"
|
||||||
|
|
||||||
|
;;;;; domain lists
|
||||||
|
; raoult.com
|
||||||
|
; www.raoult.com
|
||||||
|
; home.raoult.com
|
||||||
|
; arwen.raoult.com
|
||||||
|
; dav.raoult.com
|
||||||
|
; devs.raoult.com
|
||||||
|
; ebooks.raoult.com
|
||||||
|
; git.raoult.com
|
||||||
|
; locations.raoult.com
|
||||||
|
; marcel.raoult.com
|
||||||
|
; webtrees.raoult.com
|
||||||
|
; xavier.raoult.com
|
@@ -13,5 +13,7 @@
|
|||||||
# 1) source .bashrc if it exists
|
# 1) source .bashrc if it exists
|
||||||
# 2) add "$HOME"/bin in PATH
|
# 2) add "$HOME"/bin in PATH
|
||||||
# This imply a duplicate "$HOME/bin" in PATH, as we do everything in .bashrc.$user.
|
# This imply a duplicate "$HOME/bin" in PATH, as we do everything in .bashrc.$user.
|
||||||
|
# Having this ~/.bash_profile will avoid the execution of ~/.profile
|
||||||
|
|
||||||
[ -f "$HOME/.bashrc" ] && . "$HOME/.bashrc"
|
# shellcheck disable=SC1091
|
||||||
|
[ -f "$HOME/.bashrc" ] && . "$HOME/.bashrc"
|
@@ -15,7 +15,7 @@
|
|||||||
# i.e., add at the end of .bashrc:
|
# i.e., add at the end of .bashrc:
|
||||||
# [ -f "$HOME/.bashrc.$USER" ] && . "$HOME/.bashrc.$USER"
|
# [ -f "$HOME/.bashrc.$USER" ] && . "$HOME/.bashrc.$USER"
|
||||||
#
|
#
|
||||||
# Debian default ~/.profile does:
|
# Debian default ~/.profile usually does:
|
||||||
# 1) source .bashrc if it exists
|
# 1) source .bashrc if it exists
|
||||||
# 2) add "$HOME"/bin in PATH
|
# 2) add "$HOME"/bin in PATH
|
||||||
# This imply a duplicate "$HOME/bin" in PATH, as we do everything here.
|
# This imply a duplicate "$HOME/bin" in PATH, as we do everything here.
|
||||||
@@ -78,10 +78,12 @@ _var_append() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# adjust PATH. Below paths will be added at beginning.
|
# adjust PATH. Below paths will be added at beginning.
|
||||||
_lpath=("$HOME/bin/$(uname -s)-$(uname -m)"
|
_lpath=("$HOME/bin/$(uname -s)-$(uname -m)" # architecture specific
|
||||||
"$HOME/bin"
|
"$HOME/bin" # user scripts
|
||||||
|
"$HOME/.local/bin" # pip venv
|
||||||
#"$HOME/.cargo/bin"
|
#"$HOME/.cargo/bin"
|
||||||
"/usr/local/bin")
|
"/usr/local/bin"
|
||||||
|
)
|
||||||
|
|
||||||
# loop array in reverse order. Note: We do not test for path existence and add it
|
# loop array in reverse order. Note: We do not test for path existence and add it
|
||||||
# unconditionally, to avoid automounter interference.
|
# unconditionally, to avoid automounter interference.
|
||||||
@@ -96,13 +98,16 @@ _var_del PATH /snap/bin
|
|||||||
# enable core file
|
# enable core file
|
||||||
ulimit -Sc 102400 # in 1024 bytes, 100Mb
|
ulimit -Sc 102400 # in 1024 bytes, 100Mb
|
||||||
|
|
||||||
# ... and set PAGER to less (for man(1) and others)
|
# Set pager: "less" is prefered over "more".
|
||||||
if hash less 2>/dev/null; then
|
if hash less 2>/dev/null; then
|
||||||
export PAGER=less
|
export PAGER=less
|
||||||
# do not clear screen after "less", exit immediately if one page only
|
# do not clear screen after "less", exit immediately if one page only
|
||||||
export LESS="-XFB"
|
export LESS="--quit-if-one-screen --quit-at-eof --no-init"
|
||||||
# ... and just alias more... to less ;-)
|
|
||||||
alias more=less
|
alias more=less
|
||||||
|
else
|
||||||
|
export MORE="--exit-on-eof --silent"
|
||||||
|
export PAGER=more
|
||||||
|
alias less=more
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# no output split for dc and bc / make bc silent
|
# no output split for dc and bc / make bc silent
|
||||||
@@ -130,7 +135,8 @@ e() {
|
|||||||
$VISUAL "$@"
|
$VISUAL "$@"
|
||||||
}
|
}
|
||||||
export -f e
|
export -f e
|
||||||
if hash emacs 2>/dev/null; then
|
|
||||||
|
if hash emacs 2>/dev/null; then # look for Emacs...
|
||||||
# uncomment below to use full emacs
|
# uncomment below to use full emacs
|
||||||
#export EDITOR=emacs
|
#export EDITOR=emacs
|
||||||
# ... OR: uncomment below to use emacsclient
|
# ... OR: uncomment below to use emacsclient
|
||||||
@@ -142,8 +148,7 @@ if hash emacs 2>/dev/null; then
|
|||||||
alias emacs="emacsclient -c"
|
alias emacs="emacsclient -c"
|
||||||
#alias crontab="VISUAL=emacsclient crontab -e"
|
#alias crontab="VISUAL=emacsclient crontab -e"
|
||||||
#alias crontab="emacs-crontab.sh"
|
#alias crontab="emacs-crontab.sh"
|
||||||
else
|
else # ... or clones, vim/vi, etc...
|
||||||
# emacs clones, then vim/vi, then... whatever left.
|
|
||||||
_VISUALS=(zile jed mg e3em vim vi nano ed)
|
_VISUALS=(zile jed mg e3em vim vi nano ed)
|
||||||
|
|
||||||
for e in "${_VISUALS[@]}"; do
|
for e in "${_VISUALS[@]}"; do
|
||||||
@@ -156,6 +161,15 @@ else
|
|||||||
fi
|
fi
|
||||||
export EDITOR=$VISUAL
|
export EDITOR=$VISUAL
|
||||||
|
|
||||||
|
for _pdfviewer in atril qpdfview; do # look for a pdf viewer
|
||||||
|
if hash "$_pdfviewer" 2>/dev/null; then
|
||||||
|
# shellcheck disable=SC2139
|
||||||
|
alias acroread="$_pdfviewer"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unset _pdfviewer
|
||||||
|
|
||||||
# append to the history file, don't overwrite it
|
# append to the history file, don't overwrite it
|
||||||
shopt -s histappend
|
shopt -s histappend
|
||||||
# write history after each command
|
# write history after each command
|
||||||
@@ -179,7 +193,7 @@ export QUOTING_STYLE=literal
|
|||||||
# avoid these stupid systemd defaults (horizontal scroll and pager)
|
# avoid these stupid systemd defaults (horizontal scroll and pager)
|
||||||
alias systemctl="systemctl --no-pager --full"
|
alias systemctl="systemctl --no-pager --full"
|
||||||
|
|
||||||
# aliases for ls and history
|
# aliases/functions for usual commands (ls, history, grep...)
|
||||||
alias l='ls -F'
|
alias l='ls -F'
|
||||||
alias ls='ls -F'
|
alias ls='ls -F'
|
||||||
alias l1='ls -1F'
|
alias l1='ls -1F'
|
||||||
@@ -213,6 +227,10 @@ alias hl="history 25" # long
|
|||||||
alias hll="history 100" # very long
|
alias hll="history 100" # very long
|
||||||
alias hlll="history" # all history
|
alias hlll="history" # all history
|
||||||
|
|
||||||
|
alias grep='grep --color=auto' # add colors to grep
|
||||||
|
alias fgrep='fgrep --color=auto'
|
||||||
|
alias egrep='egrep --color=auto'
|
||||||
|
|
||||||
# user temp directory
|
# user temp directory
|
||||||
export USERTMP=~/tmp
|
export USERTMP=~/tmp
|
||||||
|
|
@@ -15,12 +15,6 @@
|
|||||||
# i.e., add at the end of .bashrc.$USER:
|
# i.e., add at the end of .bashrc.$USER:
|
||||||
# [ -f "$HOME/.bashrc.$USER.$(hostname)" ] && . "$HOME/.bashrc.$USER.$(hostname)"
|
# [ -f "$HOME/.bashrc.$USER.$(hostname)" ] && . "$HOME/.bashrc.$USER.$(hostname)"
|
||||||
|
|
||||||
# ibus
|
|
||||||
#export GTK
|
|
||||||
|
|
||||||
# look for a pdf viewer
|
|
||||||
hash atril 2> /dev/null && alias acroread=atril
|
|
||||||
|
|
||||||
# mysql aliases. Will match any "[client-XXX]" lines in ~/.my.cnf
|
# mysql aliases. Will match any "[client-XXX]" lines in ~/.my.cnf
|
||||||
# and generate "myXXX" aliases.
|
# and generate "myXXX" aliases.
|
||||||
if [[ -r ~/.my.cnf ]]; then
|
if [[ -r ~/.my.cnf ]]; then
|
||||||
@@ -71,13 +65,11 @@ _vardir() {
|
|||||||
# shellcheck disable=SC2139
|
# shellcheck disable=SC2139
|
||||||
alias "$_a"="$_x"
|
alias "$_a"="$_x"
|
||||||
}
|
}
|
||||||
#_vardir AOC aoc + ~/dev/advent-of-code # Advent of code
|
_vardir CHESS chess + ~/dev/brchess # brchess
|
||||||
_vardir WCHESS wchess - ~/dev/www/crd/chess # raoult.com chess
|
_vardir ENGINES engines - ~/dev/chess-engines # chess engines
|
||||||
_vardir CHESS chess + ~/dev/brchess # brchess
|
_vardir TOOLS tools - ~/dev/tools # tools
|
||||||
_vardir TOOLS tools - ~/dev/tools # tools
|
_vardir BRLIB brlib - ~/dev/brlib # brlib
|
||||||
_vardir BRLIB brlib - ~/dev/brlib # brlib
|
_vardir DEV dev - ~/dev # dev
|
||||||
#_vardir EUD eud + ~/dev/eudyptula # eudyptula
|
|
||||||
_vardir DEV dev - ~/dev # dev
|
|
||||||
|
|
||||||
# Indent style for emacs
|
# Indent style for emacs
|
||||||
# Local Variables:
|
# Local Variables:
|
@@ -15,9 +15,6 @@
|
|||||||
# i.e., add at the end of .bashrc.$USER:
|
# i.e., add at the end of .bashrc.$USER:
|
||||||
# [ -f "$HOME/.bashrc.$USER.$(hostname)" ] && . "$HOME/.bashrc.$USER.$(hostname)"
|
# [ -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
|
# mysql aliases. Will match any "[client-XXX]" lines in ~/.my.cnf
|
||||||
# and generate "myXXX" aliases.
|
# and generate "myXXX" aliases.
|
||||||
if [[ -r ~/.my.cnf ]]; then
|
if [[ -r ~/.my.cnf ]]; then
|
||||||
@@ -68,13 +65,14 @@ _vardir() {
|
|||||||
# shellcheck disable=SC2139
|
# shellcheck disable=SC2139
|
||||||
alias "$_a"="$_x"
|
alias "$_a"="$_x"
|
||||||
}
|
}
|
||||||
_vardir AOC aoc + ~/dev/advent-of-code # Advent of code
|
_vardir AOC aoc + ~/dev/advent-of-code # Advent of code
|
||||||
_vardir WCHESS wchess - ~/dev/www/crd/chess # raoult.com chess
|
_vardir WCHESS wchess - ~/dev/www/crd/chess # raoult.com chess
|
||||||
_vardir CHESS chess + ~/dev/brchess # brchess
|
_vardir CHESS chess + ~/dev/brchess # brchess
|
||||||
_vardir TOOLS tools - ~/dev/tools # tools
|
_vardir ENGINES engines - ~/dev/chess-engines # chess engines
|
||||||
_vardir BRLIB brlib - ~/dev/brlib # brlib
|
_vardir TOOLS tools - ~/dev/tools # tools
|
||||||
_vardir EUD eud + ~/dev/eudyptula # eudyptula
|
_vardir BRLIB brlib - ~/dev/brlib # brlib
|
||||||
_vardir DEV dev - ~/dev # dev
|
_vardir EUD eud + ~/dev/eudyptula # eudyptula
|
||||||
|
_vardir DEV dev - ~/dev # dev
|
||||||
|
|
||||||
# Indent style for emacs
|
# Indent style for emacs
|
||||||
# Local Variables:
|
# Local Variables:
|
211
config/home/bashrc.root
Normal file
211
config/home/bashrc.root
Normal file
@@ -0,0 +1,211 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
#
|
||||||
|
# ~/.bashrc.root - root bash startup
|
||||||
|
#
|
||||||
|
# (C) Bruno Raoult ("br"), 2001-2024
|
||||||
|
# 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"
|
||||||
|
#
|
||||||
|
# Debian default ~/.profile usually does:
|
||||||
|
# 1) source .bashrc if it exists
|
||||||
|
# 2) add "$HOME"/bin in PATH
|
||||||
|
# This imply a duplicate "$HOME/bin" in PATH, as we do everything here.
|
||||||
|
# Better to have a ~/.bash_profile with the lines above.
|
||||||
|
|
||||||
|
# _var_del() - remove an element from a colon-separated list.
|
||||||
|
# $1: name (reference) of a colon separated list
|
||||||
|
# $2: element to remove (string)
|
||||||
|
#
|
||||||
|
# _var_del() removes every occurrence of $2, if there are more than 1,
|
||||||
|
# and leaves $1 unchanged if $2 is not present.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# With VAR's value being "foo:bar:quax:bar". Using "_var_del VAR bar" will
|
||||||
|
# leave VAR with the value "foo:quax".
|
||||||
|
_var_del() {
|
||||||
|
local -n _p_del=$1
|
||||||
|
local _l=":$_p_del:"
|
||||||
|
|
||||||
|
while [[ $_l =~ :$2: ]]; do
|
||||||
|
_l=${_l//:$2:/:}
|
||||||
|
done
|
||||||
|
_l=${_l%:}
|
||||||
|
_l=${_l#:}
|
||||||
|
_p_del="$_l"
|
||||||
|
}
|
||||||
|
|
||||||
|
# _var_prepend() - prepend element to colon-separated variable.
|
||||||
|
# $1: variable name (reference)
|
||||||
|
# $2: element to add (string)
|
||||||
|
#
|
||||||
|
# Any occurrence of $2 in $1 is first removed, then $2 is added at $1 beginning.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# With VAR's value being "foo:bar:quax:bar". Using "_var_prepend VAR bar"
|
||||||
|
# will leave VAR with the value "bar:foo:quax".
|
||||||
|
_var_prepend() {
|
||||||
|
local -n _p_prepend=$1
|
||||||
|
|
||||||
|
_var_del _p_prepend "$2"
|
||||||
|
[[ -z $_p_prepend ]] && _p_prepend="$2" && return
|
||||||
|
_p_prepend="$2:$_p_prepend"
|
||||||
|
}
|
||||||
|
|
||||||
|
# _var_append() - append element to colon-separated variable.
|
||||||
|
# $1: variable name (reference)
|
||||||
|
# $2: element to add (string)
|
||||||
|
#
|
||||||
|
# Any occurrence of $2 in $1 is first removed, then $2 is added at $1 end.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# With VAR's value being "foo:bar:quax:bar". Using "_var_append VAR bar"
|
||||||
|
# will leave VAR with the value "foo:quax:bar".
|
||||||
|
_var_append() {
|
||||||
|
local -n _p_append=$1
|
||||||
|
|
||||||
|
_var_del _p_append "$2"
|
||||||
|
[[ -z $_p_append ]] && _p_append="$2" && return
|
||||||
|
_p_append="$_p_append:$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
# adjust PATH. Below paths will be added at beginning.
|
||||||
|
_lpath=("$HOME/bin/$(uname -s)-$(uname -m)"
|
||||||
|
"$HOME/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
|
||||||
|
_var_prepend PATH "${_lpath[_i]}"
|
||||||
|
done
|
||||||
|
unset _lpath
|
||||||
|
|
||||||
|
# enable core file
|
||||||
|
ulimit -HSc 102400 # in 1024 bytes - Really cannot use KiB :-)
|
||||||
|
|
||||||
|
# ... 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
|
||||||
|
|
||||||
|
# no Emacs for root
|
||||||
|
# emacs clones, then vim/vi, then... whatever left.
|
||||||
|
_VISUALS=(zile mg jed vim vi nano ed)
|
||||||
|
for e in "${_VISUALS[@]}"; do
|
||||||
|
if hash "$e" 2>/dev/null; then
|
||||||
|
export VISUAL="$e"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
unset _VISUALS
|
||||||
|
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="ignorespace:ignoredups:erasedups"
|
||||||
|
# ignore these in history
|
||||||
|
export HISTIGNORE="history *:h:hl:hll:hlll"
|
||||||
|
# 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
|
||||||
|
|
||||||
|
# aliases/functions 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
|
||||||
|
|
||||||
|
alias grep='grep --color=auto' # add colors to grep
|
||||||
|
alias fgrep='fgrep --color=auto'
|
||||||
|
alias egrep='egrep --color=auto'
|
||||||
|
|
||||||
|
# misc aliases
|
||||||
|
alias fuck='sudo $(history -p \!\!)'
|
||||||
|
alias diff='diff -u'
|
||||||
|
|
||||||
|
# Indent style for emacs
|
||||||
|
# Local Variables:
|
||||||
|
# mode: shell-script
|
||||||
|
# sh-basic-offset: 4
|
||||||
|
# sh-indentation: 4
|
||||||
|
# indent-tabs-mode: nil
|
||||||
|
# comment-column: 32
|
||||||
|
# End:
|
@@ -1,7 +1,7 @@
|
|||||||
;;;; ~/.Emacs.d/init.el
|
;;;; ~/.Emacs.d/init.el
|
||||||
;;;;
|
;;;;
|
||||||
;;;; emacs configuration
|
;;;; emacs configuration
|
||||||
;;;; br, 2010-2023
|
;;;; br, 2010-2024
|
||||||
;;;;
|
;;;;
|
||||||
;;;; all personal variables/defun are prefixed with "my/".
|
;;;; all personal variables/defun are prefixed with "my/".
|
||||||
;;
|
;;
|
||||||
@@ -15,6 +15,8 @@
|
|||||||
;; (require 'use-package)
|
;; (require 'use-package)
|
||||||
(package-initialize)
|
(package-initialize)
|
||||||
(setq use-package-always-ensure t)
|
(setq use-package-always-ensure t)
|
||||||
|
;; (setq package-check-signature nil)
|
||||||
|
(use-package delight :ensure t)
|
||||||
|
|
||||||
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
|
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/"))
|
||||||
;;(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
|
;;(add-to-list 'package-archives '("org" . "http://orgmode.org/elpa/"))
|
||||||
@@ -34,8 +36,7 @@
|
|||||||
"Directory where to store all temp and backup files.")
|
"Directory where to store all temp and backup files.")
|
||||||
(setq backup-directory (concat my/emacs-tmpdir "/backups/")
|
(setq backup-directory (concat my/emacs-tmpdir "/backups/")
|
||||||
save-directory (concat my/emacs-tmpdir "/autosave/")
|
save-directory (concat my/emacs-tmpdir "/autosave/")
|
||||||
auto-save-list-file-prefix (concat my/emacs-tmpdir "/autosave-list/")
|
auto-save-list-file-prefix (concat my/emacs-tmpdir "/autosave-list/"))
|
||||||
)
|
|
||||||
|
|
||||||
;; create dirs if necessary
|
;; create dirs if necessary
|
||||||
(dolist (dir (list backup-directory save-directory auto-save-list-file-prefix))
|
(dolist (dir (list backup-directory save-directory auto-save-list-file-prefix))
|
||||||
@@ -76,6 +77,8 @@
|
|||||||
(defun risky-local-variable-p (sym &optional _ignored) "Zoba SYM." nil)
|
(defun risky-local-variable-p (sym &optional _ignored) "Zoba SYM." nil)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; swap modifier keysyms (japanese keyboard)
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; swap modifier keysyms (japanese keyboard)
|
||||||
|
;; Done in .xmodmap
|
||||||
|
;;
|
||||||
;; windows key (super) becomes hyper
|
;; windows key (super) becomes hyper
|
||||||
;;(setq x-super-keysym 'hyper)
|
;;(setq x-super-keysym 'hyper)
|
||||||
;; alt key (meta) becomes super
|
;; alt key (meta) becomes super
|
||||||
@@ -254,23 +257,33 @@ Return new LIST-VAR value."
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ggtags
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ggtags
|
||||||
(use-package ggtags
|
(use-package ggtags
|
||||||
:ensure t
|
:ensure t
|
||||||
:diminish ggtags-mode
|
:diminish "gg"
|
||||||
:disabled t
|
:disabled t
|
||||||
:defer t
|
;; :defer t
|
||||||
|
:after cc-mode
|
||||||
:init
|
:init
|
||||||
(setq ggtags-global-window-height 28
|
(setq ggtags-global-window-height 28
|
||||||
ggtags-enable-navigation-keys nil)
|
ggtags-enable-navigation-keys nil)
|
||||||
|
(add-hook 'c-mode-common-hook
|
||||||
(after cc-mode (add-hook 'c-mode-common-hook #'ggtags-mode))
|
(lambda ()
|
||||||
|
(when (derived-mode-p 'c-mode 'c++-mode 'java-mode)
|
||||||
|
(ggtags-mode 1))))
|
||||||
|
;;(after cc-mode (add-hook 'c-mode-common-hook #'ggtags-mode))
|
||||||
|
|
||||||
:config
|
:config
|
||||||
(bind-keys :map ggtags-mode-map
|
(bind-keys :map ggtags-mode-map
|
||||||
("C-c g s" . ggtags-find-other-symbol)
|
;;("C-c g s" . ggtags-find-other-symbol)
|
||||||
("C-c g h" . ggtags-view-tag-history)
|
;;("C-c g h" . ggtags-view-tag-history)
|
||||||
("C-c g r" . ggtags-find-reference)
|
;;("C-c g r" . ggtags-find-reference)
|
||||||
("C-c g f" . ggtags-find-file)
|
;;("C-c g f" . ggtags-find-file)
|
||||||
("C-c g c" . ggtags-create-tags)
|
;;("C-c g c" . ggtags-create-tags)
|
||||||
("C-c g u" . ggtags-update-tags)
|
;;("C-c g u" . ggtags-update-tags)
|
||||||
|
("H-g s" . ggtags-find-other-symbol)
|
||||||
|
("H-g h" . ggtags-view-tag-history)
|
||||||
|
("H-g r" . ggtags-find-reference)
|
||||||
|
("H-g f" . ggtags-find-file)
|
||||||
|
("H-g c" . ggtags-create-tags)
|
||||||
|
("H-g u" . ggtags-update-tags)
|
||||||
("M-," 'pop-tag-mark)))
|
("M-," 'pop-tag-mark)))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; projectile
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; projectile
|
||||||
@@ -278,6 +291,7 @@ Return new LIST-VAR value."
|
|||||||
(use-package projectile
|
(use-package projectile
|
||||||
;;:diminish projectile-mode
|
;;:diminish projectile-mode
|
||||||
:diminish " prj"
|
:diminish " prj"
|
||||||
|
;; :delight
|
||||||
:ensure t
|
:ensure t
|
||||||
:config
|
:config
|
||||||
;;(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
|
;;(define-key projectile-mode-map (kbd "s-p") 'projectile-command-map)
|
||||||
@@ -287,7 +301,9 @@ Return new LIST-VAR value."
|
|||||||
;;projectile-indexing-method 'alien ;; does not use ".projectile"
|
;;projectile-indexing-method 'alien ;; does not use ".projectile"
|
||||||
projectile-indexing-method 'hybrid
|
projectile-indexing-method 'hybrid
|
||||||
;;projectile-indexing-method 'native
|
;;projectile-indexing-method 'native
|
||||||
projectile-completion-system 'default)
|
projectile-completion-system 'auto
|
||||||
|
projectile-tags-backend 'ggtags)
|
||||||
|
|
||||||
(add-to-list 'projectile-globally-ignored-files "*.png")
|
(add-to-list 'projectile-globally-ignored-files "*.png")
|
||||||
(projectile-mode +1))
|
(projectile-mode +1))
|
||||||
|
|
||||||
@@ -301,8 +317,10 @@ Return new LIST-VAR value."
|
|||||||
:config
|
:config
|
||||||
(setq magit-delete-by-moving-to-trash nil
|
(setq magit-delete-by-moving-to-trash nil
|
||||||
magit-clone-default-directory "~/dev/")
|
magit-clone-default-directory "~/dev/")
|
||||||
(magit-auto-revert-mode -1))
|
(magit-auto-revert-mode -1)
|
||||||
|
:bind
|
||||||
|
(("C-c g" . magit-file-dispatch)
|
||||||
|
("C-x g" . magit-status)))
|
||||||
|
|
||||||
(use-package git-gutter
|
(use-package git-gutter
|
||||||
:diminish
|
:diminish
|
||||||
@@ -340,6 +358,9 @@ Return new LIST-VAR value."
|
|||||||
tramp-verbose 1)
|
tramp-verbose 1)
|
||||||
;; (customize-set-variable 'tramp-syntax 'simplified)
|
;; (customize-set-variable 'tramp-syntax 'simplified)
|
||||||
|
|
||||||
|
;; Emacs 29.1 ?
|
||||||
|
;;(autoload #'tramp-register-crypt-file-name-handler "tramp-crypt")
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; conf mode
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; conf mode
|
||||||
;; strangely ".cnf" is not here...
|
;; strangely ".cnf" is not here...
|
||||||
(use-package conf-mode
|
(use-package conf-mode
|
||||||
@@ -428,12 +449,23 @@ Return new LIST-VAR value."
|
|||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Some useful setups
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Some useful setups
|
||||||
;; mouse
|
;; mouse
|
||||||
;; does not change point when getting focus - DOES NOT WORK
|
;; does not change point when getting focus - DOES NOT WORK
|
||||||
;;x-mouse-click-focus-ignore-position t
|
;; (setq x-mouse-click-focus-ignore-position t)
|
||||||
;;focus-follows-mouse nil ; must reflect WM settings
|
;;focus-follows-mouse nil ; must reflect WM settings
|
||||||
;;mouse-autoselect-window nil ; pointer does not select window
|
;;mouse-autoselect-window nil ; pointer does not select window
|
||||||
|
|
||||||
(global-set-key (kbd "C-h c") 'describe-char)
|
(global-set-key (kbd "C-h c") 'describe-char)
|
||||||
(global-set-key (kbd "C-x 4 C-b") 'switch-to-buffer-other-window)
|
(global-set-key (kbd "C-x 4 C-b") 'switch-to-buffer-other-window)
|
||||||
|
(global-unset-key [mode-line mouse-3]) ; disabble annoying modeline mouse-3
|
||||||
|
|
||||||
|
;; compilation buffer in different frame
|
||||||
|
;; https://emacs.stackexchange.com/a/21393/23591
|
||||||
|
;; (push "*compilation*" special-display-buffer-names)
|
||||||
|
;; https://emacs.stackexchange.com/a/75534/23591
|
||||||
|
(add-to-list 'display-buffer-alist
|
||||||
|
(cons (rx string-start "*compilation*" string-end)
|
||||||
|
(cons 'display-buffer-reuse-window
|
||||||
|
'((reusable-frames . visible)
|
||||||
|
(inhibit-switch-frames . nil)))))
|
||||||
|
|
||||||
;; next example maps C-x C-x to the same as C-c
|
;; next example maps C-x C-x to the same as C-c
|
||||||
;; (global-set-key (kbd "C-x C-x") (lookup-key global-map (kbd "C-c")))
|
;; (global-set-key (kbd "C-x C-x") (lookup-key global-map (kbd "C-c")))
|
||||||
@@ -460,7 +492,7 @@ Return new LIST-VAR value."
|
|||||||
tab-width 2 ; default tab width
|
tab-width 2 ; default tab width
|
||||||
)
|
)
|
||||||
|
|
||||||
(setq-default indent-tabs-mode nil)
|
(setq-default indent-tabs-mode nil) ; no tabs
|
||||||
|
|
||||||
(icomplete-mode 0) ; minibuffer completion
|
(icomplete-mode 0) ; minibuffer completion
|
||||||
; soooo sloooow
|
; soooo sloooow
|
||||||
@@ -476,7 +508,10 @@ Return new LIST-VAR value."
|
|||||||
(setq display-time-24hr-format t) ; time format
|
(setq display-time-24hr-format t) ; time format
|
||||||
(display-time-mode 0) ; disable time in the mode-line
|
(display-time-mode 0) ; disable time in the mode-line
|
||||||
|
|
||||||
(defalias 'yes-or-no-p 'y-or-n-p) ; just 'y' or 'n' instead of yes/no
|
(if (< emacs-major-version 29) ; just 'y' or 'n' instead of yes/no
|
||||||
|
(defalias 'yes-or-no-p 'y-or-n-p)
|
||||||
|
(setopt use-short-answers t))
|
||||||
|
(setq duplicate-line-final-position -1) ; point on last new line
|
||||||
|
|
||||||
(mouse-avoidance-mode 'exile) ; Avoid collision of mouse with point
|
(mouse-avoidance-mode 'exile) ; Avoid collision of mouse with point
|
||||||
|
|
||||||
@@ -655,6 +690,7 @@ point reaches the beginning or end of the buffer, stop there."
|
|||||||
|
|
||||||
(global-set-key (kbd "M-u") 'my/upcase-word)
|
(global-set-key (kbd "M-u") 'my/upcase-word)
|
||||||
(global-set-key (kbd "M-l") 'my/downcase-word)
|
(global-set-key (kbd "M-l") 'my/downcase-word)
|
||||||
|
(global-set-key (kbd "H-y") 'duplicate-dwim)
|
||||||
|
|
||||||
;; rewrite comment-kill to avoid filling kill-ring
|
;; rewrite comment-kill to avoid filling kill-ring
|
||||||
;; From: https://emacs.stackexchange.com/a/5445/23591
|
;; From: https://emacs.stackexchange.com/a/5445/23591
|
||||||
@@ -710,6 +746,25 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
(while (re-search-forward "\\(^[[:space:]\n]+\\)\n" nil t)
|
(while (re-search-forward "\\(^[[:space:]\n]+\\)\n" nil t)
|
||||||
(replace-match "\n"))))
|
(replace-match "\n"))))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; multiple cursors
|
||||||
|
(use-package multiple-cursors
|
||||||
|
:bind
|
||||||
|
(("C-c m t" . mc/mark-all-like-this)
|
||||||
|
("C-c m m" . mc/mark-all-like-this-dwim)
|
||||||
|
("C-c m l" . mc/edit-lines)
|
||||||
|
("C-c m e" . mc/edit-ends-of-lines)
|
||||||
|
("C-c m a" . mc/edit-beginnings-of-lines)
|
||||||
|
("C-c m n" . mc/mark-next-like-this)
|
||||||
|
("C-c m p" . mc/mark-previous-like-this)
|
||||||
|
("C-c m s" . mc/mark-sgml-tag-pair)
|
||||||
|
("C-c m d" . mc/mark-all-like-this-in-defun)
|
||||||
|
("C->" . mc/mark-next-like-this)
|
||||||
|
("C-<" . mc/mark-previous-like-this)
|
||||||
|
("C-S-<mouse-1>" . mc/add-cursor-on-click)
|
||||||
|
("C-M-m" . mc/mark-all-dwim)))
|
||||||
|
(use-package phi-search)
|
||||||
|
(use-package phi-search-mc :config (phi-search-mc/setup-keys))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; shell, eshell modes
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; shell, eshell modes
|
||||||
;; will tell e-shell to run in visual mode
|
;; will tell e-shell to run in visual mode
|
||||||
'(eshell-visual-commands
|
'(eshell-visual-commands
|
||||||
@@ -727,7 +782,7 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
"Switch the buffers between the two last frames."
|
"Switch the buffers between the two last frames."
|
||||||
(interactive)
|
(interactive)
|
||||||
(let ((this-frame-buffer nil)
|
(let ((this-frame-buffer nil)
|
||||||
(other-frame-buffer nil))
|
(other-frame-buffer nil))
|
||||||
(setq this-frame-buffer (car (frame-parameter nil 'buffer-list)))
|
(setq this-frame-buffer (car (frame-parameter nil 'buffer-list)))
|
||||||
(other-frame 1)
|
(other-frame 1)
|
||||||
(setq other-frame-buffer (car (frame-parameter nil 'buffer-list)))
|
(setq other-frame-buffer (car (frame-parameter nil 'buffer-list)))
|
||||||
@@ -758,7 +813,7 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
;; https://emacs.stackexchange.com/questions/10955
|
;; https://emacs.stackexchange.com/questions/10955
|
||||||
(advice-add #'vc-git-mode-line-string :filter-return #'my/replace-git-status)
|
(advice-add #'vc-git-mode-line-string :filter-return #'my/replace-git-status)
|
||||||
(defun my/replace-git-status (tstr)
|
(defun my/replace-git-status (tstr)
|
||||||
"Replace git `variable:vc-mode' string with a modified followed by TSTR."
|
"Replace git `variable:vc-mode' string with a UTF8 symbol followed by TSTR."
|
||||||
(let* ((tstr (replace-regexp-in-string "Git" "" tstr))
|
(let* ((tstr (replace-regexp-in-string "Git" "" tstr))
|
||||||
(first-char (substring tstr 0 1))
|
(first-char (substring tstr 0 1))
|
||||||
(rest-chars (substring tstr 1)))
|
(rest-chars (substring tstr 1)))
|
||||||
@@ -842,41 +897,34 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
|
|
||||||
(global-set-key (kbd "C-x w") 'compare-windows)
|
(global-set-key (kbd "C-x w") 'compare-windows)
|
||||||
|
|
||||||
;; multiple cursors
|
;; as dot-mode uses <insert>, we allow overwrite-mode with S-<insert>
|
||||||
(global-set-key (kbd "C->") 'mc/mark-next-like-this)
|
(global-set-key (kbd "S-<insert>") 'overwrite-mode)
|
||||||
(global-set-key (kbd "C-<") 'mc/mark-previous-like-this)
|
|
||||||
(global-set-key (kbd "C-c C-<") 'mc/mark-all-like-this)
|
|
||||||
(global-set-key (kbd "C-S-<mouse-1>") 'mc/add-cursor-on-click)
|
|
||||||
(global-set-key (kbd "C-M-m") 'mc/mark-all-dwim)
|
|
||||||
|
|
||||||
(global-set-key (kbd "C-x g") 'magit-status)
|
|
||||||
|
|
||||||
;; (global-set-key (kbd "s-SPC") 'delete-blank-lines)
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; define my own keymap (s-c)
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; define my own keymap (s-c)
|
||||||
;; first, define a keymap, with Super-c as prefix.
|
;; first, define a keymap, with Super-c as prefix.
|
||||||
(defvar my/keys-mode-map (make-sparse-keymap)
|
;; (defvar my/keys-mode-map (make-sparse-keymap)
|
||||||
"Keymap for my/keys-mode.")
|
;; "Keymap for my/keys-mode.")
|
||||||
|
|
||||||
(defvar my/keys-mode-prefix-map (lookup-key global-map (kbd "s-c"))
|
;; (defvar my/keys-mode-prefix-map (lookup-key global-map (kbd "s-c"))
|
||||||
"Keymap for custom key bindings starting with s-c prefix.")
|
;; "Keymap for custom key bindings starting with s-c prefix.")
|
||||||
|
|
||||||
;; (define-key my/keys-mode-map (kbd "s-c") my/keys-mode-prefix-map)
|
;; ;; (define-key my/keys-mode-map (kbd "s-c") my/keys-mode-prefix-map)
|
||||||
|
|
||||||
(define-minor-mode my/keys-mode
|
;; (define-minor-mode my/keys-mode
|
||||||
"A minor mode for custom key bindings."
|
;; "A minor mode for custom key bindings."
|
||||||
:lighter "s-c"
|
;; :lighter "s-c"
|
||||||
:keymap 'my/keys-mode-map
|
;; :keymap 'my/keys-mode-map
|
||||||
:global t)
|
;; :global t)
|
||||||
|
|
||||||
(defun my/prioritize-keys
|
;; (defun my/prioritize-keys
|
||||||
(file &optional noerror nomessage nosuffix must-suffix)
|
;; (file &optional noerror nomessage nosuffix must-suffix)
|
||||||
"Try to ensure that custom key bindings always have priority."
|
;; "Try to ensure that custom key bindings always have priority."
|
||||||
(unless (eq (caar minor-mode-map-alist) 'my/keys-mode)
|
;; (unless (eq (caar minor-mode-map-alist) 'my/keys-mode)
|
||||||
(let ((my/keys-mode-map (assq 'my/keys-mode minor-mode-map-alist)))
|
;; (let ((my/keys-mode-map (assq 'my/keys-mode minor-mode-map-alist)))
|
||||||
(assq-delete-all 'my/keys-mode minor-mode-map-alist)
|
;; (assq-delete-all 'my/keys-mode minor-mode-map-alist)
|
||||||
(add-to-list 'minor-mode-map-alist my/keys-mode-map))))
|
;; (add-to-list 'minor-mode-map-alist my/keys-mode-map))))
|
||||||
|
|
||||||
(advice-add 'load :after #'my/prioritize-keys)
|
;; (advice-add 'load :after #'my/prioritize-keys)
|
||||||
|
|
||||||
;;(global-set-key (kbd "C-c t") #'make-temp-buffer)
|
;;(global-set-key (kbd "C-c t") #'make-temp-buffer)
|
||||||
;;(define-key my/keys-mode-prefix-map (kbd "r b") #'revert-buffer)
|
;;(define-key my/keys-mode-prefix-map (kbd "r b") #'revert-buffer)
|
||||||
@@ -891,11 +939,13 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
:diminish helm-mode
|
:diminish helm-mode
|
||||||
:init
|
:init
|
||||||
;;(progn
|
;;(progn
|
||||||
;;(require 'helm-config)
|
;; (require 'helm-config)
|
||||||
;;(require 'helm-autoloads)
|
;; (require 'helm-autoloads)
|
||||||
(require 'pcomplete)
|
(require 'pcomplete)
|
||||||
(require 'helm-projectile)
|
(require 'helm-projectile)
|
||||||
|
;; (require 'tramp)
|
||||||
(setq
|
(setq
|
||||||
|
|
||||||
helm-candidate-number-limit 100
|
helm-candidate-number-limit 100
|
||||||
;; From https://gist.github.com/antifuchs/9238468
|
;; From https://gist.github.com/antifuchs/9238468
|
||||||
helm-split-window-inside-p t ; open helm buffer in current window
|
helm-split-window-inside-p t ; open helm buffer in current window
|
||||||
@@ -917,6 +967,8 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
helm-scroll-amount 8 ; scroll 8 lines other window M-<NEXT>
|
helm-scroll-amount 8 ; scroll 8 lines other window M-<NEXT>
|
||||||
|
|
||||||
helm-ff-file-name-history-use-recentf t
|
helm-ff-file-name-history-use-recentf t
|
||||||
|
helm-move-to-line-cycle-in-source nil
|
||||||
|
;; helm-ff-auto-update-initial-value nil
|
||||||
helm-echo-input-in-header-line t) ; ??
|
helm-echo-input-in-header-line t) ; ??
|
||||||
;;)
|
;;)
|
||||||
(helm-mode)
|
(helm-mode)
|
||||||
@@ -941,10 +993,19 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
("<tab>" . helm-execute-persistent-action)
|
("<tab>" . helm-execute-persistent-action)
|
||||||
("C-i" . helm-execute-persistent-action) ; make TAB works in terminal
|
("C-i" . helm-execute-persistent-action) ; make TAB works in terminal
|
||||||
("C-z" . helm-select-action) ; list actions using C-z
|
("C-z" . helm-select-action) ; list actions using C-z
|
||||||
|
)
|
||||||
;; bookmarks
|
;;("<left>" . helm-previous-source)
|
||||||
|
;;("<right>" . helm-next-source)
|
||||||
))
|
;;:map helm-imenu-map
|
||||||
|
;;("<left>" . helm-previous-source)
|
||||||
|
;;("<right>" . helm-next-source)
|
||||||
|
;;:map helm-find-files-map
|
||||||
|
;;("<left>" . helm-previous-source)
|
||||||
|
;;("<right>" . helm-next-source))
|
||||||
|
:bind*
|
||||||
|
(:map helm-find-files-map
|
||||||
|
("<left>" . helm-previous-source)
|
||||||
|
("<right>" . helm-next-source)))
|
||||||
|
|
||||||
(use-package helm-swoop
|
(use-package helm-swoop
|
||||||
:bind
|
:bind
|
||||||
@@ -995,27 +1056,59 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
;;(define-key whole-line-or-region-local-mode-map [remap uncomment-region] nil)
|
;;(define-key whole-line-or-region-local-mode-map [remap uncomment-region] nil)
|
||||||
)
|
)
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; undo tree
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; vundo / undo-tree / winner
|
||||||
(use-package undo-tree
|
;; vundo config from :
|
||||||
:diminish undo-tree-mode
|
;; https://www.reddit.com/r/emacs/comments/txwwfi/vundo_is_great_visual_undotree_for_emacs28/
|
||||||
:defer t
|
(use-package vundo
|
||||||
:init
|
:commands (vundo)
|
||||||
(progn
|
|
||||||
(defalias 'redo 'undo-tree-redo)
|
|
||||||
(defalias 'undo 'undo-tree-undo)
|
|
||||||
(global-undo-tree-mode 1))
|
|
||||||
:config
|
:config
|
||||||
(progn
|
;; Take less on-screen space.
|
||||||
(setq undo-tree-visualizer-timestamps t
|
(setq vundo-compact-display t)
|
||||||
undo-tree-visualizer-diff t
|
|
||||||
undo-tree-enable-undo-in-region t
|
;; Better contrasting highlight.
|
||||||
;;undo-tree-auto-save-history t
|
(custom-set-faces
|
||||||
)
|
'(vundo-node ((t (:foreground "#808080"))))
|
||||||
(let ((undo-dir (concat my/emacs-tmpdir "/undo-tree/")))
|
'(vundo-stem ((t (:foreground "#808080"))))
|
||||||
(setq undo-tree-history-directory-alist
|
'(vundo-highlight ((t (:foreground "#FFFF00")))))
|
||||||
`(("." . ,undo-dir)))
|
|
||||||
(unless (file-exists-p undo-dir)
|
;; Use `HJKL` VIM-like motion, also Home/End to jump around.
|
||||||
(make-directory undo-dir t)))))
|
;; (define-key vundo-mode-map (kbd "l") #'vundo-forward)
|
||||||
|
(define-key vundo-mode-map (kbd "<right>") #'vundo-forward)
|
||||||
|
;; (define-key vundo-mode-map (kbd "h") #'vundo-backward)
|
||||||
|
(define-key vundo-mode-map (kbd "<left>") #'vundo-backward)
|
||||||
|
;; (define-key vundo-mode-map (kbd "j") #'vundo-next)
|
||||||
|
(define-key vundo-mode-map (kbd "<down>") #'vundo-next)
|
||||||
|
;; (define-key vundo-mode-map (kbd "k") #'vundo-previous)
|
||||||
|
(define-key vundo-mode-map (kbd "<up>") #'vundo-previous)
|
||||||
|
(define-key vundo-mode-map (kbd "<home>") #'vundo-stem-root)
|
||||||
|
(define-key vundo-mode-map (kbd "<end>") #'vundo-stem-end)
|
||||||
|
(define-key vundo-mode-map (kbd "q") #'vundo-confirm)
|
||||||
|
(define-key vundo-mode-map (kbd "C-g") #'vundo-quit)
|
||||||
|
(define-key vundo-mode-map (kbd "RET") #'vundo-confirm))
|
||||||
|
|
||||||
|
(global-set-key (kbd "C-x u") 'vundo)
|
||||||
|
|
||||||
|
;; (use-package undo-tree
|
||||||
|
;; :diminish undo-tree-mode
|
||||||
|
;; :defer t
|
||||||
|
;; :init
|
||||||
|
;; (progn
|
||||||
|
;; (defalias 'redo 'undo-tree-redo)
|
||||||
|
;; (defalias 'undo 'undo-tree-undo)
|
||||||
|
;; (global-undo-tree-mode 1))
|
||||||
|
;; :config
|
||||||
|
;; (progn
|
||||||
|
;; (setq undo-tree-visualizer-timestamps t
|
||||||
|
;; undo-tree-visualizer-diff t
|
||||||
|
;; undo-tree-enable-undo-in-region t
|
||||||
|
;; ;;undo-tree-auto-save-history t
|
||||||
|
;; )
|
||||||
|
;; (let ((undo-dir (concat my/emacs-tmpdir "/undo-tree/")))
|
||||||
|
;; (setq undo-tree-history-directory-alist
|
||||||
|
;; `(("." . ,undo-dir)))
|
||||||
|
;; (unless (file-exists-p undo-dir)
|
||||||
|
;; (make-directory undo-dir t)))))
|
||||||
|
|
||||||
;; useful to come back to working window after a buffer has popped up
|
;; useful to come back to working window after a buffer has popped up
|
||||||
;; C-c <left> to come back
|
;; C-c <left> to come back
|
||||||
@@ -1040,7 +1133,8 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
;; ([return] . nil)
|
;; ([return] . nil)
|
||||||
("TAB" . company-complete-selection)
|
("TAB" . company-complete-selection)
|
||||||
;; ([tab] . company-complete-selection)
|
;; ([tab] . company-complete-selection)
|
||||||
("<right>" . company-complete-common))
|
;;("<right>" . company-complete-common)
|
||||||
|
)
|
||||||
:config
|
:config
|
||||||
;; Too slow !
|
;; Too slow !
|
||||||
;; (global-company-mode 1)
|
;; (global-company-mode 1)
|
||||||
@@ -1174,7 +1268,13 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
;; (message "entering Makefile-mode")
|
;; (message "entering Makefile-mode")
|
||||||
(setq indent-tabs-mode t
|
(setq indent-tabs-mode t
|
||||||
tab-width 8
|
tab-width 8
|
||||||
comment-column 60))
|
comment-column 60
|
||||||
|
comment-fill-column 120)
|
||||||
|
;;(defadvice comment-indent (around indent-to activate)
|
||||||
|
;; "Disable indent-tab-mode when indenting comment."
|
||||||
|
;; (lambda (fun &rest args) (let (indent-tabs-mode) (apply fun args))))
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
(add-hook 'makefile-mode-hook 'my/makefile-mode-hook)
|
(add-hook 'makefile-mode-hook 'my/makefile-mode-hook)
|
||||||
|
|
||||||
@@ -1333,7 +1433,15 @@ in whole buffer. With neither, delete comments on current line."
|
|||||||
comment-auto-fill-only-comments nil
|
comment-auto-fill-only-comments nil
|
||||||
comment-style 'extra-line))
|
comment-style 'extra-line))
|
||||||
|
|
||||||
(add-hook 'c-mode-hook 'my/c-style)
|
(use-package cc-mode
|
||||||
|
:ensure nil
|
||||||
|
:config
|
||||||
|
(add-hook 'c-mode-common-hook
|
||||||
|
(lambda ()
|
||||||
|
;;(when (derived-mode-p 'c-mode 'c++-mode 'java-mode 'asm-mode)
|
||||||
|
(when (derived-mode-p 'c-mode)
|
||||||
|
(ggtags-mode 1))))
|
||||||
|
(add-hook 'c-mode-hook 'my/c-style))
|
||||||
|
|
||||||
;;;;;;;;;;;;; linux kernel style
|
;;;;;;;;;;;;; linux kernel style
|
||||||
(defun c-lineup-arglist-tabs-only (ignored)
|
(defun c-lineup-arglist-tabs-only (ignored)
|
||||||
@@ -2112,8 +2220,8 @@ The output will appear in the buffer *PHP*."
|
|||||||
;;; c-mode
|
;;; c-mode
|
||||||
(sp-with-modes '(c-mode c++-mode)
|
(sp-with-modes '(c-mode c++-mode)
|
||||||
(sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET")))
|
(sp-local-pair "{" nil :post-handlers '(("||\n[i]" "RET")))
|
||||||
(sp-local-pair "/*" "*/" :post-handlers '((" | " "SPC")
|
(sp-local-pair "/*" "*/" :post-handlers '(("| " "SPC")
|
||||||
("* ||\n[i]" "RET"))))
|
("* ||\n[i]" "RET"))))
|
||||||
;;; markdown-mode
|
;;; markdown-mode
|
||||||
(sp-with-modes '(markdown-mode gfm-mode rst-mode)
|
(sp-with-modes '(markdown-mode gfm-mode rst-mode)
|
||||||
(sp-local-pair "*" "*" :bind "C-*")
|
(sp-local-pair "*" "*" :bind "C-*")
|
||||||
@@ -2146,7 +2254,7 @@ The output will appear in the buffer *PHP*."
|
|||||||
'sh-mode-hook
|
'sh-mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(setq indent-tabs-mode nil
|
(setq indent-tabs-mode nil
|
||||||
tab-width 4
|
tab-width 4
|
||||||
sh-basic-offset 4
|
sh-basic-offset 4
|
||||||
comment-column 50
|
comment-column 50
|
||||||
comment-auto-fill-only-comments t
|
comment-auto-fill-only-comments t
|
||||||
@@ -2171,7 +2279,7 @@ The output will appear in the buffer *PHP*."
|
|||||||
;;lsp-enable-on-type-formatting nil
|
;;lsp-enable-on-type-formatting nil
|
||||||
lsp-enable-snippet nil
|
lsp-enable-snippet nil
|
||||||
lsp-enable-symbol-highlighting t
|
lsp-enable-symbol-highlighting t
|
||||||
lsp-lens-enable t
|
lsp-lens-enable nil
|
||||||
lsp-headerline-breadcrumb-enable t
|
lsp-headerline-breadcrumb-enable t
|
||||||
lsp-enable-indentation nil
|
lsp-enable-indentation nil
|
||||||
lsp-enable-on-type-formatting nil
|
lsp-enable-on-type-formatting nil
|
||||||
@@ -2180,6 +2288,8 @@ The output will appear in the buffer *PHP*."
|
|||||||
lsp-modeline-code-actions-enable t
|
lsp-modeline-code-actions-enable t
|
||||||
lsp-modeline-code-actions-segments '(count icon name)
|
lsp-modeline-code-actions-segments '(count icon name)
|
||||||
lsp-signature-render-documentation t)
|
lsp-signature-render-documentation t)
|
||||||
|
;;(define-key lsp-mode-map (kbd "<mouse-3>") nil)
|
||||||
|
;;(define-key lsp-mode-map (kbd "C-S-<mouse-3>") 'lsp-mouse-click)
|
||||||
:hook
|
:hook
|
||||||
((sh-mode . lsp-deferred)
|
((sh-mode . lsp-deferred)
|
||||||
;;(c-mode-common . lsp-deferred)
|
;;(c-mode-common . lsp-deferred)
|
||||||
@@ -2189,14 +2299,22 @@ The output will appear in the buffer *PHP*."
|
|||||||
:ensure t
|
:ensure t
|
||||||
;;:diminish
|
;;:diminish
|
||||||
:config
|
:config
|
||||||
(setq ; lsp-ui-doc-show-with-cursor t
|
(setq lsp-ui-doc-show-with-cursor t
|
||||||
; lsp-ui-doc-show-with-mouse t
|
lsp-ui-doc-show-with-mouse nil ; breaks isearch
|
||||||
lsp-ui-sideline-enable t
|
|
||||||
lsp-ui-sideline-show-code-actions t
|
lsp-ui-sideline-enable nil ; too messy
|
||||||
lsp-ui-sideline-enable t
|
|
||||||
lsp-ui-sideline-show-hover t
|
lsp-ui-sideline-show-hover t
|
||||||
lsp-ui-sideline-enable t
|
lsp-ui-sideline-show-symbol t
|
||||||
lsp-ui-doc-enable nil)
|
lsp-ui-sideline-show-code-actions t
|
||||||
|
;; lsp-ui-doc-enable nil
|
||||||
|
;; TRIED 2024/02/26
|
||||||
|
lsp-ui-doc-enable t
|
||||||
|
lsp-ui-doc-max-width 80
|
||||||
|
lsp-ui-doc-max-height 20
|
||||||
|
lsp-ui-doc-include-signature t ; type signature in doc
|
||||||
|
lsp-ui-doc-enhanced-markdown t ; looks b0rken (lists...)
|
||||||
|
lsp-ui-doc-position 'top ; top/bottom/at-point
|
||||||
|
lsp-ui-doc-alignment 'window)
|
||||||
|
|
||||||
:commands
|
:commands
|
||||||
(lsp-ui-mode)
|
(lsp-ui-mode)
|
||||||
@@ -2219,7 +2337,7 @@ The output will appear in the buffer *PHP*."
|
|||||||
:diminish " ccls"
|
:diminish " ccls"
|
||||||
:init
|
:init
|
||||||
(setq ccls-initialization-options
|
(setq ccls-initialization-options
|
||||||
'(:index (:comments 2) :completion (:detailedLabel t)))
|
'(:index (:comments 2) :completion (:detailedLabel t)))
|
||||||
(setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck c/c++-gcc))
|
(setq-default flycheck-disabled-checkers '(c/c++-clang c/c++-cppcheck c/c++-gcc))
|
||||||
(setq ccls-sem-highlight-method 'font-lock)
|
(setq ccls-sem-highlight-method 'font-lock)
|
||||||
;; alternatively,
|
;; alternatively,
|
||||||
@@ -2318,11 +2436,22 @@ at beginning and end of lines."
|
|||||||
(while (re-search-forward "[ \t]+" nil t)
|
(while (re-search-forward "[ \t]+" nil t)
|
||||||
(replace-match " "))
|
(replace-match " "))
|
||||||
;; remove spaces at lines beginning
|
;; remove spaces at lines beginning
|
||||||
(goto-char (point-min))
|
;;(goto-char (point-min))
|
||||||
(while (re-search-forward "^[ \t]+" nil t)
|
;;(while (re-search-forward "^[ \t]+" nil t)
|
||||||
(replace-match ""))
|
;; (replace-match ""))
|
||||||
;; remove spaces at line start/end
|
;; remove spaces at line start/end
|
||||||
(delete-trailing-whitespace))))
|
;(delete-trailing-whitespace)
|
||||||
|
)))
|
||||||
|
|
||||||
|
(defun my/align-c-array (beg end)
|
||||||
|
"Align array declaration on commas between BEG and END."
|
||||||
|
(interactive "r")
|
||||||
|
(save-excursion
|
||||||
|
(save-restriction
|
||||||
|
(narrow-to-region beg end)
|
||||||
|
(my/trim-spaces (point-min) (point-max))
|
||||||
|
(align-regexp (point-min) (point-max) "\\(\\s-[[:alnum:]-_]+,\\)" -1 1 t)
|
||||||
|
(indent-region (point-min) (point-max) nil))))
|
||||||
|
|
||||||
(defun my/align (beg end)
|
(defun my/align (beg end)
|
||||||
"Align columns with spaces."
|
"Align columns with spaces."
|
@@ -35,14 +35,15 @@
|
|||||||
|
|
||||||
(defconst my/loaded-files-at-startup
|
(defconst my/loaded-files-at-startup
|
||||||
(list
|
(list
|
||||||
"~/dev/brlib/Makefile"
|
|
||||||
"~/dev/brchess/Makefile"
|
"~/dev/brchess/Makefile"
|
||||||
|
"~/dev/brlib/Makefile"
|
||||||
;;"~/org/boot-disk.org"
|
;;"~/org/boot-disk.org"
|
||||||
;;"~/org/beaglebone-buster-setup.org"
|
;;"~/org/beaglebone-buster-setup.org"
|
||||||
;;"~/dev/www/cf.bodi/sql/coc.sql"
|
;;"~/dev/www/cf.bodi/sql/coc.sql"
|
||||||
;;"~/dev/www/cf.bodi/sql/coc-sql.org"
|
;;"~/dev/www/cf.bodi/sql/coc-sql.org"
|
||||||
user-init-file
|
user-init-file
|
||||||
"~/dev/tools/bash/Makefile"
|
;; "~/dev/tools/bash/Makefile"
|
||||||
|
"~/dev/brchess/src/board.c"
|
||||||
"~/org/emacs-cheatsheet.org")
|
"~/org/emacs-cheatsheet.org")
|
||||||
;;"~/dev/g910/g910-gkey-macro-support/lib/data_mappers/char_uinput_mapper.py"
|
;;"~/dev/g910/g910-gkey-macro-support/lib/data_mappers/char_uinput_mapper.py"
|
||||||
;;"~/dev/advent-of-code/2022/Makefile"
|
;;"~/dev/advent-of-code/2022/Makefile"
|
Reference in New Issue
Block a user