Klimi's new dotfiles with stow.
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

219 líneas
8.9 KiB

hace 4 años
  1. #!/usr/bin/env sh
  2. ## Copyright (C) 2012 ~ 2019 Thierry Volpiatto <thierry.volpiatto@gmail.com>
  3. ##
  4. ## This program is free software; you can redistribute it and/or modify
  5. ## it under the terms of the GNU General Public License as published by
  6. ## the Free Software Foundation, either version 3 of the License, or
  7. ## (at your option) any later version.
  8. ##
  9. ## This program is distributed in the hope that it will be useful,
  10. ## but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ## GNU General Public License for more details.
  13. ##
  14. ## You should have received a copy of the GNU General Public License
  15. ## along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. ## Commentary:
  17. # Preconfigured `emacs -Q' with a basic Helm configuration.
  18. # If TEMP env var exists, use it, otherwise declare it.
  19. test -z "$TEMP" && TEMP="/tmp"
  20. CONF_FILE="$TEMP/helm-cfg.el"
  21. EMACS=emacs
  22. TOOLBARS=-1
  23. LOAD_PACKAGES=
  24. usage () {
  25. cat >&1 <<EOF
  26. Usage: ${0##*/} [-P PATH] [--toolbars] [--load-packages pkgs] [-h] [EMACS-OPTIONS-OR-FILENAME]
  27. -P --path Specify path to emacs
  28. -B --toolbars Display Menu bar, scroll bar etc...
  29. --load-packages Load specified M/Elpa packages (separate with ",")
  30. -h Display this help and exit
  31. Any other Emacs options or filename must come after.
  32. Emacs options:
  33. Initialization options:
  34. --chdir DIR change to directory DIR
  35. --daemon, --bg-daemon[=NAME] start a (named) server in the background
  36. --fg-daemon[=NAME] start a (named) server in the foreground
  37. --debug-init enable Emacs Lisp debugger for init file
  38. --display, -d DISPLAY use X server DISPLAY
  39. --no-build-details do not add build details such as time stamps
  40. --no-loadup, -nl do not load loadup.el into bare Emacs
  41. --no-site-file do not load site-start.el
  42. --no-x-resources do not load X resources
  43. --no-window-system, -nw do not communicate with X, ignoring $DISPLAY
  44. --script FILE run FILE as an Emacs Lisp script
  45. --terminal, -t DEVICE use DEVICE for terminal I/O
  46. Action options:
  47. FILE visit FILE
  48. +LINE go to line LINE in next FILE
  49. +LINE:COLUMN go to line LINE, column COLUMN, in next FILE
  50. --directory, -L DIR prepend DIR to load-path (with :DIR, append DIR)
  51. --file FILE visit FILE
  52. --find-file FILE visit FILE
  53. --funcall, -f FUNC call Emacs Lisp function FUNC with no arguments
  54. --insert FILE insert contents of FILE into current buffer
  55. --load, -l FILE load Emacs Lisp FILE using the load function
  56. --visit FILE visit FILE
  57. Display options:
  58. --background-color, -bg COLOR window background color
  59. --basic-display, -D disable many display features;
  60. used for debugging Emacs
  61. --border-color, -bd COLOR main border color
  62. --border-width, -bw WIDTH width of main border
  63. --color, --color=MODE override color mode for character terminals;
  64. MODE defaults to \`auto', and
  65. can also be \`never', \`always',
  66. or a mode name like \`ansi8'
  67. --cursor-color, -cr COLOR color of the Emacs cursor indicating point
  68. --font, -fn FONT default font; must be fixed-width
  69. --foreground-color, -fg COLOR window foreground color
  70. --fullheight, -fh make the first frame high as the screen
  71. --fullscreen, -fs make the first frame fullscreen
  72. --fullwidth, -fw make the first frame wide as the screen
  73. --maximized, -mm make the first frame maximized
  74. --geometry, -g GEOMETRY window geometry
  75. --iconic start Emacs in iconified state
  76. --internal-border, -ib WIDTH width between text and main border
  77. --line-spacing, -lsp PIXELS additional space to put between lines
  78. --mouse-color, -ms COLOR mouse cursor color in Emacs window
  79. --name NAME title for initial Emacs frame
  80. --reverse-video, -r, -rv switch foreground and background
  81. --title, -T TITLE title for initial Emacs frame
  82. --vertical-scroll-bars, -vb enable vertical scroll bars
  83. --xrm XRESOURCES set additional X resources
  84. --parent-id XID set parent window
  85. --help display this help and exit
  86. --version output version information and exit
  87. You can generally also specify long option names with a single -; for
  88. example, -batch as well as --batch. You can use any unambiguous
  89. abbreviation for a --option.
  90. Various environment variables and window system resources also affect
  91. the operation of Emacs. See the main documentation.
  92. EOF
  93. }
  94. for a in "$@"; do
  95. case $a in
  96. --path | -P)
  97. shift 1
  98. EMACS="$1"
  99. shift 1
  100. ;;
  101. --toolbars | -B)
  102. shift 1
  103. TOOLBARS=1
  104. ;;
  105. --load-packages)
  106. shift 1
  107. LOAD_PACKAGES="$1"
  108. shift 1
  109. ;;
  110. -h)
  111. usage
  112. exit 1
  113. ;;
  114. esac
  115. done
  116. LOAD_PATH=$($EMACS -q -batch --eval "(prin1 load-path)")
  117. cd "${0%/*}" || exit 1
  118. # Check if autoload file exists.
  119. # It may be in a different directory if emacs-helm.sh is a symlink.
  120. TRUENAME=$(find . -samefile "$0" -printf "%l")
  121. if [ ! -z "$TRUENAME" ]; then
  122. AUTO_FILE="${TRUENAME%/*}/helm-autoloads.el"
  123. else
  124. AUTO_FILE="helm-autoloads.el"
  125. fi
  126. if [ ! -e "$AUTO_FILE" ]; then
  127. echo No autoloads found, please run make first to generate autoload file
  128. exit 1
  129. fi
  130. cat > $CONF_FILE <<EOF
  131. (setq initial-scratch-message (concat initial-scratch-message
  132. ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\\n\
  133. ;; This Emacs is Powered by \`HELM' using\\n\
  134. ;; emacs program \"$EMACS\".\\n\
  135. ;; This is a minimal \`helm' configuration to discover \`helm' or debug it.\\n\
  136. ;; You can retrieve this minimal configuration in \"$CONF_FILE\".\\n\
  137. ;;
  138. ;; Some original Emacs commands are replaced by their \`helm' counterparts:\\n\\n\
  139. ;; - \`find-file'(C-x C-f) =>\`helm-find-files'\\n\
  140. ;; - \`occur'(M-s o) =>\`helm-occur'\\n\
  141. ;; - \`list-buffers'(C-x C-b) =>\`helm-buffers-list'\\n\
  142. ;; - \`completion-at-point'(M-tab) =>\`helm-lisp-completion-at-point'[1]\\n\
  143. ;; - \`apropos-command'(C-h a) =>\`helm-apropos'\\n\
  144. ;; - \`dabbrev-expand'(M-/) =>\`helm-dabbrev'\\n\
  145. ;; - \`execute-extended-command'(M-x) =>\`helm-M-x'\\n\\n
  146. ;; Some other Emacs commands are \"helmized\" by \`helm-mode'.\\n\
  147. ;; [1] Coming with emacs-24.4, \`completion-at-point' is \"helmized\" by \`helm-mode'\\n\
  148. ;; which provides Helm completion in many places like \`shell-mode'.\\n\
  149. ;; Find context help for most Helm commands with \`C-h m'.\\n\
  150. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\\n\\n"))
  151. (setq load-path (quote $LOAD_PATH))
  152. (require 'package)
  153. ;; User may be using a non standard \`package-user-dir'.
  154. ;; Modify \`package-directory-list' instead of \`package-user-dir'
  155. ;; in case the user starts Helm from a non-ELPA installation.
  156. (unless (file-equal-p package-user-dir "~/.emacs.d/elpa")
  157. (add-to-list 'package-directory-list (directory-file-name
  158. (file-name-directory
  159. (directory-file-name default-directory)))))
  160. (let* ((str-lst "$LOAD_PACKAGES")
  161. (load-packages (and str-lst
  162. (not (string= str-lst ""))
  163. (split-string str-lst ","))))
  164. (setq package-load-list
  165. (if (equal load-packages '("all"))
  166. '(all)
  167. (append '((helm-core t) (helm t) (async t) (popup t))
  168. (mapcar (lambda (p) (list (intern p) t)) load-packages)))))
  169. (package-initialize)
  170. (add-to-list 'load-path (file-name-directory (file-truename "$0")))
  171. (unless (> $TOOLBARS 0)
  172. (setq default-frame-alist '((vertical-scroll-bars . nil)
  173. (tool-bar-lines . 0)
  174. (menu-bar-lines . 0)
  175. (fullscreen . nil))))
  176. (blink-cursor-mode -1)
  177. (require 'helm-config)
  178. (helm-mode 1)
  179. (define-key global-map [remap find-file] 'helm-find-files)
  180. (define-key global-map [remap occur] 'helm-occur)
  181. (define-key global-map [remap list-buffers] 'helm-buffers-list)
  182. (define-key global-map [remap dabbrev-expand] 'helm-dabbrev)
  183. (define-key global-map [remap execute-extended-command] 'helm-M-x)
  184. (define-key global-map [remap apropos-command] 'helm-apropos)
  185. (unless (boundp 'completion-in-region-function)
  186. (define-key lisp-interaction-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point)
  187. (define-key emacs-lisp-mode-map [remap completion-at-point] 'helm-lisp-completion-at-point))
  188. (add-hook 'kill-emacs-hook #'(lambda () (and (file-exists-p "$CONF_FILE") (delete-file "$CONF_FILE"))))
  189. EOF
  190. $EMACS -Q -l "$CONF_FILE" "$@"