Compare commits

...
Sign in to create a new pull request.

24 commits
main ... anna

Author SHA1 Message Date
587da03cb6 Modifying radian color 2023-04-28 15:13:32 +02:00
e03dfefba1 Trying fish 2023-04-28 14:39:41 +02:00
2e8413c168 Adding Nix 2023-04-28 14:38:40 +02:00
e208e1c9f5 Added cargo and pyenv 2023-03-29 14:09:56 +02:00
e67d0bdcfd Added go 2023-03-02 11:22:25 +01:00
e759527248 27/02/23 Emacs tinkering 2023-02-27 12:04:19 +01:00
bd8d701dcf Enhanced comments and enabled company mode with eglot 2023-02-24 17:38:11 +01:00
2054d46570 Added a bunch of packages, including eglot (LSP client), powerline (cool powerline) and others 2023-02-24 16:36:36 +01:00
80bed3a2ce Fixed PATH problem with bash 2023-02-24 16:30:39 +01:00
69aa46d801 Added multiple path to the PATH env var 2023-02-12 16:24:45 +01:00
6f6de31f18 Added the org-fragtog package to do inline latex edit/preview 2023-01-17 10:18:19 +01:00
0218237590 Added the visual-line-mode and org-appear mode by default 2023-01-17 10:18:19 +01:00
58e1649ee3 Ajout des lignes permettant l'intégration de tous les fichiers du dossier "~/org" dans l'agenda des TODO 2022-12-21 08:52:54 +01:00
dbe6189bf4 Customisarion de init.org et init.el 2022-11-25 17:44:05 +01:00
5404f7b4b5 Added the emacs leuven theme 2022-11-21 21:26:03 +01:00
da3920a0e1 Added graph alias to git for the log --oneline --graph 2022-11-21 08:35:52 +01:00
3e4be21605 Changed the autocompletion behavior 2022-11-21 08:34:46 +01:00
4f9754788c Added 'fuck' alias for thefuck 2022-11-18 08:36:46 +01:00
c688ad773e Added Company mode to init.el & added init.org for easier config 2022-11-18 08:35:39 +01:00
59326d17b0 Custom set variables init.el 2022-11-15 08:57:29 +01:00
963cf00c82 Added the RR MOOC Emacs config 2022-11-15 08:51:39 +01:00
1f22b77f38 Added a quickfix to let EMACS start 2022-11-13 23:52:15 +01:00
ab733ed7fc Added a Bash profile with the git prompt 2022-11-10 17:23:15 +01:00
66b5d5034a Added the .git-prompt.sh 2022-11-10 17:08:30 +01:00
9 changed files with 1993 additions and 1 deletions

View file

@ -1 +1,4 @@
alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' alias dotfiles='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME'
# Creating an alias to have git graph
git config --global alias.graph 'log --oneline --graph'

7
.bash_logout Normal file
View file

@ -0,0 +1,7 @@
# ~/.bash_logout: executed by bash(1) when login shell exits.
# when leaving the console clear the screen to increase privacy
if [ "$SHLVL" = 1 ]; then
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
fi

48
.bash_profile Normal file
View file

@ -0,0 +1,48 @@
if [ -f ~/.bashrc ]; then
source ~/.git-prompt.sh
source ~/.bashrc
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 " (%s)")\$ '
fi
# Thefuck to have 'fuck' alias to correct last command
eval $(thefuck --alias fuck)
# To enable conda auto-completion
eval "$(register-python-argcomplete conda)"
# Set browser
BROWSER=$(which firefox)
# Autocompletion
bind 'set show-all-if-ambiguous on'
#bind 'TAB:menu-complete'
bind 'set colored-completion-prefix on'
# Add paths
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/bin" ] ; then
PATH="$HOME/bin:$PATH"
fi
# set PATH so it includes user's private bin if it exists
if [ -d "$HOME/.local/bin" ] ; then
PATH="$HOME/.local/bin:$PATH"
fi
if [ -d "$HOME/.emacs.d/bin" ] ; then
PATH="$HOME/.emacs.d/bin:$PATH"
fi
if [ -d "/usr/local/go" ]; then
PATH="$PATH:/usr/local/go/bin"
fi
if [ -d "$HOME/.cargo" ]; then
. "$HOME/.cargo/env"
fi
if [ -e /home/polarolouis/.nix-profile/etc/profile.d/nix.sh ]; then
. /home/polarolouis/.nix-profile/etc/profile.d/nix.sh;
export XDG_DATA_DIRS=$HOME/.nix-profile/share:$HOME/.share:"${XDG_DATA_DIRS:-/usr/local/share/:/usr/share/}"
fi # added by Nix installer

View file

@ -126,8 +126,17 @@ else
. "/home/polarolouis/miniconda3/etc/profile.d/conda.sh" . "/home/polarolouis/miniconda3/etc/profile.d/conda.sh"
else else
export PATH="/home/polarolouis/miniconda3/bin:$PATH" export PATH="/home/polarolouis/miniconda3/bin:$PATH"
. "$HOME/.bash_profile"
fi fi
fi fi
unset __conda_setup unset __conda_setup
# <<< conda initialize <<< # <<< conda initialize <<<
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
# Fix to emacs not starting in Conda environment
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libc_malloc_debug.so
. "$HOME/.cargo/env"

16
.config/fish/config.fish Normal file
View file

@ -0,0 +1,16 @@
if status is-interactive
# Commands to run in interactive sessions can go here
end
# Color fix
set -x fish_color_user --bold green
# For informative git prompt
set -x __fish_git_prompt_show_informative_status 1
set -x __fish_git_prompt_showuntrackedfiles 1
set -x __fish_git_prompt_color_untrackedfiles --bold red
set -x __fish_git_prompt_showdirtystate 1
set -x __fish_git_prompt_showcolorhints 1
# Aliases
abbr --add dotfiles git --git-dir=$HOME/.dotfiles --work-tree=$HOME

461
.emacs.d/init.el Normal file
View file

@ -0,0 +1,461 @@
;; I fixed custom variables here
(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.
'(custom-safe-themes
'("a27c00821ccfd5a78b01e4f35dc056706dd9ede09a8b90c6955ae6a390eb1c1e" default)))
;; Machine-dependent configuration - adapt as required for your computer!
;; There are two kinds of settings that might have to be adapted to the
;; specific environment of a computer:
;; 1. Telling Emacs which executables to use for Python and R
;; 2. Telling Emacs to use a Web proxy
;;
;; 1. Telling Emacs which executables to use for Python and R
;;
;; Default setting: Use "python3" under Linux and macOS, but "Python" under Windows.
;; The default for R is "R" for all platforms (predefined by Emacs).
(setq org-babel-python-command
(if (memq system-type '(windows-nt ms-dos))
"Python"
"python3 -q"))
;; If the Python and R executables are on your system's search path,
;; you should not have to modify anything here. If Emacs does not find
;; Python or R, or if it uses a different version of Python or R than you
;; expect, you can uncomment these two lines (one for Python, one for R)
;; and modify them to point to the executables.
;; Python
;; Be careful if the path to your Python installation contains spaces. The path
;; must then be surrounded by backslash-escaped quotation marks, as in
;; (setq org-babel-python-command "\"C:/Program Files/Python/Python37/python.exe\"")
;; R
;; (setq inferior-R-program-name "C:/Program Files/R/R-3.5.1/bin/x64/Rterm.exe")
;;
;; 2. Telling Emacs to use a Web proxy
;;
;; If your local network imposes the use of a Web proxy, you must uncomment and adapt
;; the following lines. Emacs does NOT use system-wide proxy settings. In most
;; cases, only the first two lines (proxy-name and proxy-port) need to be changed,
;; but sometimes the fifth line (no_proxy) also requires modifications. If you are
;; unsure what the right settings are, ask your local network administrator for help.
;; (let* ((proxy-name "proxy.mynetwork.org")
;; (proxy-port "8080")
;; (proxy-name-port (concat proxy-name ":" proxy-port))
;; (proxy-url (concat "http://" proxy-name-port "/")))
;; (setq url-proxy-services (list (cons "no_proxy" "127.0.0.1")
;; (cons "http" proxy-name-port)
;; (cons "https" proxy-name-port)))
;; (setenv "http_proxy" proxy-url)
;; (setenv "https_proxy" proxy-url)
;; (setenv "JVM_OPTS" (concat "-Dhttp.proxyHost=" proxy-name
;; " -Dhttp.proxyPort=" proxy-port)))
(package-initialize)
(add-to-list 'package-archives
'("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(setq package-archive-priorities '(("melpa-stable" . 100)
("melpa" . 50)
("gnu" . 10)))
;(require 'cl)
(let* ((required-packages
'(dash
htmlize
ess
auctex
magit))
(missing-packages (cl-remove-if #'package-installed-p required-packages)))
(when missing-packages
(message "Missing packages: %s" missing-packages)
(package-refresh-contents)
(dolist (pkg missing-packages)
(package-install pkg)
(message "Package %s has been installed" pkg))))
(require 'org)
(require 'ess-site)
(setq inhibit-splash-screen t)
(setq frame-title-format
'("Emacs - " (buffer-file-name "%f"
(dired-directory dired-directory "%b"))))
(global-font-lock-mode t)
(custom-set-faces
'(flyspell-incorrect ((t (:inverse-video t)))))
(line-number-mode 1)
(column-number-mode 1)
(load-library "paren")
(show-paren-mode 1)
(transient-mark-mode t)
(require 'paren)
(defalias 'yes-or-no-p 'y-or-n-p)
(add-hook 'org-mode-hook 'display-line-numbers-mode)
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
(setq
ns-command-modifier 'meta ; Apple/Command key is Meta
ns-alternate-modifier nil ; Option is the Mac Option key
ns-use-mac-modifier-symbols nil ; display standard Emacs (and not standard Mac) modifier symbols
)
;; (cua-mode t) to activate
(global-set-key "\M-g" 'goto-line)
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
;; C-x C-0 restores the default font size
;; Inspired from http://tex.stackexchange.com/questions/166681/changing-language-of-flyspell-emacs-with-a-shortcut
;; (defun spell (choice)
;; "Switch between language dictionaries."
;; (interactive "cChoose: (a) American | (f) Francais")
;; (cond ((eq choice ?1)
;; (setq flyspell-default-dictionary "american")
;; (setq ispell-dictionary "american")
;; (ispell-kill-ispell))
;; ((eq choice ?2)
;; (setq flyspell-default-dictionary "francais")
;; (setq ispell-dictionary "francais")
;; (ispell-kill-ispell))
;; (t (message "No changes have been made."))) )
(define-key global-map (kbd "C-c s a") (lambda () (interactive) (ispell-change-dictionary "american")))
(define-key global-map (kbd "C-c s f") (lambda () (interactive) (ispell-change-dictionary "francais")))
(define-key global-map (kbd "C-c s r") 'flyspell-region)
(define-key global-map (kbd "C-c s b") 'flyspell-buffer)
(define-key global-map (kbd "C-c s s") 'flyspell-mode)
(global-set-key [f5] '(lambda () (interactive) (revert-buffer nil t nil)))
(global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "C-x M-g") 'magit-dispatch-popup)
;; (global-magit-file-mode 1)
(defun auto-fill-mode-on () (TeX-PDF-mode 1))
(add-hook 'tex-mode-hook 'TeX-PDF-mode-on)
(add-hook 'latex-mode-hook 'TeX-PDF-mode-on)
(setq TeX-PDF-mode t)
(defun auto-fill-mode-on () (auto-fill-mode 1))
(add-hook 'text-mode-hook 'auto-fill-mode-on)
(add-hook 'emacs-lisp-mode 'auto-fill-mode-on)
(add-hook 'tex-mode-hook 'auto-fill-mode-on)
(add-hook 'latex-mode-hook 'auto-fill-mode-on)
(setq org-directory "~/org/")
(setq org-hide-leading-stars t)
(setq org-alphabetical-lists t)
(setq org-src-fontify-natively t) ;; you want this to activate coloring in blocks
(setq org-src-tab-acts-natively t) ;; you want this to have completion in blocks
(setq org-hide-emphasis-markers t) ;; to hide the *,=, or / markers
(setq org-pretty-entities t) ;; to have \alpha, \to and others display as utf8 http://orgmode.org/manual/Special-symbols.html
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture)
(global-set-key (kbd "C-c a") 'org-agenda)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map (kbd "C-c a") 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(setq org-default-notes-file "~/org/notes.org")
(define-key global-map "\C-cd" 'org-capture)
(setq org-capture-templates (quote (("t" "Todo" entry (file+headline "~/org/liste.org" "Tasks") "* TODO %?
%i
%a" :prepend t) ("j" "Journal" entry (file+datetree "~/org/journal.org") "* %?
Entered on %U
%i
%a"))))
(setq org-agenda-include-all-todo t)
(setq org-agenda-include-diary t)
;; Adding the ~/org directory to the list of directories to scan
(setq org-agenda-files '("~/org"))
(global-set-key (kbd "C-c d") 'insert-date)
(defun insert-date (prefix)
"Insert the current date. With prefix-argument, use ISO format. With
two prefix arguments, write out the day and month name."
(interactive "P")
(let ((format (cond
((not prefix) "** %Y-%m-%d")
((equal prefix '(4)) "[%Y-%m-%d]"))))
(insert (format-time-string format))))
(global-set-key (kbd "C-c t") 'insert-time-date)
(defun insert-time-date (prefix)
"Insert the current date. With prefix-argument, use ISO format. With
two prefix arguments, write out the day and month name."
(interactive "P")
(let ((format (cond
((not prefix) "[%H:%M:%S; %d.%m.%Y]")
((equal prefix '(4)) "[%H:%M:%S; %Y-%m-%d]"))))
(insert (format-time-string format))))
(global-set-key (kbd "C-c l") 'org-store-link)
(global-set-key (kbd "C-c <up>") 'outline-up-heading)
(global-set-key (kbd "C-c <left>") 'outline-previous-visible-heading)
(global-set-key (kbd "C-c <right>") 'outline-next-visible-heading)
(defun org-toggle-emphasis ()
"Toggle hiding/showing of org emphasize markers."
(interactive)
(if org-hide-emphasis-markers
(set-variable 'org-hide-emphasis-markers nil)
(set-variable 'org-hide-emphasis-markers t))
(org-mode-restart))
(define-key org-mode-map (kbd "C-c e") 'org-toggle-emphasis)
;; In org-mode 9 you need to have #+PROPERTY: header-args :eval never-export
;; in the beginning or your document to tell org-mode not to evaluate every
;; code block every time you export.
(setq org-confirm-babel-evaluate nil) ;; Do not ask for confirmation all the time!!
(org-babel-do-load-languages
'org-babel-load-languages
'(
(emacs-lisp . t)
(shell . t)
(python . t)
(R . t)
(ruby . t)
(ocaml . t)
(ditaa . t)
(dot . t)
(octave . t)
(sqlite . t)
(perl . t)
(screen . t)
(plantuml . t)
(lilypond . t)
(org . t)
(makefile . t)
))
(setq org-src-preserve-indentation t)
(setq rrmooc/new-org-templates (version<= "9.2" (org-version)))
(when rrmooc/new-org-templates
(require 'org-tempo))
(require 'subr-x)
(defun rrmooc/add-org-template (old-style-template)
(add-to-list 'org-structure-template-alist
(if rrmooc/new-org-templates
(cons
(cl-first old-style-template)
(string-trim-right (substring (cl-second old-style-template) 8 -9)))
old-style-template)))
(unless rrmooc/new-org-templates
;; this template is predefined in the new templating system
(rrmooc/add-org-template
'("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>")))
(rrmooc/add-org-template
'("m" "#+begin_src emacs-lisp\n\n#+end_src" "<src lang=\"emacs-lisp\">\n\n</src>"))
(rrmooc/add-org-template
'("r" "#+begin_src R :results output :session *R* :exports both\n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
(rrmooc/add-org-template
'("R" "#+begin_src R :results output graphics :file (org-babel-temp-file \"figure\" \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
(rrmooc/add-org-template
'("RR" "#+begin_src R :results output graphics :file (org-babel-temp-file (concat (file-name-directory (or load-file-name buffer-file-name)) \"figure-\") \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
(rrmooc/add-org-template
'("p" "#+begin_src python :results output :exports both\n\n#+end_src" "<src lang=\"python\">\n\n</src>"))
(rrmooc/add-org-template
'("P" "#+begin_src python :results output :session :exports both\n\n#+end_src" "<src lang=\"python\">\n\n</src>"))
(rrmooc/add-org-template
'("PP" "#+begin_src python :results file :session :var matplot_lib_filename=(org-babel-temp-file \"figure\" \".png\") :exports both\nimport matplotlib.pyplot as plt\n\nimport numpy\nx=numpy.linspace(-15,15)\nplt.figure(figsize=(10,5))\nplt.plot(x,numpy.cos(x)/x)\nplt.tight_layout()\n\nplt.savefig(matplot_lib_filename)\nmatplot_lib_filename\n#+end_src" "<src lang=\"python\">\n\n</src>"))
(if (memq system-type '(windows-nt ms-dos))
;; Non-session shell execution does not seem to work under Windows, so we use
;; a named session just like for B.
(rrmooc/add-org-template
'("b" "#+begin_src shell :session session :results output :exports both\n\n#+end_src" "<src lang=\"sh\">\n\n</src>"))
(rrmooc/add-org-template
'("b" "#+begin_src shell :results output :exports both\n\n#+end_src" "<src lang=\"sh\">\n\n</src>")))
(rrmooc/add-org-template
'("B" "#+begin_src shell :session *shell* :results output :exports both \n\n#+end_src" "<src lang=\"sh\">\n\n</src>"))
(rrmooc/add-org-template
'("g" "#+begin_src dot :results output graphics :file \"/tmp/graph.pdf\" :exports both
digraph G {
node [color=black,fillcolor=white,shape=rectangle,style=filled,fontname=\"Helvetica\"];
A[label=\"A\"]
B[label=\"B\"]
A->B
}\n#+end_src" "<src lang=\"dot\">\n\n</src>"))
(global-set-key (kbd "C-c S-t") 'org-babel-execute-subtree)
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-babel-result-hide-all)
(setq python-shell-completion-native-enable nil)
;;; Beginning of my customisations
(let* ((wanted-packages
'(flycheck ; grammar
flycheck-grammalecte ; grammar
company ; auto-complete
org-appear ; org emphasis appear
org-fragtog ; see latex fragment in org
org-bullets ; Nicer bullets
use-package
eglot ; LSP client
counsel ; ivy autocomplete for M-x
eldoc-box ; adding popup for eldoc
powerline ; A cool powerline
rainbow-delimiters ; To color parenthesis, brackets
focus ; A package to dim surrounding text to focus on the current text
aggressive-indent ; A package to force indentation and tidy code
))
(missing-wanted-packages (cl-remove-if #'package-installed-p wanted-packages)))
(when missing-wanted-packages
(message "Missing wanted packages: %s" missing-wanted-packages)
(package-refresh-contents)
(dolist (pkg missing-wanted-packages)
(package-install pkg)
(message "Wanted package %s has been installed" pkg))))
(use-package smart-mode-line
:ensure t
:init
(setq sml/theme 'automatic) ; To prevent the popup for loading custom theme
:config
(sml/setup))
;; Below we modify Org Mode behavior
;; When loading org-mode turns off auto-fill-mode
(add-hook 'org-mode-hook 'turn-off-auto-fill)
;; Emphasis markers now appear when hovering
(add-hook 'org-mode-hook 'org-appear-mode)
;; Nicer org bullets
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
;; Auto-toggle LaTeX fragments
(add-hook 'org-mode-hook 'org-fragtog-mode)
(global-linum-mode 1)
(global-visual-line-mode 1) ; 1 for on & 0 for off
(global-company-mode)
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
;;; LSP features
;; Enables LSP for the provided languages
(require 'use-package)
(use-package eglot
:defer t
:commands (eglot eglot-ensure)
:hook
((ess-mode . eglot-ensure)
(python-mode . eglot-ensure))
:config
;(setq eglot-stay-out-of '(company))
(add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd-10")
)
)
;; Forcing the ESS mode to work
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(ess-mode . ("R" "--slave" "-e" "languageserver::run()"))))
;; Activating eldoc-box to have a popup with the doc
(require 'eldoc-box)
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)
;; Workaround to disable the popup when we open the buffer
(defun quit-eldoc-box-frame-before-doc-buffer (orig-fun &rest _arg)
(eldoc-box-quit-frame)
(funcall orig-fun t))
(advice-add 'eldoc-doc-buffer
:around 'quit-eldoc-box-frame-before-doc-buffer)
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
(global-aggressive-indent-mode 1)
(add-to-list 'aggressive-indent-excluded-modes 'html-mode)
(use-package numpydoc
:ensure t
:bind (:map python-mode-map
("C-c C-n" . numpydoc-generate)))
(use-package projectile
:ensure t
:config
(projectile-mode +1)
;(setq projectile-switch-project-action #'magit-status)
;(setq projectile-switch-project-action #'treemacs)
;; Recommended keymap prefix on Windows/Linux
:bind (:map projectile-mode-map
("C-c p" . projectile-command-map)))
;; The YASnippet package
(use-package yasnippet
:ensure t
:config
(yas-global-mode 1))
;; The snippets for YASnippet
(use-package yasnippet-snippets
:ensure t)
;; Perspective
(use-package perspective
:ensure t
:bind
("C-x C-b" . persp-list-buffers) ; or use a nicer switcher, see below
:custom
(persp-mode-prefix-key (kbd "C-c M-p")) ; pick your own prefix key here
:init
(persp-mode))
(use-package solo-jazz-theme
:ensure t
:config
(load-theme 'solo-jazz t nil)) ;; t nil supposed to enable NO-CONFIRM disable NO-ENABLE

848
.emacs.d/init.org Normal file
View file

@ -0,0 +1,848 @@
# -*- mode: org -*-
#+TITLE: Emacs init file written in org-mode
#+AUTHOR: Arnaud Legrand, Konrad Hinsen
#+STARTUP: indent
#+LANGUAGE: en
This is a "minimal" =.emacs= configuration file. For this configuration
to work, you'll need one of:
- Emacs 26 (preferred)
- Emacs 25 plus Org-Mode 9
* Installation Instructions
Backup you own =.emacs= if you have one and replace it with [[file:init.el][the content
of this file]]. If you ever want to regenerate if from this org
document, simply =M-x org-babel-tangle=.
* Machine-dependent configuration
#+begin_src emacs-lisp :tangle init.el
;; I fixed custom variables here
(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.
'(custom-safe-themes
'("a27c00821ccfd5a78b01e4f35dc056706dd9ede09a8b90c6955ae6a390eb1c1e" default)))
;; Machine-dependent configuration - adapt as required for your computer!
;; There are two kinds of settings that might have to be adapted to the
;; specific environment of a computer:
;; 1. Telling Emacs which executables to use for Python and R
;; 2. Telling Emacs to use a Web proxy
;;
;; 1. Telling Emacs which executables to use for Python and R
;;
;; Default setting: Use "python3" under Linux and macOS, but "Python" under Windows.
;; The default for R is "R" for all platforms (predefined by Emacs).
(setq org-babel-python-command
(if (memq system-type '(windows-nt ms-dos))
"Python"
"python3 -q"))
;; If the Python and R executables are on your system's search path,
;; you should not have to modify anything here. If Emacs does not find
;; Python or R, or if it uses a different version of Python or R than you
;; expect, you can uncomment these two lines (one for Python, one for R)
;; and modify them to point to the executables.
;; Python
;; Be careful if the path to your Python installation contains spaces. The path
;; must then be surrounded by backslash-escaped quotation marks, as in
;; (setq org-babel-python-command "\"C:/Program Files/Python/Python37/python.exe\"")
;; R
;; (setq inferior-R-program-name "C:/Program Files/R/R-3.5.1/bin/x64/Rterm.exe")
;;
;; 2. Telling Emacs to use a Web proxy
;;
;; If your local network imposes the use of a Web proxy, you must uncomment and adapt
;; the following lines. Emacs does NOT use system-wide proxy settings. In most
;; cases, only the first two lines (proxy-name and proxy-port) need to be changed,
;; but sometimes the fifth line (no_proxy) also requires modifications. If you are
;; unsure what the right settings are, ask your local network administrator for help.
;; (let* ((proxy-name "proxy.mynetwork.org")
;; (proxy-port "8080")
;; (proxy-name-port (concat proxy-name ":" proxy-port))
;; (proxy-url (concat "http://" proxy-name-port "/")))
;; (setq url-proxy-services (list (cons "no_proxy" "127.0.0.1")
;; (cons "http" proxy-name-port)
;; (cons "https" proxy-name-port)))
;; (setenv "http_proxy" proxy-url)
;; (setenv "https_proxy" proxy-url)
;; (setenv "JVM_OPTS" (concat "-Dhttp.proxyHost=" proxy-name
;; " -Dhttp.proxyPort=" proxy-port)))
#+end_src
* Package sources
** Use melpa-stable (preferred) and melpa in addition to the default GNU archive
#+BEGIN_SRC emacs-lisp :tangle init.el
(package-initialize)
(add-to-list 'package-archives
'("gnu" . "https://elpa.gnu.org/packages/"))
(add-to-list 'package-archives
'("melpa-stable" . "https://stable.melpa.org/packages/"))
(add-to-list 'package-archives
'("melpa" . "https://melpa.org/packages/"))
(setq package-archive-priorities '(("melpa-stable" . 100)
("melpa" . 50)
("gnu" . 10)))
#+END_SRC
* Install packages
#+begin_src emacs-lisp :tangle init.el
;(require 'cl)
(let* ((required-packages
'(dash
htmlize
ess
auctex
magit))
(missing-packages (cl-remove-if #'package-installed-p required-packages)))
(when missing-packages
(message "Missing packages: %s" missing-packages)
(package-refresh-contents)
(dolist (pkg missing-packages)
(package-install pkg)
(message "Package %s has been installed" pkg))))
#+end_src
* Loading files:
** Loading babel: :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(require 'org)
#+end_src
** Loading ESS (Emacs support for R)
This seems to be needed on some platforms.
#+begin_src emacs-lisp :tangle init.el
(require 'ess-site)
#+end_src
* Emacs aesthetics:
** Remove splash screen: :WEB:
#+begin_src emacs-lisp :tangle init.el
(setq inhibit-splash-screen t)
#+end_src
** Change frame name of emacs: :LUKA:WEB:
#+begin_src emacs-lisp :tangle init.el
(setq frame-title-format
'("Emacs - " (buffer-file-name "%f"
(dired-directory dired-directory "%b"))))
#+end_src
** Text coloring :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(global-font-lock-mode t)
(custom-set-faces
'(flyspell-incorrect ((t (:inverse-video t)))))
#+end_src
** Line and column numbering :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(line-number-mode 1)
(column-number-mode 1)
#+end_src
** Parenthesis :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(load-library "paren")
(show-paren-mode 1)
(transient-mark-mode t)
(require 'paren)
#+end_src
** Asking for confirmation concisely: :WEB:
Link: http://org.ryuslash.org/dotfiles/emacs/init.html#sec-7-1 Being
asked to type in yes explicitly all the time gets very tedious. I
understand that it is safer since y is much easier to type in
accidentally than yes and so the potential to say yes to things you
don't want is there, but I haven't had any such problems yet.
#+begin_src emacs-lisp :tangle init.el
(defalias 'yes-or-no-p 'y-or-n-p)
#+end_src
** Add the line numbers on the left :LOUIS:
Add the number lines on the left side when Org mode is active
#+begin_src emacs-lisp :tangle init.el
(add-hook 'org-mode-hook 'display-line-numbers-mode)
#+end_src
* Shortcuts:
** UTF 8 by default :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(set-terminal-coding-system 'utf-8)
(set-keyboard-coding-system 'utf-8)
(prefer-coding-system 'utf-8)
#+end_src
** Keyboard fix for Mac OS X users... :ADRIEN:
Thanks to Adrien Lebre for providing me with this
=ns-use-mac-modifier-symbols= thing. Unfortunately, this is broken at
the moment (I tried to wrap the command around the cond but it should
fail on mac).
#+begin_src emacs-lisp :tangle init.el
(setq
ns-command-modifier 'meta ; Apple/Command key is Meta
ns-alternate-modifier nil ; Option is the Mac Option key
ns-use-mac-modifier-symbols nil ; display standard Emacs (and not standard Mac) modifier symbols
)
#+end_src
** CUA mode a.k.a =C-x, C-c, C-v=
Yuck! Many people like this but I hate it as it conflicts with some of
my other shortcuts (e.g., the ones for spelling a region).
#+begin_src emacs-lisp :tangle init.el
;; (cua-mode t) to activate
#+end_src
** Navigate back in text :ARNAUD:noexport:
#+begin_src emacs-lisp
(defun jump-mark ()
(interactive)
(set-mark-command (point)))
(defun beginning-of-defun-and-mark ()
(interactive)
(push-mark (point))
(beginning-of-defun))
(defun end-of-defun-and-mark ()
(interactive)
(push-mark (point))
(end-of-defun))
(global-set-key "\^c\^b" 'beginning-of-defun-and-mark)
(global-set-key "\^c\^e" 'end-of-defun-and-mark)
(global-set-key "\^c\^j" 'jump-mark)
(global-set-key [S-f6] 'jump-mark) ;; jump from mark to mark
#+end_src
** Goto line :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(global-set-key "\M-g" 'goto-line)
#+end_src
** Increase/decrease text size in emacs :WEB:
#+begin_src emacs-lisp :tangle init.el
(global-set-key (kbd "C-+") 'text-scale-increase)
(global-set-key (kbd "C--") 'text-scale-decrease)
;; C-x C-0 restores the default font size
#+end_src
[11:26:47; 18.04.2014]
** Add spell checker to the file :WEB:
#+begin_src emacs-lisp :tangle init.el
;; Inspired from http://tex.stackexchange.com/questions/166681/changing-language-of-flyspell-emacs-with-a-shortcut
;; (defun spell (choice)
;; "Switch between language dictionaries."
;; (interactive "cChoose: (a) American | (f) Francais")
;; (cond ((eq choice ?1)
;; (setq flyspell-default-dictionary "american")
;; (setq ispell-dictionary "american")
;; (ispell-kill-ispell))
;; ((eq choice ?2)
;; (setq flyspell-default-dictionary "francais")
;; (setq ispell-dictionary "francais")
;; (ispell-kill-ispell))
;; (t (message "No changes have been made."))) )
(define-key global-map (kbd "C-c s a") (lambda () (interactive) (ispell-change-dictionary "american")))
(define-key global-map (kbd "C-c s f") (lambda () (interactive) (ispell-change-dictionary "francais")))
(define-key global-map (kbd "C-c s r") 'flyspell-region)
(define-key global-map (kbd "C-c s b") 'flyspell-buffer)
(define-key global-map (kbd "C-c s s") 'flyspell-mode)
#+end_src
** Reload buffer :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(global-set-key [f5] '(lambda () (interactive) (revert-buffer nil t nil)))
#+end_src
** Invoke magit (for git) :WEB:
From http://magit.vc/manual/magit.pdf
#+begin_src emacs-lisp :tangle init.el
(global-set-key (kbd "C-x g") 'magit-status)
(global-set-key (kbd "C-x M-g") 'magit-dispatch-popup)
;; (global-magit-file-mode 1)
#+end_src
* Small fixes for LaTeX:
** PDF with LaTeX by default :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(defun auto-fill-mode-on () (TeX-PDF-mode 1))
(add-hook 'tex-mode-hook 'TeX-PDF-mode-on)
(add-hook 'latex-mode-hook 'TeX-PDF-mode-on)
(setq TeX-PDF-mode t)
#+end_src
** Auto-fill-mode
#+begin_src emacs-lisp :tangle init.el
(defun auto-fill-mode-on () (auto-fill-mode 1))
(add-hook 'text-mode-hook 'auto-fill-mode-on)
(add-hook 'emacs-lisp-mode 'auto-fill-mode-on)
(add-hook 'tex-mode-hook 'auto-fill-mode-on)
(add-hook 'latex-mode-hook 'auto-fill-mode-on)
#+end_src
* Org-mode convenient configuration
** Default directory
#+begin_src emacs-lisp :tangle init.el
(setq org-directory "~/org/")
#+end_src
** Cosmetics
#+begin_src emacs-lisp :tangle init.el
(setq org-hide-leading-stars t)
(setq org-alphabetical-lists t)
(setq org-src-fontify-natively t) ;; you want this to activate coloring in blocks
(setq org-src-tab-acts-natively t) ;; you want this to have completion in blocks
(setq org-hide-emphasis-markers t) ;; to hide the *,=, or / markers
(setq org-pretty-entities t) ;; to have \alpha, \to and others display as utf8 http://orgmode.org/manual/Special-symbols.html
#+end_src
** Agenda
*** Add short cut keys for the org-agenda :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(global-set-key "\C-cl" 'org-store-link)
(global-set-key "\C-cc" 'org-capture)
(global-set-key (kbd "C-c a") 'org-agenda)
(define-key global-map "\C-cl" 'org-store-link)
(define-key global-map (kbd "C-c a") 'org-agenda)
(global-set-key "\C-cb" 'org-iswitchb)
(setq org-default-notes-file "~/org/notes.org")
(define-key global-map "\C-cd" 'org-capture)
(setq org-capture-templates (quote (("t" "Todo" entry (file+headline "~/org/liste.org" "Tasks") "* TODO %?
%i
%a" :prepend t) ("j" "Journal" entry (file+datetree "~/org/journal.org") "* %?
Entered on %U
%i
%a"))))
#+end_src
#+RESULTS:
| t | Todo | entry | (file+headline ~/org/liste.org Tasks) | * TODO %?\n %i\n %a | :prepend | t |
| j | Journal | entry | (file+datetree ~/org/journal.org) | * %?\nEntered on %U\n %i\n %a | | |
*** Agenda config :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(setq org-agenda-include-all-todo t)
(setq org-agenda-include-diary t)
;; Adding the ~/org directory to the list of directories to scan
(setq org-agenda-files '("~/org"))
#+end_src
* Org-mode shortcuts
** Adding date with brackets with command "C-c d": :LUKA:
#+begin_src emacs-lisp :tangle init.el
(global-set-key (kbd "C-c d") 'insert-date)
(defun insert-date (prefix)
"Insert the current date. With prefix-argument, use ISO format. With
two prefix arguments, write out the day and month name."
(interactive "P")
(let ((format (cond
((not prefix) "** %Y-%m-%d")
((equal prefix '(4)) "[%Y-%m-%d]"))))
(insert (format-time-string format))))
#+end_src
[16:34:01; 24.04.2013]
** Adding date with command "C-c t": :LUKA:
#+begin_src emacs-lisp :tangle init.el
(global-set-key (kbd "C-c t") 'insert-time-date)
(defun insert-time-date (prefix)
"Insert the current date. With prefix-argument, use ISO format. With
two prefix arguments, write out the day and month name."
(interactive "P")
(let ((format (cond
((not prefix) "[%H:%M:%S; %d.%m.%Y]")
((equal prefix '(4)) "[%H:%M:%S; %Y-%m-%d]"))))
(insert (format-time-string format))))
#+end_src
[16:34:15; 24.04.2013]
** Org-store-link: :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(global-set-key (kbd "C-c l") 'org-store-link)
#+end_src
** Navigating through org-mode:
Additional shortcuts for navigating through org-mode documents:
#+begin_src emacs-lisp :tangle init.el
(global-set-key (kbd "C-c <up>") 'outline-up-heading)
(global-set-key (kbd "C-c <left>") 'outline-previous-visible-heading)
(global-set-key (kbd "C-c <right>") 'outline-next-visible-heading)
#+end_src
** Toggling the visibility of emphasis markers :LOUIS:
Sourced from [[https://stackoverflow.com/questions/10969617/hiding-markup-elements-in-org-mode]["Hiding markup Elements" on StackOverflow]]
#+begin_src emacs-lisp :tangle init.el
(defun org-toggle-emphasis ()
"Toggle hiding/showing of org emphasize markers."
(interactive)
(if org-hide-emphasis-markers
(set-variable 'org-hide-emphasis-markers nil)
(set-variable 'org-hide-emphasis-markers t))
(org-mode-restart))
(define-key org-mode-map (kbd "C-c e") 'org-toggle-emphasis)
#+end_src
* Org-mode + babel:
** Seamless use of babel (no confirmation, lazy export) :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
;; In org-mode 9 you need to have #+PROPERTY: header-args :eval never-export
;; in the beginning or your document to tell org-mode not to evaluate every
;; code block every time you export.
(setq org-confirm-babel-evaluate nil) ;; Do not ask for confirmation all the time!!
#+end_src
** Some initial languages we want org-babel to support: :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(org-babel-do-load-languages
'org-babel-load-languages
'(
(emacs-lisp . t)
(shell . t)
(python . t)
(R . t)
(ruby . t)
(ocaml . t)
(ditaa . t)
(dot . t)
(octave . t)
(sqlite . t)
(perl . t)
(screen . t)
(plantuml . t)
(lilypond . t)
(org . t)
(makefile . t)
))
(setq org-src-preserve-indentation t)
#+end_src
** Adding source code blocks: :LUKA:
*** Enable the old template system with Orgmode 9.2 and later
#+begin_src emacs-lisp :tangle init.el
(setq rrmooc/new-org-templates (version<= "9.2" (org-version)))
(when rrmooc/new-org-templates
(require 'org-tempo))
#+end_src
*** Template definitions that work with the old and new templating systems
#+begin_src emacs-lisp :tangle init.el
(require 'subr-x)
(defun rrmooc/add-org-template (old-style-template)
(add-to-list 'org-structure-template-alist
(if rrmooc/new-org-templates
(cons
(cl-first old-style-template)
(string-trim-right (substring (cl-second old-style-template) 8 -9)))
old-style-template)))
#+end_src
*** With capital letters:
To use this type <s and then TAB
#+begin_src emacs-lisp :tangle init.el
(unless rrmooc/new-org-templates
;; this template is predefined in the new templating system
(rrmooc/add-org-template
'("s" "#+begin_src ?\n\n#+end_src" "<src lang=\"?\">\n\n</src>")))
#+end_src
*** Emacs-elisp code:
To use this type <m and then TAB
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("m" "#+begin_src emacs-lisp\n\n#+end_src" "<src lang=\"emacs-lisp\">\n\n</src>"))
#+end_src
*** R code:
To use this type <r and then TAB. This creates an R block for textual output.
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("r" "#+begin_src R :results output :session *R* :exports both\n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
#+end_src
To use this type <R and then TAB. This creates an R block for graphics
that are stored in the =/tmp/=.
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("R" "#+begin_src R :results output graphics :file (org-babel-temp-file \"figure\" \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
#+end_src
To use this type <RR and then TAB. This creates an R block for
graphics that are stored in the directory of the current file.
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("RR" "#+begin_src R :results output graphics :file (org-babel-temp-file (concat (file-name-directory (or load-file-name buffer-file-name)) \"figure-\") \".png\") :exports both :width 600 :height 400 :session *R* \n\n#+end_src" "<src lang=\"R\">\n\n</src>"))
#+end_src
*** Python code
To use this type <p and then TAB
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("p" "#+begin_src python :results output :exports both\n\n#+end_src" "<src lang=\"python\">\n\n</src>"))
#+end_src
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("P" "#+begin_src python :results output :session :exports both\n\n#+end_src" "<src lang=\"python\">\n\n</src>"))
#+end_src
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("PP" "#+begin_src python :results file :session :var matplot_lib_filename=(org-babel-temp-file \"figure\" \".png\") :exports both\nimport matplotlib.pyplot as plt\n\nimport numpy\nx=numpy.linspace(-15,15)\nplt.figure(figsize=(10,5))\nplt.plot(x,numpy.cos(x)/x)\nplt.tight_layout()\n\nplt.savefig(matplot_lib_filename)\nmatplot_lib_filename\n#+end_src" "<src lang=\"python\">\n\n</src>"))
#+end_src
*** Bash "sh" code:
To use this type <b and then TAB
#+begin_src emacs-lisp :tangle init.el
(if (memq system-type '(windows-nt ms-dos))
;; Non-session shell execution does not seem to work under Windows, so we use
;; a named session just like for B.
(rrmooc/add-org-template
'("b" "#+begin_src shell :session session :results output :exports both\n\n#+end_src" "<src lang=\"sh\">\n\n</src>"))
(rrmooc/add-org-template
'("b" "#+begin_src shell :results output :exports both\n\n#+end_src" "<src lang=\"sh\">\n\n</src>")))
#+end_src
To use this type <B and then TAB. This comes with a session argument
(e.g., in case you want to keep ssh connexions open).
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("B" "#+begin_src shell :session *shell* :results output :exports both \n\n#+end_src" "<src lang=\"sh\">\n\n</src>"))
#+end_src
*** Graphviz
#+begin_src emacs-lisp :tangle init.el
(rrmooc/add-org-template
'("g" "#+begin_src dot :results output graphics :file \"/tmp/graph.pdf\" :exports both
digraph G {
node [color=black,fillcolor=white,shape=rectangle,style=filled,fontname=\"Helvetica\"];
A[label=\"A\"]
B[label=\"B\"]
A->B
}\n#+end_src" "<src lang=\"dot\">\n\n</src>"))
#+end_src
** Evaluating whole subtree: :LUKA:
#+begin_src emacs-lisp :tangle init.el
(global-set-key (kbd "C-c S-t") 'org-babel-execute-subtree)
#+end_src
** Display images :ARNAUD:
#+begin_src emacs-lisp :tangle init.el
(add-hook 'org-babel-after-execute-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-display-inline-images)
(add-hook 'org-mode-hook 'org-babel-result-hide-all)
#+end_src
** Optimizing Python execution
*** Don't use readline completion
This often fails, yielding an ugly warning, and isn't of any use in Org-mode anyway
#+begin_src emacs-lisp :tangle init.el
(setq python-shell-completion-native-enable nil)
#+end_src
* Custom Louis :LOUIS:
#+begin_src emacs-lisp :tangle init.el
;;; Beginning of my customisations
#+end_src
** TODO Change to use package for clarity ! Installing wanted packages
#+begin_src emacs-lisp :tangle init.el
(let* ((wanted-packages
'(flycheck ; grammar
flycheck-grammalecte ; grammar
company ; auto-complete
org-appear ; org emphasis appear
org-fragtog ; see latex fragment in org
org-bullets ; Nicer bullets
use-package
eglot ; LSP client
counsel ; ivy autocomplete for M-x
eldoc-box ; adding popup for eldoc
powerline ; A cool powerline
rainbow-delimiters ; To color parenthesis, brackets
focus ; A package to dim surrounding text to focus on the current text
aggressive-indent ; A package to force indentation and tidy code
))
(missing-wanted-packages (cl-remove-if #'package-installed-p wanted-packages)))
(when missing-wanted-packages
(message "Missing wanted packages: %s" missing-wanted-packages)
(package-refresh-contents)
(dolist (pkg missing-wanted-packages)
(package-install pkg)
(message "Wanted package %s has been installed" pkg))))
#+end_src
#+begin_src emacs-lisp
; :tangle init.el
;; Install straight.el
(defvar bootstrap-version)
(let ((bootstrap-file
(expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
(bootstrap-version 5))
(unless (file-exists-p bootstrap-file)
(with-current-buffer
(url-retrieve-synchronously
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
'silent 'inhibit-cookies)
(goto-char (point-max))
(eval-print-last-sexp)))
(load bootstrap-file nil 'nomessage))
#+end_src
** Smart mode line (Powerline)
#+begin_src emacs-lisp :tangle init.el
(use-package smart-mode-line
:ensure t
:init
(setq sml/theme 'automatic) ; To prevent the popup for loading custom theme
:config
(sml/setup))
#+end_src
** Org modifications
#+begin_src emacs-lisp :tangle init.el
;; Below we modify Org Mode behavior
#+end_src
*** Disabling auto-fill-mode when using org
This snippet disables the auto-fill-mode which wraps the line when it exceeds a certain length
#+begin_src emacs-lisp :tangle init.el
;; When loading org-mode turns off auto-fill-mode
(add-hook 'org-mode-hook 'turn-off-auto-fill)
#+end_src
*** Activating org-appear minor mode
This mode makes the emphasis markers appear when the cursor is on it
#+begin_src emacs-lisp :tangle init.el
;; Emphasis markers now appear when hovering
(add-hook 'org-mode-hook 'org-appear-mode)
#+end_src
*** Nicer Org bullets
#+begin_src emacs-lisp :tangle init.el
;; Nicer org bullets
(add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))
#+end_src
*** Auto toggle the preview of LaTeX fragments
#+begin_src emacs-lisp :tangle init.el
;; Auto-toggle LaTeX fragments
(add-hook 'org-mode-hook 'org-fragtog-mode)
#+end_src
** Visual line mode activated on startup
#+begin_src emacs-lisp :tangle init.el
(global-linum-mode 1)
(global-visual-line-mode 1) ; 1 for on & 0 for off
#+end_src
** Remote image display :disabled:
This code was taken from https://emacs.stackexchange.com/questions/42281/org-mode-is-it-possible-to-display-online-images and makes use of the =org-yt= package.
#+begin_src emacs-lisp
(require 'org-yt)
(defun org-image-link (protocol link _description)
"Interpret LINK as base64-encoded image data."
(cl-assert (string-match "\\`img" protocol) nil
"Expected protocol type starting with img")
(let ((buf (url-retrieve-synchronously (concat (substring protocol 3) ":" link))))
(cl-assert buf nil
"Download of image \"%s\" failed." link)
(with-current-buffer buf
(goto-char (point-min))
(re-search-forward "\r?\n\r?\n")
(buffer-substring-no-properties (point) (point-max)))))
(org-link-set-parameters
"imghttp"
:image-data-fun #'org-image-link)
(org-link-set-parameters
"imghttps"
:image-data-fun #'org-image-link)
#+end_src
** Global enable Company-mode :completion:
#+begin_src emacs-lisp :tangle init.el
(global-company-mode)
#+end_src
** Ivy for Emacs command completion
#+begin_src emacs-lisp :tangle init.el
(ivy-mode 1)
(setq ivy-use-virtual-buffers t)
(setq ivy-count-format "(%d/%d) ")
#+end_src
** LSP, programming and other IDE features
*** Enabling eglot and adding ess-mode lsp
Language Server Protocol (LSP) provides intellisense completion and other nice features of VS Code.
#+begin_src emacs-lisp :tangle init.el
;;; LSP features
;; Enables LSP for the provided languages
(require 'use-package)
(use-package eglot
:defer t
:commands (eglot eglot-ensure)
:hook
((ess-mode . eglot-ensure)
(python-mode . eglot-ensure))
:config
;(setq eglot-stay-out-of '(company))
(add-to-list 'eglot-server-programs '((c-mode c++-mode) "clangd-10")
)
)
;; Forcing the ESS mode to work
(with-eval-after-load 'eglot
(add-to-list 'eglot-server-programs
'(ess-mode . ("R" "--slave" "-e" "languageserver::run()"))))
#+end_src
*** Floating pop-up for eldoc
#+begin_src emacs-lisp :tangle init.el
;; Activating eldoc-box to have a popup with the doc
(require 'eldoc-box)
(add-hook 'eglot-managed-mode-hook #'eldoc-box-hover-mode t)
;; Workaround to disable the popup when we open the buffer
(defun quit-eldoc-box-frame-before-doc-buffer (orig-fun &rest _arg)
(eldoc-box-quit-frame)
(funcall orig-fun t))
(advice-add 'eldoc-doc-buffer
:around 'quit-eldoc-box-frame-before-doc-buffer)
#+end_src
*** Rainbow delimiters
#+begin_src emacs-lisp :tangle init.el
(add-hook 'prog-mode-hook 'rainbow-delimiters-mode)
#+end_src
*** Aggressive indent
#+begin_src emacs-lisp :tangle init.el
(global-aggressive-indent-mode 1)
(add-to-list 'aggressive-indent-excluded-modes 'html-mode)
#+end_src
*** NumpyDoc to generate python docstring
#+begin_src emacs-lisp :tangle init.el
(use-package numpydoc
:ensure t
:bind (:map python-mode-map
("C-c C-n" . numpydoc-generate)))
#+end_src
*** Projectile for project management
#+begin_src emacs-lisp :tangle init.el
(use-package projectile
:ensure t
:config
(projectile-mode +1)
;(setq projectile-switch-project-action #'magit-status)
;(setq projectile-switch-project-action #'treemacs)
;; Recommended keymap prefix on Windows/Linux
:bind (:map projectile-mode-map
("C-c p" . projectile-command-map)))
#+end_src
*** YASnippet to provided code snippets
#+begin_src emacs-lisp :tangle init.el
;; The YASnippet package
(use-package yasnippet
:ensure t
:config
(yas-global-mode 1))
;; The snippets for YASnippet
(use-package yasnippet-snippets
:ensure t)
#+end_src
*** Treemacs :disabled:
#+begin_src emacs-lisp
;:tangle init.el
(use-package treemacs
:ensure t
:defer t
:init
(with-eval-after-load 'winum
(define-key winum-keymap (kbd "M-0") #'treemacs-select-window))
(with-eval-after-load 'treemacs
(define-key treemacs-mode-map [mouse-1] #'treemacs-single-click-expand-action))
:config
(add-hook 'prog-mode-hook 'treemacs)
(progn
(setq treemacs-collapse-dirs (if treemacs-python-executable 3 0)
treemacs-deferred-git-apply-delay 0.5
treemacs-directory-name-transformer #'identity
treemacs-display-in-side-window t
treemacs-eldoc-display 'simple
treemacs-file-event-delay 2000
treemacs-file-extension-regex treemacs-last-period-regex-value
treemacs-file-follow-delay 0.2
treemacs-file-name-transformer #'identity
treemacs-follow-after-init t
treemacs-expand-after-init t
treemacs-find-workspace-method 'find-for-file-or-pick-first
treemacs-git-command-pipe ""
treemacs-goto-tag-strategy 'refetch-index
treemacs-header-scroll-indicators '(nil . "^^^^^^")
treemacs-hide-dot-git-directory t
treemacs-indentation 2
treemacs-indentation-string " "
treemacs-is-never-other-window nil
treemacs-max-git-entries 5000
treemacs-missing-project-action 'ask
treemacs-move-forward-on-expand nil
treemacs-no-png-images nil
treemacs-no-delete-other-windows t
treemacs-project-follow-cleanup nil
treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory)
treemacs-position 'left
treemacs-read-string-input 'from-child-frame
treemacs-recenter-distance 0.1
treemacs-recenter-after-file-follow nil
treemacs-recenter-after-tag-follow nil
treemacs-recenter-after-project-jump 'always
treemacs-recenter-after-project-expand 'on-distance
treemacs-litter-directories '("/node_modules" "/.venv" "/.cask")
treemacs-project-follow-into-home nil
treemacs-show-cursor nil
treemacs-show-hidden-files t
treemacs-silent-filewatch nil
treemacs-silent-refresh nil
treemacs-sorting 'alphabetic-asc
treemacs-select-when-already-in-treemacs 'move-back
treemacs-space-between-root-nodes t
treemacs-tag-follow-cleanup t
treemacs-tag-follow-delay 1.5
treemacs-text-scale nil
treemacs-user-mode-line-format nil
treemacs-user-header-line-format nil
treemacs-wide-toggle-width 70
treemacs-width 35
treemacs-width-increment 1
treemacs-width-is-initially-locked t
treemacs-workspace-switch-cleanup nil)
;; The default width and height of the icons is 22 pixels. If you are
;; using a Hi-DPI display, uncomment this to double the icon size.
;;(treemacs-resize-icons 44)
(treemacs-follow-mode t)
(treemacs-filewatch-mode t)
(treemacs-fringe-indicator-mode 'always)
(when treemacs-python-executable
(treemacs-git-commit-diff-mode t))
(pcase (cons (not (null (executable-find "git")))
(not (null treemacs-python-executable)))
(`(t . t)
(treemacs-git-mode 'deferred))
(`(t . _)
(treemacs-git-mode 'simple)))
(treemacs-hide-gitignored-files-mode nil))
:bind
(:map global-map
("M-0" . treemacs-select-window)
("C-x t 1" . treemacs-delete-other-windows)
("C-x t t" . treemacs)
("C-x t d" . treemacs-select-directory)
("C-x t B" . treemacs-bookmark)
("C-x t C-t" . treemacs-find-file)
("C-x t M-t" . treemacs-find-tag)))
(use-package treemacs-projectile
:after (treemacs projectile)
:ensure t)
(use-package treemacs-icons-dired
:hook (dired-mode . treemacs-icons-dired-enable-once)
:ensure t)
(use-package treemacs-magit
:after (treemacs magit)
:ensure t)
#+end_src
** Perspective to handle multiple workspaces
#+begin_src emacs-lisp :tangle init.el
;; Perspective
(use-package perspective
:ensure t
:bind
("C-x C-b" . persp-list-buffers) ; or use a nicer switcher, see below
:custom
(persp-mode-prefix-key (kbd "C-c M-p")) ; pick your own prefix key here
:init
(persp-mode))
#+end_src
* Theme
** Activation du thème
#+begin_src emacs-lisp :tangle init.el
(use-package solo-jazz-theme
:ensure t
:config
(load-theme 'solo-jazz t nil)) ;; t nil supposed to enable NO-CONFIRM disable NO-ENABLE
#+end_src

599
.git-prompt.sh Normal file
View file

@ -0,0 +1,599 @@
# bash/zsh git prompt support
#
# Copyright (C) 2006,2007 Shawn O. Pearce <spearce@spearce.org>
# Distributed under the GNU General Public License, version 2.0.
#
# This script allows you to see repository status in your prompt.
#
# To enable:
#
# 1) Copy this file to somewhere (e.g. ~/.git-prompt.sh).
# 2) Add the following line to your .bashrc/.zshrc:
# source ~/.git-prompt.sh
# 3a) Change your PS1 to call __git_ps1 as
# command-substitution:
# Bash: PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
# ZSH: setopt PROMPT_SUBST ; PS1='[%n@%m %c$(__git_ps1 " (%s)")]\$ '
# the optional argument will be used as format string.
# 3b) Alternatively, for a slightly faster prompt, __git_ps1 can
# be used for PROMPT_COMMAND in Bash or for precmd() in Zsh
# with two parameters, <pre> and <post>, which are strings
# you would put in $PS1 before and after the status string
# generated by the git-prompt machinery. e.g.
# Bash: PROMPT_COMMAND='__git_ps1 "\u@\h:\w" "\\\$ "'
# will show username, at-sign, host, colon, cwd, then
# various status string, followed by dollar and SP, as
# your prompt.
# ZSH: precmd () { __git_ps1 "%n" ":%~$ " "|%s" }
# will show username, pipe, then various status string,
# followed by colon, cwd, dollar and SP, as your prompt.
# Optionally, you can supply a third argument with a printf
# format string to finetune the output of the branch status
#
# The repository status will be displayed only if you are currently in a
# git repository. The %s token is the placeholder for the shown status.
#
# The prompt status always includes the current branch name.
#
# In addition, if you set GIT_PS1_SHOWDIRTYSTATE to a nonempty value,
# unstaged (*) and staged (+) changes will be shown next to the branch
# name. You can configure this per-repository with the
# bash.showDirtyState variable, which defaults to true once
# GIT_PS1_SHOWDIRTYSTATE is enabled.
#
# You can also see if currently something is stashed, by setting
# GIT_PS1_SHOWSTASHSTATE to a nonempty value. If something is stashed,
# then a '$' will be shown next to the branch name.
#
# If you would like to see if there're untracked files, then you can set
# GIT_PS1_SHOWUNTRACKEDFILES to a nonempty value. If there're untracked
# files, then a '%' will be shown next to the branch name. You can
# configure this per-repository with the bash.showUntrackedFiles
# variable, which defaults to true once GIT_PS1_SHOWUNTRACKEDFILES is
# enabled.
#
# If you would like to see the difference between HEAD and its upstream,
# set GIT_PS1_SHOWUPSTREAM="auto". A "<" indicates you are behind, ">"
# indicates you are ahead, "<>" indicates you have diverged and "="
# indicates that there is no difference. You can further control
# behaviour by setting GIT_PS1_SHOWUPSTREAM to a space-separated list
# of values:
#
# verbose show number of commits ahead/behind (+/-) upstream
# name if verbose, then also show the upstream abbrev name
# legacy don't use the '--count' option available in recent
# versions of git-rev-list
# git always compare HEAD to @{upstream}
# svn always compare HEAD to your SVN upstream
#
# By default, __git_ps1 will compare HEAD to your SVN upstream if it can
# find one, or @{upstream} otherwise. Once you have set
# GIT_PS1_SHOWUPSTREAM, you can override it on a per-repository basis by
# setting the bash.showUpstream config variable.
#
# You can change the separator between the branch name and the above
# state symbols by setting GIT_PS1_STATESEPARATOR. The default separator
# is SP.
#
# When there is an in-progress operation such as a merge, rebase,
# revert, cherry-pick, or bisect, the prompt will include information
# related to the operation, often in the form "|<OPERATION-NAME>".
#
# When the repository has a sparse-checkout, a notification of the form
# "|SPARSE" will be included in the prompt. This can be shortened to a
# single '?' character by setting GIT_PS1_COMPRESSSPARSESTATE, or omitted
# by setting GIT_PS1_OMITSPARSESTATE.
#
# If you would like to see a notification on the prompt when there are
# unresolved conflicts, set GIT_PS1_SHOWCONFLICTSTATE to "yes". The
# prompt will include "|CONFLICT".
#
# If you would like to see more information about the identity of
# commits checked out as a detached HEAD, set GIT_PS1_DESCRIBE_STYLE
# to one of these values:
#
# contains relative to newer annotated tag (v1.6.3.2~35)
# branch relative to newer tag or branch (master~4)
# describe relative to older annotated tag (v1.6.3.1-13-gdd42c2f)
# tag relative to any older tag (v1.6.3.1-13-gdd42c2f)
# default exactly matching tag
#
# If you would like a colored hint about the current dirty state, set
# GIT_PS1_SHOWCOLORHINTS to a nonempty value. The colors are based on
# the colored output of "git status -sb" and are available only when
# using __git_ps1 for PROMPT_COMMAND or precmd in Bash,
# but always available in Zsh.
#
# If you would like __git_ps1 to do nothing in the case when the current
# directory is set up to be ignored by git, then set
# GIT_PS1_HIDE_IF_PWD_IGNORED to a nonempty value. Override this on the
# repository level by setting bash.hideIfPwdIgnored to "false".
# check whether printf supports -v
__git_printf_supports_v=
printf -v __git_printf_supports_v -- '%s' yes >/dev/null 2>&1
# stores the divergence from upstream in $p
# used by GIT_PS1_SHOWUPSTREAM
__git_ps1_show_upstream ()
{
local key value
local svn_remote svn_url_pattern count n
local upstream_type=git legacy="" verbose="" name=""
svn_remote=()
# get some config options from git-config
local output="$(git config -z --get-regexp '^(svn-remote\..*\.url|bash\.showupstream)$' 2>/dev/null | tr '\0\n' '\n ')"
while read -r key value; do
case "$key" in
bash.showupstream)
GIT_PS1_SHOWUPSTREAM="$value"
if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
p=""
return
fi
;;
svn-remote.*.url)
svn_remote[$((${#svn_remote[@]} + 1))]="$value"
svn_url_pattern="$svn_url_pattern\\|$value"
upstream_type=svn+git # default upstream type is SVN if available, else git
;;
esac
done <<< "$output"
# parse configuration values
local option
for option in ${GIT_PS1_SHOWUPSTREAM}; do
case "$option" in
git|svn) upstream_type="$option" ;;
verbose) verbose=1 ;;
legacy) legacy=1 ;;
name) name=1 ;;
esac
done
# Find our upstream type
case "$upstream_type" in
git) upstream_type="@{upstream}" ;;
svn*)
# get the upstream from the "git-svn-id: ..." in a commit message
# (git-svn uses essentially the same procedure internally)
local -a svn_upstream
svn_upstream=($(git log --first-parent -1 \
--grep="^git-svn-id: \(${svn_url_pattern#??}\)" 2>/dev/null))
if [[ 0 -ne ${#svn_upstream[@]} ]]; then
svn_upstream=${svn_upstream[${#svn_upstream[@]} - 2]}
svn_upstream=${svn_upstream%@*}
local n_stop="${#svn_remote[@]}"
for ((n=1; n <= n_stop; n++)); do
svn_upstream=${svn_upstream#${svn_remote[$n]}}
done
if [[ -z "$svn_upstream" ]]; then
# default branch name for checkouts with no layout:
upstream_type=${GIT_SVN_ID:-git-svn}
else
upstream_type=${svn_upstream#/}
fi
elif [[ "svn+git" = "$upstream_type" ]]; then
upstream_type="@{upstream}"
fi
;;
esac
# Find how many commits we are ahead/behind our upstream
if [[ -z "$legacy" ]]; then
count="$(git rev-list --count --left-right \
"$upstream_type"...HEAD 2>/dev/null)"
else
# produce equivalent output to --count for older versions of git
local commits
if commits="$(git rev-list --left-right "$upstream_type"...HEAD 2>/dev/null)"
then
local commit behind=0 ahead=0
for commit in $commits
do
case "$commit" in
"<"*) ((behind++)) ;;
*) ((ahead++)) ;;
esac
done
count="$behind $ahead"
else
count=""
fi
fi
# calculate the result
if [[ -z "$verbose" ]]; then
case "$count" in
"") # no upstream
p="" ;;
"0 0") # equal to upstream
p="=" ;;
"0 "*) # ahead of upstream
p=">" ;;
*" 0") # behind upstream
p="<" ;;
*) # diverged from upstream
p="<>" ;;
esac
else # verbose, set upstream instead of p
case "$count" in
"") # no upstream
upstream="" ;;
"0 0") # equal to upstream
upstream="|u=" ;;
"0 "*) # ahead of upstream
upstream="|u+${count#0 }" ;;
*" 0") # behind upstream
upstream="|u-${count% 0}" ;;
*) # diverged from upstream
upstream="|u+${count#* }-${count% *}" ;;
esac
if [[ -n "$count" && -n "$name" ]]; then
__git_ps1_upstream_name=$(git rev-parse \
--abbrev-ref "$upstream_type" 2>/dev/null)
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
upstream="$upstream \${__git_ps1_upstream_name}"
else
upstream="$upstream ${__git_ps1_upstream_name}"
# not needed anymore; keep user's
# environment clean
unset __git_ps1_upstream_name
fi
fi
fi
}
# Helper function that is meant to be called from __git_ps1. It
# injects color codes into the appropriate gitstring variables used
# to build a gitstring. Colored variables are responsible for clearing
# their own color.
__git_ps1_colorize_gitstring ()
{
if [[ -n ${ZSH_VERSION-} ]]; then
local c_red='%F{red}'
local c_green='%F{green}'
local c_lblue='%F{blue}'
local c_clear='%f'
else
# Using \[ and \] around colors is necessary to prevent
# issues with command line editing/browsing/completion!
local c_red='\[\e[31m\]'
local c_green='\[\e[32m\]'
local c_lblue='\[\e[1;34m\]'
local c_clear='\[\e[0m\]'
fi
local bad_color=$c_red
local ok_color=$c_green
local flags_color="$c_lblue"
local branch_color=""
if [ $detached = no ]; then
branch_color="$ok_color"
else
branch_color="$bad_color"
fi
if [ -n "$c" ]; then
c="$branch_color$c$c_clear"
fi
b="$branch_color$b$c_clear"
if [ -n "$w" ]; then
w="$bad_color$w$c_clear"
fi
if [ -n "$i" ]; then
i="$ok_color$i$c_clear"
fi
if [ -n "$s" ]; then
s="$flags_color$s$c_clear"
fi
if [ -n "$u" ]; then
u="$bad_color$u$c_clear"
fi
}
# Helper function to read the first line of a file into a variable.
# __git_eread requires 2 arguments, the file path and the name of the
# variable, in that order.
__git_eread ()
{
test -r "$1" && IFS=$'\r\n' read "$2" <"$1"
}
# see if a cherry-pick or revert is in progress, if the user has committed a
# conflict resolution with 'git commit' in the middle of a sequence of picks or
# reverts then CHERRY_PICK_HEAD/REVERT_HEAD will not exist so we have to read
# the todo file.
__git_sequencer_status ()
{
local todo
if test -f "$g/CHERRY_PICK_HEAD"
then
r="|CHERRY-PICKING"
return 0;
elif test -f "$g/REVERT_HEAD"
then
r="|REVERTING"
return 0;
elif __git_eread "$g/sequencer/todo" todo
then
case "$todo" in
p[\ \ ]|pick[\ \ ]*)
r="|CHERRY-PICKING"
return 0
;;
revert[\ \ ]*)
r="|REVERTING"
return 0
;;
esac
fi
return 1
}
# __git_ps1 accepts 0 or 1 arguments (i.e., format string)
# when called from PS1 using command substitution
# in this mode it prints text to add to bash PS1 prompt (includes branch name)
#
# __git_ps1 requires 2 or 3 arguments when called from PROMPT_COMMAND (pc)
# in that case it _sets_ PS1. The arguments are parts of a PS1 string.
# when two arguments are given, the first is prepended and the second appended
# to the state string when assigned to PS1.
# The optional third parameter will be used as printf format string to further
# customize the output of the git-status string.
# In this mode you can request colored hints using GIT_PS1_SHOWCOLORHINTS=true
__git_ps1 ()
{
# preserve exit status
local exit=$?
local pcmode=no
local detached=no
local ps1pc_start='\u@\h:\w '
local ps1pc_end='\$ '
local printf_format=' (%s)'
case "$#" in
2|3) pcmode=yes
ps1pc_start="$1"
ps1pc_end="$2"
printf_format="${3:-$printf_format}"
# set PS1 to a plain prompt so that we can
# simply return early if the prompt should not
# be decorated
PS1="$ps1pc_start$ps1pc_end"
;;
0|1) printf_format="${1:-$printf_format}"
;;
*) return $exit
;;
esac
# ps1_expanded: This variable is set to 'yes' if the shell
# subjects the value of PS1 to parameter expansion:
#
# * bash does unless the promptvars option is disabled
# * zsh does not unless the PROMPT_SUBST option is set
# * POSIX shells always do
#
# If the shell would expand the contents of PS1 when drawing
# the prompt, a raw ref name must not be included in PS1.
# This protects the user from arbitrary code execution via
# specially crafted ref names. For example, a ref named
# 'refs/heads/$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' might cause the
# shell to execute 'sudo rm -rf /' when the prompt is drawn.
#
# Instead, the ref name should be placed in a separate global
# variable (in the __git_ps1_* namespace to avoid colliding
# with the user's environment) and that variable should be
# referenced from PS1. For example:
#
# __git_ps1_foo=$(do_something_to_get_ref_name)
# PS1="...stuff...\${__git_ps1_foo}...stuff..."
#
# If the shell does not expand the contents of PS1, the raw
# ref name must be included in PS1.
#
# The value of this variable is only relevant when in pcmode.
#
# Assume that the shell follows the POSIX specification and
# expands PS1 unless determined otherwise. (This is more
# likely to be correct if the user has a non-bash, non-zsh
# shell and safer than the alternative if the assumption is
# incorrect.)
#
local ps1_expanded=yes
[ -z "${ZSH_VERSION-}" ] || [[ -o PROMPT_SUBST ]] || ps1_expanded=no
[ -z "${BASH_VERSION-}" ] || shopt -q promptvars || ps1_expanded=no
local repo_info rev_parse_exit_code
repo_info="$(git rev-parse --git-dir --is-inside-git-dir \
--is-bare-repository --is-inside-work-tree \
--short HEAD 2>/dev/null)"
rev_parse_exit_code="$?"
if [ -z "$repo_info" ]; then
return $exit
fi
local short_sha=""
if [ "$rev_parse_exit_code" = "0" ]; then
short_sha="${repo_info##*$'\n'}"
repo_info="${repo_info%$'\n'*}"
fi
local inside_worktree="${repo_info##*$'\n'}"
repo_info="${repo_info%$'\n'*}"
local bare_repo="${repo_info##*$'\n'}"
repo_info="${repo_info%$'\n'*}"
local inside_gitdir="${repo_info##*$'\n'}"
local g="${repo_info%$'\n'*}"
if [ "true" = "$inside_worktree" ] &&
[ -n "${GIT_PS1_HIDE_IF_PWD_IGNORED-}" ] &&
[ "$(git config --bool bash.hideIfPwdIgnored)" != "false" ] &&
git check-ignore -q .
then
return $exit
fi
local sparse=""
if [ -z "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ -z "${GIT_PS1_OMITSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
sparse="|SPARSE"
fi
local r=""
local b=""
local step=""
local total=""
if [ -d "$g/rebase-merge" ]; then
__git_eread "$g/rebase-merge/head-name" b
__git_eread "$g/rebase-merge/msgnum" step
__git_eread "$g/rebase-merge/end" total
r="|REBASE"
else
if [ -d "$g/rebase-apply" ]; then
__git_eread "$g/rebase-apply/next" step
__git_eread "$g/rebase-apply/last" total
if [ -f "$g/rebase-apply/rebasing" ]; then
__git_eread "$g/rebase-apply/head-name" b
r="|REBASE"
elif [ -f "$g/rebase-apply/applying" ]; then
r="|AM"
else
r="|AM/REBASE"
fi
elif [ -f "$g/MERGE_HEAD" ]; then
r="|MERGING"
elif __git_sequencer_status; then
:
elif [ -f "$g/BISECT_LOG" ]; then
r="|BISECTING"
fi
if [ -n "$b" ]; then
:
elif [ -h "$g/HEAD" ]; then
# symlink symbolic ref
b="$(git symbolic-ref HEAD 2>/dev/null)"
else
local head=""
if ! __git_eread "$g/HEAD" head; then
return $exit
fi
# is it a symbolic ref?
b="${head#ref: }"
if [ "$head" = "$b" ]; then
detached=yes
b="$(
case "${GIT_PS1_DESCRIBE_STYLE-}" in
(contains)
git describe --contains HEAD ;;
(branch)
git describe --contains --all HEAD ;;
(tag)
git describe --tags HEAD ;;
(describe)
git describe HEAD ;;
(* | default)
git describe --tags --exact-match HEAD ;;
esac 2>/dev/null)" ||
b="$short_sha..."
b="($b)"
fi
fi
fi
if [ -n "$step" ] && [ -n "$total" ]; then
r="$r $step/$total"
fi
local conflict="" # state indicator for unresolved conflicts
if [[ "${GIT_PS1_SHOWCONFLICTSTATE}" == "yes" ]] &&
[[ $(git ls-files --unmerged 2>/dev/null) ]]; then
conflict="|CONFLICT"
fi
local w=""
local i=""
local s=""
local u=""
local h=""
local c=""
local p="" # short version of upstream state indicator
local upstream="" # verbose version of upstream state indicator
if [ "true" = "$inside_gitdir" ]; then
if [ "true" = "$bare_repo" ]; then
c="BARE:"
else
b="GIT_DIR!"
fi
elif [ "true" = "$inside_worktree" ]; then
if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ] &&
[ "$(git config --bool bash.showDirtyState)" != "false" ]
then
git diff --no-ext-diff --quiet || w="*"
git diff --no-ext-diff --cached --quiet || i="+"
if [ -z "$short_sha" ] && [ -z "$i" ]; then
i="#"
fi
fi
if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ] &&
git rev-parse --verify --quiet refs/stash >/dev/null
then
s="$"
fi
if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ] &&
[ "$(git config --bool bash.showUntrackedFiles)" != "false" ] &&
git ls-files --others --exclude-standard --directory --no-empty-directory --error-unmatch -- ':/*' >/dev/null 2>/dev/null
then
u="%${ZSH_VERSION+%}"
fi
if [ -n "${GIT_PS1_COMPRESSSPARSESTATE-}" ] &&
[ "$(git config --bool core.sparseCheckout)" = "true" ]; then
h="?"
fi
if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
__git_ps1_show_upstream
fi
fi
local z="${GIT_PS1_STATESEPARATOR-" "}"
b=${b##refs/heads/}
if [ $pcmode = yes ] && [ $ps1_expanded = yes ]; then
__git_ps1_branch_name=$b
b="\${__git_ps1_branch_name}"
fi
# NO color option unless in PROMPT_COMMAND mode or it's Zsh
if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
if [ $pcmode = yes ] || [ -n "${ZSH_VERSION-}" ]; then
__git_ps1_colorize_gitstring
fi
fi
local f="$h$w$i$s$u$p"
local gitstring="$c$b${f:+$z$f}${sparse}$r${upstream}${conflict}"
if [ $pcmode = yes ]; then
if [ "${__git_printf_supports_v-}" != yes ]; then
gitstring=$(printf -- "$printf_format" "$gitstring")
else
printf -v gitstring -- "$printf_format" "$gitstring"
fi
PS1="$ps1pc_start$gitstring$ps1pc_end"
else
printf -- "$printf_format" "$gitstring"
fi
return $exit
}

1
.radian_profile Normal file
View file

@ -0,0 +1 @@
options(radian.color_scheme = "manni")