Browse Source

Primo commit

master
me 1 year ago
commit
71e6baf0da
  1. 2
      .gitattributes
  2. 99
      .gitignore
  3. 76
      README.org
  4. 10
      common/common.windows-registry
  5. 2
      emacs/.emacs.d.symlinks
  6. 11
      emacs/.emacs.d/.gitignore
  7. 163
      emacs/.emacs.d/early-init.el
  8. 1503
      emacs/.emacs.d/gb-init.el
  9. 3337
      emacs/.emacs.d/gb-init.org
  10. BIN
      emacs/.emacs.d/img/Logob-w.png
  11. BIN
      emacs/.emacs.d/img/Logog-b.png
  12. 89
      emacs/.emacs.d/img/logo-BlackGreen-noText.svg
  13. 67
      emacs/.emacs.d/img/logo-GOLEM-text.svg
  14. 72
      emacs/.emacs.d/img/logo-GOLEM-website.svg
  15. 89
      emacs/.emacs.d/img/logo-WhiteBlack-noText.svg
  16. BIN
      emacs/.emacs.d/img/original_Logob-w.png
  17. BIN
      emacs/.emacs.d/img/original_Logog-b.png
  18. 227
      emacs/.emacs.d/init.el
  19. 16
      emacs/emacs.windows-registry
  20. 2
      git/.git_template.symlink/hooks/.gitattributes
  21. 30
      git/.git_template.symlink/hooks/pre-commit
  22. 19
      git/.gitconfig.symlink
  23. 18
      git/.gitconfig_include.windows-symlink
  24. 99
      git/.gitignore_global.symlink
  25. 206
      install.ps1
  26. 162
      install.sh
  27. 24
      runme_linux.sh
  28. 14
      runme_win.cmd
  29. 2
      vim/.vim.symlinks
  30. 1
      vim/.vim/.gitattributes
  31. 136
      vim/.vimrc.symlink

2
.gitattributes

@ -0,0 +1,2 @@
.vimrc.symlink text eol=lf
.gitattributes text eol=lf

99
.gitignore

@ -0,0 +1,99 @@
# -*- mode: gitignore; -*-
#
# https://www.toptal.com
#
# ------------------------------------------------------------------------
# WINDOWS gitignore settings
# ------------------------------------------------------------------------
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# EMACS gitignore settings
# ------------------------------------------------------------------------
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
ltximg/**
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
# network security
/network-security.data
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# VIM gitignore settings
# ------------------------------------------------------------------------
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
# ------------------------------------------------------------------------

76
README.org

@ -0,0 +1,76 @@
* Il frankenscript
E' il risultato di scopiazzamenti vari messi insieme con lo scotch e la colla di pesce.
Purtroppo è passato un bel po' di tempo e non ricordo da dove ho preso il codice.
Agli autori dimenticati vanno tutti i miei ringraziamenti.
Il "tool" (se così si può chiamare) è in realtà composto da due branche: una per Linux
e l'altra per Windows.
Il funzionamento delle due branche è essenzialmente uguale e segue la stessa struttura:
- runme_* :: E' lo script di "bootstrap". Ha il compito di impostare l'ambiente e richiamare
lo script di gestione dei link simbolici.
- install.* :: E' lo script che esegue il lavoro vero e proprio di gestione dei link
simbolici e dell'unico vezzo relativo alla configurazione di Git.
Il file da eseguire è quindi "runme_linux.sh" in ambiente Linux o "runme_win.cmd" in
ambiente Windows.
Per Windows occorre avere i diritti di creazione dei link simbolici o eseguire lo script
con "esegui come administratore".
* L'organizzazione dei dotfiles
La gestione è un po' datata e prende in considerazione come destinazione soltanto la =$HOME=.
I dotfiles sono gestiti in "gruppi" ciascuno identificato da una directory, dare un nome
descrittivo alla directory è utile, ma non è necessario. Non c'è nessun legame tra il
nome della directory ed il suo contenuto.
Queste le directory ustate:
- common: elementi "comuni" o non necessrariamente abbinati ad un software.
- emacs: elementi di configurazione dei dotfiles relativi a GNU Emacs
- git: elementi di configurazione dei dotfiles relativi a Git
- vim: elementi di configurazione dei dotfiles relativi a Vim
All'interno di ciascuna directory gli elementi vengono gestiti in base alla tipolgia
(estensione) dei files.
** *.windows-registry
Deve essere gestito come elemento del registro di configurazione di Windows.
Il contenuto è stato creato con un export che viene quindi importato.
** *.symlink
Senza la "S" finale!
E' il file a cui si vuole agganciare il link simbolico. Il nome del link simbolico
sarà lo stesso del file.
Se ad esempio ho il file ~.gitconfig.symlink~, dopo l'esecuzione dello script mi
ritroverò nella =$HOME= o nella =%USERPROFILE%= ~.gitconfig~ come link simbolico.
** *.symlinks
Notare la "S" finale!
Contiene la lista delle destinazioni dei link simbolici.
Necessaria quando i nomi delle destinazioni sono diverse tra Linux
e Windows (unici elementi gestiti).
Facciamo un esempio.
Se ho un file (ma non c'è differenza se dovessi avere una directory) di nome ~.pippo.conf~
ed ho la necessità di creare un link simbolico che si chiama ~_pippo.conf~ per Windows
mentre quello per Linux resta invariato continuado a chiamarsi ~.pippo.conf~ devo agire così:
- avere il file reale che si chiame ~.pippo.conf~
- creare un file di testo che si chiama ~.pippo.conf.symlinks~ (ricordarsi della S finale)
e il cui contenuto deve essere di due righe:
- ~linux: .pippo.conf~
- ~windows: _pippo.conf~
Eseguendo lo script in Linux mi troverò nella =$HOME= ~.pippo.conf~ (link simbolico che punta
al file fisico nel repository dei dotfiles).
Eseguendo lo script in Windows mi ritroverò nella =%USERPROFILE%= ~_pippo.conf~ (sempre
link simbolico).

10
common/common.windows-registry

@ -0,0 +1,10 @@
{
"RegistryEntries": [
{
Path: "HKCU:\\Environment",
Key: {Name: "HOME",
Type: "ExpandString",
Value: "%USERPROFILE%"}
}
]
}

2
emacs/.emacs.d.symlinks

@ -0,0 +1,2 @@
linux: .emacs.d
windows: .emacs.d

11
emacs/.emacs.d/.gitignore

@ -0,0 +1,11 @@
# -*- mode: gitignore; -*-
auto-save-list/
elpa/
emms/
eshell/
games/
server/
transient/
url/
amx-items
recentf

163
emacs/.emacs.d/early-init.el

@ -0,0 +1,163 @@
;;; early-init.el --- File di configurazione "early-init" di GNU Emacs -*- mode: emacs-lisp; lexical-binding: t;-*-
;; Copyright (C) 2020 Geraldo Biotti
;; Author: Geraldo Biotti <gbiotti@gmail.com>
;; Created: 20200731
;; Keywords: init, early-init, .emacs.d, startup
;; Compatiblity: emacs-version >= 27
;; This file is not part of GNU Emacs.
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Questo file contiene le impostazioni di GNU Emacs che vengono eseguite
;; durante la fase di Early Init.
;;
;; La fase di Early Init e' stata introdotta con GNU Emacs versione 27
;;
;; Per maggiori informazioni fare riferimento al manuale di GNU Emacs
;; versione 27 o successiva: 49.4.6 - The Early Init File
;;; To do:
;;; Change log:
;;; Code:
;; N.B.: Ho rimosso l'impostazione del lexical-binding:
;; -*- lexical-binding: t; -*-
;; Imposto l'ora di avvio di Emacs
;; Servira' alla fine per determinare quanto tempo e' trascorso
(defconst gb/emacs/emacs-startup-time (current-time))
;; Imposto le varibili di appoggio usate per ripristinare
;; le impostazioni di default procedura di inizializzazione
(defvar gb/emacs/gc-cons-threshold-original gc-cons-threshold
"Valore originale di 'gc-cons-threshold' prima della modifica.
Salvato per ripristinarlo alla fine della procedura di inizializzazione")
(defvar gb/emacs/gc-cons-percentage-original gc-cons-percentage
"Valore originale di 'gc-cons-percentage' prima della modifica.
Salvato per ripristinarlo alla fine della procedura di inizializzazione")
(defvar gb/emacs/file-name-handler-alist-original file-name-handler-alist
"Valore originale di 'file-name-handler-alist' prima della modifica.
Salvato per ripristinarlo alla fine della procedura di inizializzazione")
;; Imposta la soglia del garbage collector
;; Da reimpostare poi ai valori corretti con apposito
;; codice richiamato in after-init-hook
(setq gc-cons-threshold (* 1024 (* 1024 1024)) ; 1 GByte
gc-cons-percentage 0.6)
;; Imposta file-name-handler-alist
;; Da reimpostare poi ai valori corretti con apposito
;; codice richiamato in after-init-hook
(setq file-name-handler-alist nil)
;; Aggiungo ad after-init-hook il codice necessario
;; per reimpostare i valori di default nelle variabili
;; usate qui sopra e fare una garbage-collect finale.
;; Si usa una depth 90 (vedi docstring di di "add-hook")
(add-hook 'after-init-hook
'(lambda ()
;; Non imposto piu' 'gc-cons-threshold' al suo valore originale ma, come
;; riportato in molti siti ad un valore molto piu' alto.
;; Si veda, ad esempio qui: https://emacs-lsp.github.io/lsp-mode/page/performance/
;; (consultato 31/08/2020)
;; (setq gc-cons-threshold gb/emacs/gc-cons-threshold-original)
;; 100 Mb = (* 1024 (* 1024 100)))
(setq gc-cons-threshold (* 1024 (* 1024 100)))
;; Sempre https://emacs-lsp.github.io/lsp-mode/page/performance/
;; raccomanda di impostare 'read-process-output-max' ad un valore di 1Mb
;; (numero massimo di bytes letti in un singolo chunk dai subprocess)
(setq read-process-output-max (* 1024 1024))
(setq gc-cons-percentage gb/emacs/gc-cons-percentage-original)
(setq file-name-handler-alist gb/emacs/file-name-handler-alist-original)
(garbage-collect)
(defvar gb/emacs/elapsed (float-time
(time-subtract (current-time) gb/emacs/emacs-startup-time))
)
(message (emacs-init-time))
(message "Loading done in %.3fs seconds and %d garbage collections [after-init]"
gb/emacs/elapsed
gcs-done)
)
90
)
;; Non rende disponibili i package all'avvio di Emacs
;; da usare qui e non in init.el
(setq package-enable-at-startup nil)
;; Per GNU Emacs versione 27 e successive
(when (not (version< emacs-version "27"))
(progn
;; Consente il caricamento dalla cache dei package
(setq package-quickstart t)
)
)
;; Non ridimnensiona il frame in questo momento
(setq frame-inhibit-implied-resize t)
;; Su Windows, assumendo di aver installato Scoop, ne metto il path
;; in testa, altrimenti vengono prima trovati gli eseguibili nelle
;; directory di sistema. Questo crea confusione, ad esempio concat
;; "find" che esiste sia in ambiente Linux che in Windows, ovviamente
;; con sintassi completamente diverse. Generalmente mi apsetto che
;; le funzionalita' siano quelle del mondo Linux e non quelle del
;; mondo Windows per cui faccio in modo che vengano lette per prima.
;; Da notare che Scoop aggiunge le sue directory al Path, ma queste
;; sono di tipo utente e vengono aggiunte al path dopo quelle di
;; sistema. Si avra' un "doppione" nel path, ma va bene.
(when (eq system-type 'windows-nt)
(defvar gb/emacs/scoop-shim-path
(concat (expand-file-name "~/scoop/shims")
path-separator)
"Percorso per 'scoop/shims' da aggiungere in testa al PATH."
)
;;(add-to-list 'exec-path "c:/Users/Geraldo/scoop/shims")
(add-to-list 'exec-path gb/emacs/scoop-shim-path)
;; (setenv "PATH" (concat gb/emacs/scoop-shim-path
;; (getenv "PATH")))
)
(provide 'early-init)
;;(progn
;; (setq gb/frame-font
;; (cond ((find-font (font-spec :name "DejaVu Sans mono")) '(font . "DejaVu Sans Mono-10"))
;; ((find-font (font-spec :name "Consolas")) '(font . "Consolas-10"))
;; ((find-font (font-spec :name "Inconsolata")) '(font . "Inconsolata-10"))
;; ((find-font (font-spec :name "Courier New")) '(font . "Courier New-10"))
;; ))
;; (print gb/frame-font)
;; (add-to-list 'default-frame-alist gb/frame-font)
;; (add-to-list 'initial-frame-alist gb/frame-font))
;; ===========================================================================
;; Local Variables:
;; coding: utf-8-unix
;; indent-tabs-mode: nil
;; tab-width: 4
;; End:
;; ===========================================================================
;;; early-init.el ends here

1503
emacs/.emacs.d/gb-init.el

File diff suppressed because it is too large

3337
emacs/.emacs.d/gb-init.org

File diff suppressed because it is too large

BIN
emacs/.emacs.d/img/Logob-w.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
emacs/.emacs.d/img/Logog-b.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

89
emacs/.emacs.d/img/logo-BlackGreen-noText.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 23 KiB

67
emacs/.emacs.d/img/logo-GOLEM-text.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 74 KiB

72
emacs/.emacs.d/img/logo-GOLEM-website.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 32 KiB

89
emacs/.emacs.d/img/logo-WhiteBlack-noText.svg

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 23 KiB

BIN
emacs/.emacs.d/img/original_Logob-w.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 330 KiB

BIN
emacs/.emacs.d/img/original_Logog-b.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 KiB

227
emacs/.emacs.d/init.el

@ -0,0 +1,227 @@
;;; init.el --- File di configurazione di GNU Emacs -*- mode: emacs-lisp; lexical-binding: t;-*-
;; Copyright (C) 2020 Geraldo Biotti
;; Author: Geraldo Biotti <gbiotti@gmail.com>
;; Created: 20200731
;; Keywords: init, early-init, .emacs.d, startup
;; Compatiblity: emacs-version >= 27
;; This file is not part of GNU Emacs.
;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or (at
;; your option) any later version.
;; This program is distributed in the hope that it will be useful, but
;; WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
;; General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;; Questo file contiene le impostazioni di GNU Emacs che vengono eseguite
;; durante la fase di Init.
;; La fase di Init viene eseguita successivamente a quella di Early Init
;;
;; Per maggiori informazioni fare riferimento al manuale di GNU Emacs:
;; 49.4 The Emacs Initialization File
;;; To do:
;;; Change log:
;;; Code:
;; ----------------------------------------------------------------------------------------
;; https://etienne.depar.is/emacs.d/init.html
;; https://github.com/MatthewZMD/.emacs.d
;; https://www.reddit.com/r/emacs/comments/2edbau/what_are_some_great_emacsd_examples/
;; https://www.reddit.com/r/emacs/comments/2edbau/what_are_some_great_emacsd_examples/
;; https://github.com/AndreaCrotti
;; https://github.com/grettke/
;; Pastebin off topic:
;; https://www.privacytools.io/
;; https://alternativeto.net/list/18434/xenmaster-s-privacy-tools
;; https://send-anywhere.com/
;; https://framasoft.org/en/
;; https://gofile.io/welcome
;; ----------------------------------------------------------------------------------------
;; N.B.: Ho rimosso l'impostazione del lexical-binding:
;; -*- lexical-binding: t; -*-
;; Se la versione e' inferiore alla 26.1 emetto un warning
(when (version< emacs-version "26.1")
(warn "E' necessario che GNU Emacs sia in versione 26.1 o successiva!"))
(defun gb/emacs/package-setup ()
"Function che imposta 'package'"
;; Carico il modulo di gestione dei packages
(require 'package)
;; Carica sempre il file piu' recente tra '.el' e '.elc'
(setq load-prefer-newer t)
;; Aggiungo all'elenco dei repositories da cui scaricare i packages
;; la versione "unstable" di Melpa
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
;; Genera dei warnings con i package-install
(unless (bound-and-true-p package--initialized)
(package-initialize))
)
(defun gb/emacs/init-old-emacs-version ()
"Function eseguita per il setup di init.el quando si sta usando Emacs
in versione precedente alla 27"
;; Early-init e' gestito automaticamente dalla versione 27 in poi
;; Se esiste early-init.el lo carico
(let ((gb/emacs/early-init-file (expand-file-name "early-init.el" user-emacs-directory)))
(when (file-exists-p gb/emacs/early-init-file)
(require 'early-init gb/emacs/early-init-file)))
(gb/emacs/package-setup)
)
(defun gb/emacs/init-new-emacs-version ()
"Function eseguita per il setup di init.el quando si sta usando Emacs
in versione 27+"
;; Avvio package
(gb/emacs/package-setup)
)
;; Eseguo le impostazioni in base alla versione di GNU Emacs
(if (version< emacs-version "27")
(gb/emacs/init-old-emacs-version)
(gb/emacs/init-new-emacs-version))
;; Delight e' un package che viene usato da use-package
;; mi accerto che sia installato, se non lo e' lo installo
;; N.B.: Se non si vuole averlo come dipendenza e' bene
;; installarlo prima di use-package
(unless (package-installed-p 'delight)
(unless package-archive-contents
(package-refresh-contents))
(package-install 'delight))
;; Diminish e' un package che viene usato da use-package
;; mi accerto che sia installato, se non lo e' lo installo
;; N.B.: Se non si vuole averlo come dipendenza e' bene
;; installarlo prima di use-package
(unless (package-installed-p 'diminish)
(unless package-archive-contents
(package-refresh-contents))
(package-install 'diminish))
;; Mi accerto che use-package sia installato
;; se non lo e' lo installo
(unless (package-installed-p 'use-package)
(unless package-archive-contents
(package-refresh-contents))
(package-install 'use-package))
;; Carico use-package
(eval-when-compile
(require 'use-package))
;; Configuro use-package prima di caricarlo
(eval-and-compile
(if init-file-debug
(setq use-package-verbose t
use-package-expand-minimally nil
use-package-compute-statistics t
debug-on-error t) ; True
(setq use-package-verbose nil
use-package-expand-minimally t) ; False
)
(setq use-package-enable-imenu-support t
;; Quanto segue e' MOLTO IMPORTANTE:
;; Usare sempre gli hook con il loro nome completo
;; al posto del nome abbreviato:
;; after-init --> after-init-hook
;; Questo migliora la gestione della documentazione
;; a riconoscere il contesto (vedi, ad esempio 'describe-symbol)
use-package-hook-name-suffix nil)
)
;; Configuro vc (package gestione "version cotrol"
(use-package vc
:config
;; Questo perche' i miei "dotfiles" usano i link simbolici
(setq vc-follow-symlinks t)
)
;; Carico org
(use-package org
;; Accertarsi di caricare quello presente nel repository GNU
;; e non quello "builtin": quello in GNU e' sempre aggiornato.
:pin gnu
:ensure org
)
;; Qui avviene la magia.
;; Carico la configurazione dal file "org"
;; Cerco pero' di ottimizzare un mimino la cosa:
;; se il file "el" generato da org-babel e' piu' recente
;; del file "org" allora carico "el" altrimenti passo
;; all'uso di org-babel
(progn (defvar gb/emacs/gb-init "gb-init")
(defvar gb/emacs/conf-filename (expand-file-name gb/emacs/gb-init user-emacs-directory))
(defvar gb/emacs/el-conf-filename (concat gb/emacs/conf-filename ".el"))
(defvar gb/emacs/org-conf-filename (concat gb/emacs/conf-filename ".org"))
(if (file-exists-p gb/emacs/el-conf-filename)
(if (file-newer-than-file-p gb/emacs/org-conf-filename gb/emacs/el-conf-filename)
(progn (message "%s e' piu' recente di %s, ricreo e carico il .el"
gb/emacs/org-conf-filename
gb/emacs/el-conf-filename)
(org-babel-load-file gb/emacs/org-conf-filename))
(progn (message "%s e' meno recente di %s, carico il .el senza ricrearlo"
gb/emacs/org-conf-filename
gb/emacs/el-conf-filename)
(load-file gb/emacs/el-conf-filename)))
(progn (message "Creo e carico %s" gb/emacs/el-conf-filename)
(org-babel-load-file gb/emacs/org-conf-filename))
)
)
;; NON RIMUOVERE CUSTOM DA QUI
;; ---------------------------
;; Si potrebbe cedere alla tentazione di avere un init.el piu' "pulito"
;; spostando custom-set-variables e custom-set-faces in un file separato,
;; ma questo porta spesso a comportamenti altalenanti: se si installa un
;; package con use-package e la sua opzione :ensure, capita che il package
;; venga installato, ma la variabile package-selected-packages non venga
;; aggiornata correttamente portanto il package installato ad uno stato
;; di "dependency" in list-packages con invito alla rimozione qualora questo
;; non fosse effettivamente utilizzato anche come dipendenza da qualche altro
;; package
(custom-set-variables
;; custom-set-variables was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
'(package-selected-packages
'(modus-themes dockerfile-mode cargo docker docker-compose-mode flycheck-rust impatient-mode simple-httpd yasnippet yasnippet-snippets org projectile company-go go-errcheck go-mode company-auctex auctex sql-indent markdown-mode csharp-mode powershell counsel-projectile ibuffer-projectile rainbow-delimiters smartparens flycheck-pos-tip flycheck highlight-indent-guides aggressive-indent pcre2el emms pdf-tools csv-mode pretty-mode elfeed-protocol elfeed-org elfeed-goodies elfeed company-restclient restclient treemacs-all-the-icons treemacs-projectile treemacs-magit treemacs git-timemachine gitattributes-mode gitignore-mode gitconfig-mode magit undo-tree origami company-quickhelp ace-window avy symon beacon htmlize org-edna org-bullets amx ivy-hydra all-the-icons-ivy-rich ivy-rich swiper hydra which-key dashboard minions doom-modeline base16-theme seti-theme moe-theme solarized-theme color-theme-sanityinc-tomorrow dracula-theme atom-one-dark-theme zerodark-theme gruvbox-theme monokai-theme zenburn-theme material-theme spacemacs-theme doom-themes all-the-icons-ibuffer all-the-icons-dired all-the-icons async use-package diminish delight)))
(custom-set-faces
;; custom-set-faces was added by Custom.
;; If you edit it by hand, you could mess it up, so be careful.
;; Your init file should contain only one such instance.
;; If there is more than one, they won't work right.
)
;; ===========================================================================
;; Local Variables:
;; coding: utf-8-unix
;; indent-tabs-mode: nil
;; tab-width: 4
;; End:
;; ===========================================================================
;;; init.el ends here

16
emacs/emacs.windows-registry

@ -0,0 +1,16 @@
{
"RegistryEntries": [
{
Path: "HKCU:\\Software\\GNU\\Emacs",
Key: {Name: "HOME",
Type: "ExpandString",
Value: "%USERPROFILE%"}
},
{
Path: "HKCU:\\Software\\GNU\\Emacs",
Key: {Name: "PWD",
Type: "ExpandString",
Value: "%USERPROFILE%\\Documents"}
}
]
}

2
git/.git_template.symlink/hooks/.gitattributes

@ -0,0 +1,2 @@
* text=auto
pre-commit text eol=lf

30
git/.git_template.symlink/hooks/pre-commit

@ -0,0 +1,30 @@
#!/bin/bash
function get_org_of_current_repo() {
local orgs_from_global_config=$(git config --get-regexp ^orgs. | cut -d . -f 2)
for org in $orgs_from_global_config; do
local org_remotes=$(git remote -v | grep -i $org/)
if [ ! -z "$org_remotes" ]; then
echo $org
fi
done
}
org=$(get_org_of_current_repo)
if [ ! -z "$org" ]; then
organization_email=$(git config orgs\.$org\.email)
repository_email=$(git config --local user.email)
if [ "$organization_email" != "$repository_email" ]; then
echo "Organization '$org' identified!"
echo "Setting the configured e-mail <$organization_email>"
git config --local user.email $organization_email
echo "Please repeat the commit command to use the new e-mail"
exit 1
fi
fi

19
git/.gitconfig.symlink

@ -0,0 +1,19 @@
[core]
editor = vi
quotepath = false
[alias]
graph = log --decorate --oneline --graph
whatsnew = !git log ..origin/`git rev-parse --abbrev-ref HEAD`
[include]
path = ~/.gitconfig_user
path = ~/.gitconfig_include
[init]
templatedir = ~/.git_template
[pull]
rebase = false
[fetch]
prune = false
[rebase]
autoStash = false
# vim: set ft=gitconfig :

18
git/.gitconfig_include.windows-symlink

@ -0,0 +1,18 @@
[core]
autocrlf = true
[diff]
tool = kdiff3
guitool = kdiff3
[difftool]
prompt = false
[difftool "kdiff3"]
path = C:/Program Files/KDiff3/kdiff3.exe
cmd = \"C:/Program Files/KDiff3/kdiff3.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = kdiff3
[mergetool]
keepBackup = false
prompt = false
[mergetool "kdiff3"]
path = C:/Program Files/KDiff3/kdiff3.exe
cmd = \"C:/Program Files/KDiff3/kdiff3.exe\" \"$BASE\" \"$LOCAL\" \"$REMOTE\" -o \"$MERGED\"

99
git/.gitignore_global.symlink

@ -0,0 +1,99 @@
# -*- mode: gitignore; -*-
#
# https://www.toptal.com
#
# ------------------------------------------------------------------------
# WINDOWS gitignore settings
# ------------------------------------------------------------------------
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# EMACS gitignore settings
# ------------------------------------------------------------------------
*~
\#*\#
/.emacs.desktop
/.emacs.desktop.lock
*.elc
auto-save-list
tramp
.\#*
# Org-mode
.org-id-locations
*_archive
ltximg/**
# flymake-mode
*_flymake.*
# eshell files
/eshell/history
/eshell/lastdir
# elpa packages
/elpa/
# reftex files
*.rel
# AUCTeX auto folder
/auto/
# cask packages
.cask/
dist/
# Flycheck
flycheck_*.el
# server auth directory
/server/
# projectiles files
.projectile
# directory configuration
.dir-locals.el
# network security
/network-security.data
# ------------------------------------------------------------------------
# ------------------------------------------------------------------------
# VIM gitignore settings
# ------------------------------------------------------------------------
# Swap
[._]*.s[a-v][a-z]
!*.svg # comment out if you don't need vector files
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
Sessionx.vim
# Temporary
.netrwhist
*~
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
# ------------------------------------------------------------------------

206
install.ps1

@ -0,0 +1,206 @@
# Param must be the first statement in your script
param(
[Parameter(Position = 0, Mandatory = $true)]
[String]$DestUserDomain=$env:USERDOMAIN
,
[Parameter(Position = 1, Mandatory = $true)]
[String]$DestUserName=$env:USERNAME
,
[Parameter(Position = 2, Mandatory = $true)]
[String]$DestHome=$HOME
)
$OS = "windows"
$GIT_USER_CONFIG_FILE = "$DestHome\.gitconfig_user"
$scriptRoot = Split-Path -Path $MyInvocation.MyCommand.Path
#$DOTFILES = Get-Location
$DOTFILES = $scriptRoot
Function Set-DvcsUser {
if (Test-Path $GIT_USER_CONFIG_FILE) {
Write-Host "-> GIT user config file $GIT_USER_CONFIG_FILE already exists. Skipping..."
}
else {
if (!(Test-Path $GIT_USER_CONFIG_FILE)) {
Write-Host "-> Asking Username & Email for GIT user config file ${GIT_USER_CONFIG_FILE}:"
}
$userName = Read-Host "Name"
$userEmail = Read-Host "Email"
if (!(Test-Path $GIT_USER_CONFIG_FILE)) {
Write-Host "-> Creating ${GIT_USER_CONFIG_FILE}:"
@"
[user]
name = $userName
email = $userEmail
"@ | Set-Content $GIT_USER_CONFIG_FILE
$answer = Read-Host "`nDo you want to add an organization-specific email? [y/N]"
if ($answer -match '^[yY]$') {
$orgName = Read-Host "Organization"
$orgUserEmail = Read-Host "Organization Email"
@"
[orgs "$orgName"]
email = $orgUserEmail
"@ | Add-Content $GIT_USER_CONFIG_FILE
}
Write-Host "`n$GIT_USER_CONFIG_FILE created!"
}
}
}
Function Install-Registry {
$registryFiles = Get-ChildItem $DOTFILES\*\* | Where-Object {$_.Name -match "\.($OS-)?registry$"}
$sid = Get-SidFromUser -DomainName $DestUserDomain -UserName $DestUserName
$hkcu = "HKCU:"
foreach ($file in $registryFiles) {
$fileContent = Get-Content -LiteralPath $file | Out-String
$jsonRegistry = ConvertFrom-Json -InputObject $fileContent
foreach ($registryEntry in $jsonRegistry.RegistryEntries) {
# Se in json ho un path che deve lavorare su HKCU non posso
# usare direttamente HKCU perche' prenderebbe quello impersonato
# (l'utente administrator).
# Devo quindi sostituirlo con HKU riferito al sid dell'utente
# che ha effettivamente lanciato lo script tramite il batch di avvio
if ($registryEntry.Path.StartsWith($hkcu)) {
$newString = "HKU:\$sid"
$registryPath = $registryEntry.Path -replace $hkcu, $newString
} else {
$registryPath = $registryEntry.Path
}
# Verifico che il percorso nel registro esista, altrimenti lo creo
if (-not (Test-Path -LiteralPath $registryPath)) {
New-Item -Path $registryPath -Force
}
# Verifico l'esistenza della chiave
if (Test-RegistryValue -Path $registryPath -Name $registryEntry.Key.Name) {
# La chiave esiste. La elimino
Remove-ItemProperty -LiteralPath $registryPath -Name $registryEntry.Key.Name
}
# Nel file Json sono ammessi i seguenti Type:
# String. Specifies a null-terminated string. Equivalent to REG_SZ.
# ExpandString. Specifies a null-terminated string that contains unexpanded references to environment variables that are expanded when the value is retrieved. Equivalent to REG_EXPAND_SZ.
# Binary. Specifies binary data in any form. Equivalent to REG_BINARY.
# DWord. Specifies a 32-bit binary number. Equivalent to REG_DWORD.
# MultiString. Specifies an array of null-terminated strings terminated by two null characters. Equivalent to REG_MULTI_SZ.
# Qword. Specifies a 64-bit binary number. Equivalent to REG_QWORD.
# Unknown. Indicates an unsupported registry data type, such as REG_RESOURCE_LIST.
New-ItemProperty -LiteralPath $registryPath -Name $registryEntry.Key.Name -PropertyType $registryEntry.Key.Type -Value $registryEntry.Key.Value
}
}
}
Function Install-Symlinks {
$filesToSymlink = Get-ChildItem $DOTFILES\*\* | Where-Object {$_.Name -match "\.($OS-)?symlink$"}
foreach ($file in $filesToSymlink) {
$name = Get-Basename $file.Name
$symlink = "$DestHome\$name"
$target = $file.FullName
New-Symlink "$symlink" "$target"
}
}
Function Install-ConfigurableSymlinks {
$symlinkConfigFiles = Get-ChildItem $DOTFILES\*\* | Where-Object {$_.Name -match "\.symlinks$"}
foreach ($configFile in $symlinkConfigFiles) {
$config = Get-Content $configFile.FullName
$matches = $null
$configuredName = $config | ForEach-Object {$null = $_ -match "^$OS" + ':\s+(?<link>.+)$'; $matches.link} | Select-Object -f 1
if ($configuredName) {
$symlink = "$DestHome\$configuredName"
$target = Get-Basename $configFile.FullName
New-Symlink "$symlink" "$target"
}
}
}
Function Get-Basename {
Param($string)
return $string.Substring(0, $string.LastIndexOf('.'))
}
Function New-Symlink {
Param($symlink, $target)
if (Test-Path $target -pathType container) {
# Remove-Item cannot be used to remove folder symlinks,
# because it also removes the target folder.
if (Test-Path $symlink) { cmd /c rmdir /s /q $symlink }
(cmd /c mklink /d $symlink $target) > $null
}
else {
if (Test-Path $symlink) { Remove-Item $symlink }
(cmd /c mklink $symlink $target) > $null
}
Write-Host " $symlink -> $target"
}
Function Get-SidFromUser {
param (
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$DomainName
,
[Parameter(Position = 1, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$UserName
)
process {
$objUser = New-Object System.Security.Principal.NTAccount($DomainName, $UserName)
$strSID = $objUser.Translate([System.Security.Principal.SecurityIdentifier])
$strSID.Value
}
}
Function Test-RegistryValue {
param(
[Alias("PSPath")]
[Parameter(Position = 0, Mandatory = $true, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$Path
,
[Parameter(Position = 1, Mandatory = $true)]
[String]$Name
,
[Switch]$PassThru
)
process {
if (Test-Path $Path) {
$Key = Get-Item -LiteralPath $Path
if ($Key.GetValue($Name, $null) -ne $null) {
if ($PassThru) {
Get-ItemProperty $Path $Name
} else {
$true
}
} else {
$false
}
} else {
$false
}
}
}
New-PSDrive -PSProvider Registry -Name HKU -Root HKEY_USERS
Write-Host "-> Dotfiles directory = $DOTFILES"
Set-DvcsUser
Write-Host "-> Creating registry data..."
Install-Registry
Write-Host "-> Creating symbolic links..."
Install-Symlinks
Install-ConfigurableSymlinks
Write-Host "-> Done!"
Write-Host -NoNewLine "Press any key to continue..."
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")

162
install.sh

@ -0,0 +1,162 @@
#!/usr/bin/env bash
# set -x
function ask() {
# http://djm.me/ask
local prompt default REPLY
while true; do
if [ "${2:-}" = "Y" ]; then
prompt="Y/n"
default=Y
elif [ "${2:-}" = "N" ]; then
prompt="y/N"
default=N
else
prompt="y/n"
default=
fi
# Ask the question (not using "read -p" as it uses stderr not stdout)
echo -n "$1 [$prompt] "
# Read the answer (use /dev/tty in case stdin is redirected from somewhere else)
read REPLY </dev/tty
# Default?
if [ -z "$REPLY" ]; then
REPLY=$default
fi
# Check if the reply is valid
case "$REPLY" in
Y*|y*) return 0 ;;
N*|n*) return 1 ;;
esac
done
}
function set_dvcs_user() {
local DVCS_USER_NAME
local DVCS_USER_EMAIL
local DVCS_ORG_NAME
local DVCS_ORG_EMAIL
if [[ -f $GIT_USER_CONFIG_FILE ]] ; then
echo "-> GIT user config file $GIT_USER_CONFIG_FILE already exists. Skipping..."
else
if [[ ! -f $GIT_USER_CONFIG_FILE ]] ; then
echo "-> Asking Username & Email for GIT user config file $GIT_USER_CONFIG_FILE:"
fi
read -r -p "Name: " DVCS_USER_NAME
read -r -p "Email: " DVCS_USER_EMAIL
if [[ ! -f $GIT_USER_CONFIG_FILE ]] ; then
echo "-> Creating $GIT_USER_CONFIG_FILE:"
cat > $GIT_USER_CONFIG_FILE <<EOF
[user]
name = $DVCS_USER_NAME
email = $DVCS_USER_EMAIL
EOF
if ask "Do you want to add an organization-specific email?" N; then
read -r -p "Organization: " DVCS_ORG_NAME
read -r -p "Organization Email: " DVCS_ORG_EMAIL
cat >> $GIT_USER_CONFIG_FILE <<EOF
[orgs "$DVCS_ORG_NAME"]
email = $DVCS_ORG_EMAIL
EOF
fi
echo "$GIT_USER_CONFIG_FILE created!"
fi
fi
}
function new_symlink() {
local SYM_LINK
local LINK_TARGET
LINK_TARGET="$1"
SYM_LINK="$2"
if [[ ! -h $SYM_LINK ]]; then
ln -s $LINK_TARGET $SYM_LINK
echo " $SYM_LINK -> $LINK_TARGET"
else
if [[ -h $SYM_LINK ]]; then
rm $SYM_LINK
ln -s $LINK_TARGET $SYM_LINK
echo " $SYM_LINK -> $LINK_TARGET"
else
echo " Cannot link $LINK_TARGET to $SYM_LINK"
echo " because $SYM_LINK exists and is not a symbolic link"
fi
fi
}
function get_basename() {
local STRING_PARAM
local RESULT
eval "STRING_PARAM=\$$1"
RESULT=${STRING_PARAM%.*}
eval "$1=$RESULT"
}
function install_symlinks() {
local LINK_FILE
local LINK_FILE_NAME
local SYM_LINK
local LINK_TARGET
for LINK_FILE in $(find $SCRIPT_DIR -name '*.symlink' -or -name '*.$OS_NAME-symlink'); do
LINK_FILE_NAME=$(basename "$LINK_FILE")
SYM_LINK="$DEST_DIR/$LINK_FILE_NAME"
LINK_TARGET="$LINK_FILE"
get_basename SYM_LINK
new_symlink "$LINK_TARGET" "$SYM_LINK"
done
}
function install_configurable_symlinks() {
local LINK_FILE
local CONFIGURED_NAME
local SYM_LINK
local LINK_TARGET
local AWK_COMMAND
for LINK_FILE in $(find $SCRIPT_DIR -name '*.symlinks'); do
AWK_COMMAND="awk 'match(\$0, /^$OS_NAME:\s+(.+)$/, mtch) {print mtch[1]}' $LINK_FILE"
CONFIGURED_NAME=$(eval $AWK_COMMAND)
if [[ $CONFIGURED_NAME ]]; then
SYM_LINK="$DEST_DIR/$CONFIGURED_NAME"
LINK_TARGET="$LINK_FILE"
get_basename LINK_TARGET
new_symlink "$LINK_TARGET" "$SYM_LINK"
fi
done
}
DEST_DIR=$1
if [[ ! $DEST_DIR ]]; then
DEST_DIR=$HOME
fi
OS_NAME="linux"
GIT_USER_CONFIG_FILE="$DEST_DIR/.gitconfig_user"
SCRIPT_SOURCE="${BASH_SOURCE[0]}"
# resolve $SCRIPT_SOURCE until the file is no longer a symlink
while [ -h "$SCRIPT_SOURCE" ]; do
SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
PVR_BASH_SOURCE="$(readlink "$SCRIPT_SOURCE")"
[[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE"
done
SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
if [[ ! -d $DEST_DIR ]]; then
echo "Directory $DEST_DIR does not exists. Quitting"
exit 1
else
echo "-> Dotfiles directory = $SCRIPT_SOURCE"
echo "-> Installing in $DEST_DIR"
echo "-> Configuring Git and Mercurial user..."
set_dvcs_user
echo "-> Creating/updating symbolic links..."
install_symlinks
install_configurable_symlinks
echo "-> Done!"
read -r -p "Press any key to countinue... "
fi
# set +x

24
runme_linux.sh

@ -0,0 +1,24 @@
#!/usr/bin/env bash
SCRIPT_SOURCE="${BASH_SOURCE[0]}"
OLD_DIR=$(pwd)
# resolve $SCRIPT_SOURCE until the file is no longer a symlink
while [ -h "$SCRIPT_SOURCE" ]; do
SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
PVR_BASH_SOURCE="$(readlink "$SCRIPT_SOURCE")"
[[ $SCRIPT_SOURCE != /* ]] && SCRIPT_SOURCE="$SCRIPT_DIR/$SCRIPT_SOURCE"
done
SCRIPT_DIR="$( cd -P "$( dirname "$SCRIPT_SOURCE" )" && pwd )"
cd $SCRIPT_DIR
git submodule update --init --recursive
echo Prima di proseguire accertarsi che la versione di AWK installata sia GAWK
echo altrimenti interrompere
$SCRIPT_DIR/install.sh $@
cd $OLD_DIR

14
runme_win.cmd

@ -0,0 +1,14 @@
@REM ECHO off
SET OLD_DIR=%cd%
SET PSSCRIPT=install.ps1
SET PSCMD=%~dp0%PSSCRIPT%
ECHO Esecuzione dello script PowerShell %PSCMD%
ECHO Per il profilo %USERPROFILE% (%USERDOMAIN%\%USERPROFILE%)
ECHO .
CD %~dp0
git submodule update --init --recursive
PowerShell -Command Start-Process "$PSHome\PowerShell.exe" -Verb RunAs -ArgumentList '-ExecutionPolicy bypass -File %PSCMD% %USERDOMAIN% %USERNAME% %USERPROFILE%'
CD %OLD_DIR%
SET PSCMD=
SET PSSCRIPT=
SET OLD_DIR=

2
vim/.vim.symlinks

@ -0,0 +1,2 @@
linux: .vim
windows: .vim

1
vim/.vim/.gitattributes

@ -0,0 +1 @@
* text eol=lf

136
vim/.vimrc.symlink

@ -0,0 +1,136 @@
set nocompatible
if has("gui_running")
let do_syntax_sel_menu=1
endif
set langmenu=none
if has("win32") || has("win64")
language messages en_US
else
language messages en_US.UTF-8
endif
if has("multi_byte")
if has("win32") || has("win64")
if has("gui_running")
set encoding=utf-8
endif
endif
set encoding=utf-8
endif
set nocompatible
" set modeline
set backspace=indent,eol,start
" Highlight problematic whitespace
" set listchars=tab:>.,trail:.,extends:#,nbsp:.
" set listchars=eol:¶,tab:»,trail:·,extends:>,precedes:<,nbsp:¤
" il carattere per eol (¶) si ottiene con CTRL-vu00b6
" il carattere per tab (») si ottiene con CTRL-vu00bb
" seguito da \<spazio> oppure
" il carattere per trail (·) si ottiene con CTRL-vu00b7
" il carattere per extends (>) e' il carattere di maggiore
" il carattere per precedes (<) e' il carattere di minore
" il carattere per nbsp (¤) si ottiene con CTRL-vu00a4
set listchars=eol:¶,tab:»\ ,trail:·,extends:>,precedes:<,nbsp:¤
set number
set relativenumber
set history=50
set incsearch
set ignorecase
set smartcase
set wrapscan
" Make the 'cw' and like commands put a $ at the end instead of
" just deleting the text and replacing it
set cpoptions=ces$
set statusline=%<%F\ %h%m%r%w%q\ %y\(%{&ff}\)\ %=\ \#%n\ ln:%l\/%L[%P]\ co:%c%V\ %b
set lazyredraw
set showmode
set foldenable
set foldopen=block,insert,jump,mark,percent,quickfix,search,tag,undo
set whichwrap=b,s,h,l,<,>,[,]
set scrolljump=0
set scrolloff=0
set sidescrolloff=0
set wildmenu
set showfulltag
set diffopt+=iwhite
set clipboard+=unnamed
set grepprg=grep\ -nH\ $*
" let loaded_matchparen=1
set showtabline=2
set nostartofline
set nospell " spell checking off (default!)
if has("autocmd")
filetype plugin indent on
augroup vimrcEx
au!
autocmd BufReadPost *
\ if line("'\"") > 1 && line("'\"") <= line("$") |
\ exe "normal! g`\"" |
\ endif
augroup END
endif " has("autocmd")
set nowrap
set autoindent
set tabstop=4
set shiftwidth=4
set softtabstop=4
set noexpandtab
if has("mouse")
set mouse=a
endif
if &t_Co > 2 || has("gui_running")
syntax enable
set hlsearch
set synmaxcol=2048
endif
if has("cmdline_info")
set noruler
set showcmd
endif
if has("statusline")
set laststatus=2
set statusline=%<%f\ " Filename
set statusline+=%w%h%m%r " Options
set statusline+=\ [%{&ff}/%Y] " filetype
set statusline+=\ [%{getcwd()}] " current dir
"set statusline+=\ [A=\%03.3b/H=\%02.2B] " ASCII / Hexadecimal value of char
set statusline+=%=%-14.(%l,%c%V%)\ %p%% " Right aligned file nav info
endif
if has("gui_running")
" GUI
set cursorline
set guicursor=n-v-c:block-Cursor-blinkon0,ve:ver35-Cursor,o:hor50-Cursor,i-ci:ver25-Cursor,r-cr:hor20-Cursor,sm:block-Cursor-blinkwait175-blinkoff150-blinkon175
set cmdheight=2 " Abbreviato: set ch=2
set mousehide
endif
set shortmess+=I
" CTRL-U in insert mode deletes a lot. Use CTRL-G u to first break undo,
" so that you can undo CTRL-U after inserting a line break.
inoremap <C-U> <C-G>u<C-U>
set background=dark
"
" vim: set tabstop=4:shiftwidth=4:filetype=vim:fdm=marker:fileformat=unix:
"
Loading…
Cancel
Save