Merge remote-tracking branch 'origin/master'
commit
ff901964d0
|
@ -112,6 +112,8 @@ Example: to assign some-function to C-i, use
|
||||||
(when (fboundp 'po-find-file-coding-system)
|
(when (fboundp 'po-find-file-coding-system)
|
||||||
(modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\." 'po-find-file-coding-system))
|
(modify-coding-system-alist 'file "\\.po\\'\\|\\.po\\." 'po-find-file-coding-system))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
;; Third-party tools
|
;; Third-party tools
|
||||||
(autoload 'guess-style-set-variable "guess-style" nil t)
|
(autoload 'guess-style-set-variable "guess-style" nil t)
|
||||||
|
|
|
@ -109,14 +109,18 @@
|
||||||
mode-hook
|
mode-hook
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(page-number-mode t)
|
(page-number-mode t)
|
||||||
;; (setq show-trailing-whitespace t)
|
(when (fboundp 'guess-style-guess-all)
|
||||||
|
(guess-style-guess-all))
|
||||||
(whitespace-mode))))
|
(whitespace-mode))))
|
||||||
'(prog-mode-hook lua-mode-hook))
|
'(prog-mode-hook lua-mode-hook))
|
||||||
|
|
||||||
;; WARNING: this can break some configuration files needing whitespaces at the
|
;; WARNING: this can break some configuration files needing whitespaces at the
|
||||||
;; end.
|
;; end.
|
||||||
; (add-hook 'before-save-hook 'delete-trailing-whitespace)
|
; (add-hook 'before-save-hook 'delete-trailing-whitespace)
|
||||||
(setq whitespace-style (quote (face trailing tab-mark)))
|
(setq whitespace-style (quote (face trailing tab-mark)))
|
||||||
;; TODO: whitespace report-on-bogus does not seem to work properly.
|
;; TODO: whitespace report-on-bogus and cleanup do not seem to work properly.
|
||||||
|
;; Empty lines seems to be always true. Report is shown even when style is not
|
||||||
|
;; matching the errors.
|
||||||
; (setq whitespace-action '(report-on-bogus))
|
; (setq whitespace-action '(report-on-bogus))
|
||||||
|
|
||||||
;; Remove whitespaces on region, or whole file.
|
;; Remove whitespaces on region, or whole file.
|
||||||
|
@ -147,8 +151,8 @@
|
||||||
browse-url-browser-function 'browse-url-generic)
|
browse-url-browser-function 'browse-url-generic)
|
||||||
(define-key my-keys-minor-mode-map (kbd "C-M-u") 'browse-url)
|
(define-key my-keys-minor-mode-map (kbd "C-M-u") 'browse-url)
|
||||||
|
|
||||||
;; Default ispell dictionnay
|
;; Default ispell dictionnay. If not set, Emacs uses the current locale.
|
||||||
;; (setq ispell-dictionary "fr")
|
(setq ispell-dictionary "en")
|
||||||
(define-key my-keys-minor-mode-map
|
(define-key my-keys-minor-mode-map
|
||||||
(kbd "<f5>")
|
(kbd "<f5>")
|
||||||
(lambda () (interactive) (ispell-change-dictionary "en")))
|
(lambda () (interactive) (ispell-change-dictionary "en")))
|
||||||
|
@ -195,8 +199,9 @@
|
||||||
;; Run ranger asynchronously.
|
;; Run ranger asynchronously.
|
||||||
(define-key my-keys-minor-mode-map (kbd "C-x D")
|
(define-key my-keys-minor-mode-map (kbd "C-x D")
|
||||||
(lambda () (interactive)
|
(lambda () (interactive)
|
||||||
(shell-command "urxvt -e ranger &")
|
(let ((term (getenv "TERMCMD")))
|
||||||
(delete-windows-on "*Async Shell Command*")))
|
(when (and (executable-find "ranger") (executable-find term))
|
||||||
|
(start-process "dummy" nil term "-e" "ranger")))))
|
||||||
|
|
||||||
;; Calendar ISO display.
|
;; Calendar ISO display.
|
||||||
(setq calendar-week-start-day 1)
|
(setq calendar-week-start-day 1)
|
||||||
|
@ -268,7 +273,7 @@
|
||||||
;; Multiple-Cursors
|
;; Multiple-Cursors
|
||||||
(when (require 'multiple-cursors nil t)
|
(when (require 'multiple-cursors nil t)
|
||||||
(setq mc/list-file (concat emacs-cache-folder "mc-lists.el"))
|
(setq mc/list-file (concat emacs-cache-folder "mc-lists.el"))
|
||||||
;; Load the file at the new location
|
;; Load the file at the new location.
|
||||||
(load mc/list-file t)
|
(load mc/list-file t)
|
||||||
(global-unset-key (kbd "C-<down-mouse-1>"))
|
(global-unset-key (kbd "C-<down-mouse-1>"))
|
||||||
(define-key my-keys-minor-mode-map (kbd "C-<mouse-1>") 'mc/add-cursor-on-click)
|
(define-key my-keys-minor-mode-map (kbd "C-<mouse-1>") 'mc/add-cursor-on-click)
|
||||||
|
|
|
@ -76,7 +76,6 @@ restored."
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(c-set-style "peter")
|
(c-set-style "peter")
|
||||||
(cc-set-compiler)
|
(cc-set-compiler)
|
||||||
(guess-style-guess-all)
|
|
||||||
(local-set-key (kbd "<f9>") 'cc-clean)
|
(local-set-key (kbd "<f9>") 'cc-clean)
|
||||||
(local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline)
|
(local-set-key (kbd "M-TAB") 'semantic-complete-analyze-inline)
|
||||||
(local-set-key (kbd "C-c C-f") 'cc-fori)
|
(local-set-key (kbd "C-c C-f") 'cc-fori)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
## Toggle shell browser autostart and launch terminal.
|
## Invoke a terminal while setting this environment variable. This way the shell
|
||||||
|
## can behave accordingly. This is useful to launch a program from X, which can
|
||||||
|
## then exit to shell, without closing the terminal.
|
||||||
|
|
||||||
if [ -z "$TERMCMD" ]; then
|
if [ -z "$TERMCMD" ]; then
|
||||||
echo 'TERMCMD not set. Exiting.'
|
echo 'TERMCMD not set. Exiting.'
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
COLUMN="1"
|
||||||
|
FORMAT="TOTAL: %s\n"
|
||||||
|
|
||||||
|
if [ "$1" = "-h" ]; then
|
||||||
|
cat<<EOF
|
||||||
|
Usage: ${0##*/} [COLUMN] [FORMAT]
|
||||||
|
|
||||||
|
Sum COLUMN (default to column $COLUMN) and output result with format FORMAT
|
||||||
|
(default to $FORMAT).
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ $# -ge 1 ] && COLUMN="$1" && shift
|
||||||
|
[ $# -ge 1 ] && FORMAT="$1"
|
||||||
|
|
||||||
|
awk -v format="$FORMAT" '{total += $'$COLUMN'; print} END {printf format, total}'
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ $# -ne 3 ] || [ "$1" = "-h" ]; then
|
||||||
|
cat <<EOF
|
||||||
|
Usage: ${0##*/} VALUE IN-CURRENCY OUT-CURRENCY
|
||||||
|
|
||||||
|
Convert VALUE from IN-CURRENCY to OUT-CURRENCY.
|
||||||
|
CURRENCY is a 3-letters code like EUR, SEK, USD, etc.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
curl -sA "Mozilla/5.0" "http://www.google.com/finance?q=$2$3" | \
|
||||||
|
awk -v value=$1 -F '<|>' '/^1 / {print value * substr($3, 1, index($3," "))}'
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "$1" = "-" ] || [ "$1" = "--help" ]; then
|
||||||
|
cat <<EOF
|
||||||
|
Usage: ${0##*/} [FILES]
|
||||||
|
|
||||||
|
Grep non-ascii characters. If no files are provided, use stdin.
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
perl -ne 'chomp; print $_, "\n" if /[[:^ascii:]]/'
|
177
.scripts/pacsize
177
.scripts/pacsize
|
@ -16,133 +16,152 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
################################################################################
|
readonly myname='pacsize'
|
||||||
## Helper functions.
|
readonly myver='4.1.2'
|
||||||
|
|
||||||
calc_total () {
|
calc_total () {
|
||||||
awk '{
|
awk '{
|
||||||
total += $1
|
total += $1
|
||||||
print
|
print
|
||||||
}
|
}
|
||||||
END {
|
END {
|
||||||
printf ("%7s KIB TOTAL\n", total)
|
printf ("%7s KIB TOTAL\n", total)
|
||||||
|
}'
|
||||||
|
}
|
||||||
|
|
||||||
|
error () {
|
||||||
|
echo "$@" >&2
|
||||||
|
}
|
||||||
|
|
||||||
|
## Print size and name. We round to the lowest integer, this makes output
|
||||||
|
## lighter.
|
||||||
|
filter () {
|
||||||
|
awk -F ": " \
|
||||||
|
'$0 ~ "^Name" {
|
||||||
|
pkg = $2
|
||||||
|
}
|
||||||
|
$0 ~ "^Installed Size" {
|
||||||
|
split($2, a, " ")
|
||||||
|
printf ("%4d%s %s\n", a[1], a[2], pkg)
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
remove_duplicates () {
|
remove_duplicates () {
|
||||||
awk '! table[$0]++'
|
awk '! table[$0]++'
|
||||||
}
|
}
|
||||||
|
|
||||||
usage() {
|
usage () {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: ${1##*/} [OPTIONS] PACKAGES
|
Usage: ${1##*/} [OPTIONS] PACKAGES
|
||||||
${1##*/} -a [OPTIONS]
|
${1##*/} -a [OPTIONS]
|
||||||
|
|
||||||
Display package sizes. Duplicates are removed if any. Output can be sorted by
|
Display the size of PACKAGES. Duplicates are removed if any. The local database
|
||||||
name or size. A grand total can be printed at the end. Both the sync and the
|
is queried first; if the package is not found, the sync database is then used
|
||||||
local databes can be used for lookup.
|
for lookup.
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
|
|
||||||
-a: All installed packages. Implies -Q.
|
-a: Process all installed packages.
|
||||||
-h: Show this help.
|
-h: Show this help.
|
||||||
-n: Output is sorted by name.
|
-n: Sort output by name.
|
||||||
-Q: Use local database. It speeds up queries and allows displaying
|
-s: Sort output by size.
|
||||||
size of local packages not available in repos.
|
|
||||||
-S: Use sync database. It is slower but allows to display size of
|
|
||||||
non-installed packages.
|
|
||||||
-s: Output is sorted by size.
|
|
||||||
-t: Print total.
|
-t: Print total.
|
||||||
|
-V: Show version information.
|
||||||
|
|
||||||
Examples:
|
Examples:
|
||||||
|
|
||||||
${1##*/} -ast
|
$ ${1##*/} -ast
|
||||||
Convenient way to keep track of big packages.
|
Convenient way to keep track of big packages.
|
||||||
|
|
||||||
${1##*/} -Q \$(pactree -ld1 linux)
|
$ ${1##*/} \$(pactree -ld1 linux)
|
||||||
Print the size of linux and all its direct dependencies.
|
Print the size of linux and all its direct dependencies.
|
||||||
|
|
||||||
${1##*/} -Qst \$(pacman -Qdtq)
|
$ ${1##*/} -st \$(pacman -Qdtq)
|
||||||
Print a grand total of orphan packages, and sort by size.
|
Print a grand total of orphan packages, and sort by size.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
db="Q"
|
version () {
|
||||||
|
echo "$myname $myver"
|
||||||
|
echo 'Copyright (C) 2014 Pierre Neidhardt <ambrevar@gmail.com>'
|
||||||
|
}
|
||||||
|
|
||||||
opt_sort=false
|
opt_sort=false
|
||||||
opt_all=false
|
opt_all=false
|
||||||
opt_total=false
|
opt_total=false
|
||||||
|
|
||||||
while getopts ":ahnQSst" opt; do
|
while getopts ":ahnstV" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
a)
|
a)
|
||||||
opt_all=true
|
opt_all=true ;;
|
||||||
db="Q" ;;
|
h)
|
||||||
h)
|
usage "$0"
|
||||||
usage "$0"
|
exit ;;
|
||||||
exit ;;
|
n)
|
||||||
n)
|
opt_sort="sort -uk3" ;;
|
||||||
opt_sort="sort -uk3" ;;
|
s)
|
||||||
Q)
|
opt_sort="sort -uh" ;;
|
||||||
db="Q" ;;
|
t)
|
||||||
S)
|
opt_total="calc_total" ;;
|
||||||
db="S" ;;
|
V)
|
||||||
s)
|
version "$0"
|
||||||
opt_sort="sort -un" ;;
|
exit ;;
|
||||||
t)
|
?)
|
||||||
opt_total="calc_total" ;;
|
usage "$0"
|
||||||
?)
|
exit 1 ;;
|
||||||
usage "$0"
|
esac
|
||||||
exit 1 ;;
|
|
||||||
esac
|
|
||||||
done
|
done
|
||||||
|
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
################################################################################
|
## All-packages mode.
|
||||||
## All-packages mode. We use a dedicated algorithm which is much faster than
|
## We use a dedicated algorithm which is much faster than per-package mode.
|
||||||
## per-package mode.
|
## Unfortunately there is no easy way to select packages with this method.
|
||||||
if $opt_all; then
|
if $opt_all; then
|
||||||
DBPath="$(awk -F = '/^ *DBPath/{print $2}' /etc/pacman.conf)"
|
DBPath="$(awk -F "=[ \t]*" '/^[ \t]*DBPath[ \t]*=/{gsub(/[ \t]*$/, "", $2); print $2}' /etc/pacman.conf 2>/dev/null)"
|
||||||
[ ! -d "$DBPath" ] && DBPath="/var/lib/pacman/"
|
[ -z "$DBPath" ] && DBPath="/var/lib/pacman"
|
||||||
[ ! -d "$DBPath/local/" ] && exit
|
|
||||||
|
|
||||||
awk '/^%NAME%/ {
|
if [ ! -d "$DBPath/local/" ]; then
|
||||||
getline
|
error "Could not find local database in $DBPath/local/."
|
||||||
pkg=$0
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
awk 'BEGIN {
|
||||||
|
split("B KiB MiB GiB TiB PiB EiB ZiB YiB", unit)
|
||||||
}
|
}
|
||||||
/^%SIZE%/ {
|
$0 == "%NAME%" {
|
||||||
getline
|
getline pkg
|
||||||
size = $0 / 1024
|
}
|
||||||
printf ("%6s KiB %s\n", size, pkg)
|
$0 == "%SIZE%" {
|
||||||
}' "$DBPath"/local/*/desc | ($opt_sort || cat) | ($opt_total || cat)
|
getline size
|
||||||
exit
|
i = 1
|
||||||
|
while (size > 2048) {
|
||||||
|
size /= 1024
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
printf ("%4d%s %s\n", size, unit[i], pkg)
|
||||||
|
}' "$DBPath"/local/*/desc | { $opt_sort || cat ;} | { $opt_total || cat ;}
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
################################################################################
|
|
||||||
## Per-package mode.
|
## Per-package mode.
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
echo "Missing argument." >&2
|
error "Missing argument."
|
||||||
usage "$0"
|
usage "$0"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
## Remove this check if integrated to pacman.
|
||||||
if ! command -v pacman >/dev/null 2>&1; then
|
if ! command -v pacman >/dev/null 2>&1; then
|
||||||
echo "'pacman' not found." >&2
|
error "'pacman' not found."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Locale.
|
{
|
||||||
LC_NAME="$(gettext pacman "Name")"
|
## If package is not found locally (-Q), we use the sync database (-S). We
|
||||||
LC_SIZE="$(gettext pacman "Installed Size :" | sed 's/ *: *$//')"
|
## use LC_ALL=C to make sure pacman output is not localized.
|
||||||
|
buffer=$(LC_ALL=C pacman -Qi "$@" 2>&1 1>&3 3>&- | cut -f2 -d "'")
|
||||||
|
[ -n "$buffer" ] && LC_ALL=C pacman -Si $buffer
|
||||||
|
} 3>&1 | filter | { $opt_sort || remove_duplicates ;} | { $opt_total || cat ;}
|
||||||
|
|
||||||
## We use external variable for awk to fit current locales. In the following
|
# vim: set noet:
|
||||||
## command, we strip the decimals. This makes output lighter.
|
|
||||||
pacman -${db}i "$@" 2>/dev/null | awk -F ": " \
|
|
||||||
-v pkgsize="$LC_SIZE" -v pkgname="$LC_NAME" \
|
|
||||||
'$0 ~ pkgname {
|
|
||||||
pkg = $2
|
|
||||||
}
|
|
||||||
$0 ~ pkgsize {
|
|
||||||
gsub (/[\.,].*/, "")
|
|
||||||
printf ("%7s KiB %s\n", $2, pkg)
|
|
||||||
}' | ($opt_sort || remove_duplicates) | ($opt_total || cat)
|
|
||||||
|
|
|
@ -1,25 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
rawname=${0##*/}
|
|
||||||
rawname=${rawname#p}
|
|
||||||
|
|
||||||
if [ "$1" = "-h" ]; then
|
|
||||||
cat <<EOF
|
|
||||||
Usage: ${0##*/}
|
|
||||||
|
|
||||||
Run `sessionclean' if available and $rawname the system.
|
|
||||||
|
|
||||||
EOF
|
|
||||||
exit
|
|
||||||
fi
|
|
||||||
|
|
||||||
command -v sessionclean >/dev/null 2>&1 && sessionclean
|
|
||||||
|
|
||||||
## Poweroff / Reboot.
|
|
||||||
## If you do not want to get prompted for your password, configure sudo properly.
|
|
||||||
## TODO: use only "sudo halt -p"?
|
|
||||||
sudo $rawname
|
|
||||||
if command -v systemctl >/dev/null 2>&1; then
|
|
||||||
|
|
||||||
else
|
|
||||||
fi
|
|
|
@ -1,5 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
## Start zsh in the directory specified as first argument.
|
## Start zsh in the directory specified as first argument. Useful for file
|
||||||
|
## browsers to start shell in pointed folder.
|
||||||
|
|
||||||
if [ ! -d "$1" ]; then
|
if [ ! -d "$1" ]; then
|
||||||
zsh
|
zsh
|
||||||
|
|
Loading…
Reference in New Issue