#+TAGS: { client server } nodejs common-lisp lisp git shell DONE * Org Mode ** Starts 'org-mode 'org-indent-mode Indent the contents on different level (You seei in the firest line make it by default) ** Collapwse # S- Means Shift S- org-shifttab 循环切换整个文档的大纲状态(三种状态:折叠,打开下一级,打开全部) org-cycle 循环切换光标所在大纲的状态 ** Move Cursor C-c C-n/p 下/上一标题 C-c C-f/b 下/上一标题(仅限同级标题) C-c C-u 跳到上一级标题 C-c C-j 切换到大纲浏览状态 ** Edit/Move Contents M-RET 插入一个同级标题 M-S-RET 插入一个同级TODO 标题 M-left/right 将当前标题升/降级 *你的光标要载标题处* M-S-left/right 将子树升/降级 *同上* M-S-up/down 将子树上/下移 *同上* C-c * 将本行设为标题/正文 *所以会自动加一级* C-c C-w 将子树或区域移动到另一标题处(切换Boss) *Move this tree* C-x n s/w 只显示当前子树/返回 *s:隐藏其他子树 w:返回* *C-c C-x b* 在新缓冲区显示当前分支 *不用改变当前分区* C-c / 只列出包含搜索结果的大纲,并高亮,支持多种搜索方式 *Regular Expression!* C-c C-c 取消高亮 *在上面的搜索结果* ** Links C-c C-l org-insert-link 创建或修改链接,可以引用已保存的链接 C-c C-o org-open-at-point 打开光标所在的链接 Examples: http://celwk.com/gravity Website (will be opened by default Browser - Chrome) file:~/Develop/Lisp/ Folder (will be opened by Mac) [[file:/Develop/Lisp/2019/][Lisp Directory]] file:~/Develop/C/environ.c Same as above file:~/Develop/Lisp/init.cl::40 File, absolute path (will be opended in this Emacs), the 40th row file:org-mode.org File, relative path (setq default-directory "/Develop/C") Run it by file:environ.c Link format: [[link] [description]] Remove the middle space. file:/Users/Can/Develop/Lisp/history/images/mandelbrot.png *** Internal Link (anchor) Define: <> [[my-anchor][Goto My Anchor]] file:~/other-file.org::my-anchor Link to another Org file's link ** Table Start with "|" in a line, and end with "C-c RET", jump to another cloum with key. C-c | org-table-create-or-convert-from-region C-c 竖线 创建或转换成表格 C-c C-c 调整表格,不移动光标 移动到下一区域,必要时新建一行 S- 移动到上一区域 RET 移动到下一行,必要时新建一行 M-left/right 移动列 M-UP/down 移动行 M-S-left/right 删除/插入列 M-S-UP/down 删除/插入行 C-c - 添加水平分割线 C-c RET 添加水平分割线并跳到下一行 C-c ^ 根据当前列排序,可以选择排序方式 |-------------+-------------+-----| | Name | Phone | Age | |-------------+-------------+-----| | Savior | 13012345678 | 12 | | Can EriK Lu | 15089323844 | 30 | | Love | 18043392350 | 50 | |-------------+-------------+-----| ** List 无序列表项以‘-’、‘+’或者‘*‘开头。 有序列表项以‘1.’或者‘1)’开头。 描述列表用‘::’将项和描述分开。 有序列表和无序列表都以缩进表示层级。只要对齐缩进,不管是换行还是分块都认为是处于当前列表项。 My favorite scenes are (in this order) 1. The attack of the Rohirrim 2. Eowyn's fight with the witch king + this was already my favorite scene in the book + I really like Miranda Otto. Important actors in this film are: - Elijah Wood :: He plays Frodo - Sean Austin :: He plays Sam, Frodo's friend. TAB 折叠列表项 M-ret 插入项 M-S-ret 插入带复选框的项 M-S-up/down 移动列表项 M-left/right 升/降级列表项,不包括子项 M-S-left/rigth 升/降级列表项,包括子项 c-c C-c 改变复选框状态 C-c - 更换列表标记(循环切换) (setq org-src-tab-acts-natively t) 显示代码格式 (common-lisp) ** [[http://www.cnblogs.com/holbrook/archive/2012/04/12/2444992.html#sec-4][Tag]] C-c % => (org-mark-ring-push) 记录当前标签位置 C-c & => (org-mark-ring-goto) 返回到上一个标签位置 ** Tutorial [[https://www.cnblogs.com/Open_Source/archive/2011/07/17/2108747.html][Org-mode 简明手册]] [[http://www.cnblogs.com/holbrook/archive/2012/04/12/2444992.html][Org-mode: 最好的文档编辑利器,没有之一]] * Emacs ** [[~/.emacs][Emacs Configuration File]] [[file://~/emacs.d/keys.el][Key Bindings]] (menu-bar-mode 0/1) 隐藏/显示菜单栏,打开菜单 ** [[file:~/.emacs.d/keys.el::22][Bookmarks]] *'list-bookmarks* || C-x r l List Bookmarks *'bookmark-jump* || C-x r b Open a bookmark, wildcard available, e.g *data 'bookmark-set || C-x r m Make(create) a bookmark 'bookmark-save Save current buffer to a bookmark 'bookmark-delete Delete a bookmark by name a – show annotation for the current bookmark A – show all annotations for your bookmarks d – mark various entries for deletion (x – to delete them) e – edit the annotation for the current bookmark m – mark various entries for display and other operations, (v – to visit) o – visit the current bookmark in another window, keeping the bookmark list open C-o – switch to the current bookmark in another window r – *rename the current bookmark* ** [[~/emacs.d/keys.el][Shortcuts]] ** Eval ([[file:~/emacs.d/keys.el::19][Evaluate]]) 'eval-buffer Eval the current buffer(elisp) C-x C-x, C-x C-e 'eval-last-sexp Evaluate expression before your curosor C-z, M-z 'eval-expression Prompt for your expression to evaluate ** [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Several-Buffers.html][Buffers]] C-x h Select whole buffer; (select-all) C-x C-b List Buffers (type "g" to refresh) *F4* Close the current window *C-x 4 C-o* display-buffer *Without selecting it!!* *C-x 4 b* switch-to-buffer-other-window *And select it* C-x i [insert-file] Insert a file's content to this buffer 'revert-buffer To set the buffer to the unsaved file content. 'erase-buffer Erase the whole buffer. [[https://blog.csdn.net/diabloneo/article/details/7691204][Emacs iBuffers]] ** Directory (C-h F dired) 'dired || C-x d List the directory files [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Contents-of-Directories.html][(directory-files "~/.emacs.d")]] o: Open selected file in another window C-o: Open selected file in another window without selecting its buffer d: Add delete tag u: Remove delete tag x: Execute +: New sub directory *** 查看帮助 ? 简单帮助 h 模式帮助 *** 移动光标 n, p, SPC 上、下移动光标 [p] C-n, C-p 上、下移动光标 [p] M-{, M-} 已标记的文件之间移动 [p] C-M-p, C-M-n 缓冲中的子目录间移动 [p] <, > 缓冲中的目录行间移动 [p] C-M-u 缓冲中的目录树上移动 [p] M-g 光标移动到某个文件上 M-G 光标移动到某个缓冲中的子目录上,(用 i 插入的) *** 标记文件 m 标记文件,下移一行 [p] u 去掉标记,下移一行 [p] U 去掉缓冲中所有的标记 M-Backspace 去掉缓冲中所有的某个标记,缺省为 * 标记 Backspace 并去掉上一行标记,并上移一行 [p] t 标记/未标记互换 D 删除所有标记的文件/目录 [*] d 设置“删除标记”(字符D),并且光标下移一行 [p] x 删除用 d 标记的文件/目录 ~ 将缓冲中备份文件做删除标记 [u] & 没用的文件,做删除标记 # 将缓冲中自动保存的文件做删除标记 [u] . 按备份文件版本,将备份文件做删除标记 [u] % g 标记所有“含有”regexp 的文件 [u] * * 标记所有可执行文件 [u] * . 标记所有同扩展名文件 [ux] * / 标记所有目录 [u] * @ 标记所有符号连接 [u] * c 改变标记的符号 % d 通过匹配 regexp 标记删除 % m 通过匹配 regexp 标记 [u] *** 复制、移动、创建 文件或目录以及连接 C-x C-f 创建文件 + 创建目录 R 文件的重命名/移动 [p*] C 复制文件 [*] S 创建文件的 Symbol link (绝对路径) [p*] Y 创建文件的 Symbol link (相对路径) [px*] H 创建文件的 Hard link [p*] % C 复制匹配 regexp 的文件 [p*] % S 创建匹配 regexp 的 Symbol link (绝对路径) [p*] % Y 创建匹配 regexp 的 Symbol link (相对路径) [p*] % H 创建匹配 regexp 的 Hark link [p*] w 复制文件名,如果通过 C-u 传递一个前缀参数 0 ,则复制决定路径名, 如果只是 C-u 则复制相对于 dired 当前目录的相对路径。 *** 修改文件名、属性 M 修改文件 rwx 权限属性 [*] G 修改文件 Group 属性 [p*] O 修改文件 Owner 属性 [p*] T 修改文件的时间戳 [p*] % l 文件名逐一改为小写 [p*] % u 文件名逐一改为大写 [p*] % R, % r 重命名/移动匹配 regexp 的文件 [p*] *** 访问文件,目录 e, f, RET 打开文件或目录 a 打开文件或目录,并替换当前缓冲 v 使用 view 模式查看文件,q 退出,有些文件使用外部查看程序调用 o 另一个窗口中,打开文件或目录 C-o 另一个窗口中,打开文件或目录,但当前窗口不变 F 打开(多个)文件 [x*] I 使用 Info 模式查看文件 N 使用 man 模式查看文件,若有前缀参数,提示输入处理命令 [ux*] V 使用 RMAIL 模式查看文件 [x] *** 退出 ^ 访问目录的父目录,若有前缀参数在另外的窗口中打开 [u] q 退出缓冲,若有前缀参数则关闭缓冲 [u] *** 隐藏/刷新缓冲中内容 s 互换缓冲中“文件名/时间”排序 [u] C-u s 修改传递给 ls 的参数,即修改每行的内容 M-o 隐藏/显示部分次要文件,使缓冲更简便,若有前缀参数标记隐藏的文件 [ux] $ 隐藏/显示当前目录中内容 [p] M-$ 隐藏/显示缓冲中所有目录内容 k 隐藏文件,按 g 可以再显示出来 [p*] l 刷新缓冲文件 [p*] g 刷新缓冲所有文件 C-/, C-_, C-x u dired 模式的 undo i 把当前行的子目录插入缓冲中 C-u k 把光标放在子目录的header上按此组合,将会把子目录内容从当前buffer移除 *** 其他 = 比较文件 -= 文件和备份之间比较,若有前缀参数,提示输入 diff 选项 [u] w 复制文件名到 kill-ring [p*] Z 压缩/解压缩文件 [p*] X 在文件上执行 shell 命令 [p*] B 编译(Emacs Lisp)文件 [p*] L 加载(Emacs Lisp)文件 [p*] y 给出文件类型信息 (通过 file 命令) P 打印文件 [p*] *** dired-x.el 中的其他有用的函数 dired-mark-extension 按后缀标记 dired-flag-extension 按后缀标记删除 dired-clean-patch 标记删除 patch 文件 dired-clean-tex 标记删除 tex 编译文件 dired-very-clean-tex 标记删除 tex 编译文件 dired-jump 跳转到当前缓冲所在目录 dired-jump-other-window 在另一个窗口中跳转到当前缓冲所在目录 dired-omit-here-always 在当前目录生成 .dired 文件 ** Curosr Place C-u C-space ** Help *C-h f * Show the detail of the function name of Emacs *C-h k || 'describe-key * 描述当前缓冲区的绑定到的函数。 *C-h v describe-variable* 描述变量,例如 default-directory C-h b || 'describe-bindings 列出当前缓冲区的所有键绑定。 C-h m || 'describe-mode 显示所有当前缓冲区可用的major-mode的命令,然后是所有的minor-mode的命令。 C-h l || 'view-lossage 按顺序显示出你刚刚按了的所有按键的序列。 C-h d Show a list of functions, variables, and other items whose documentation matches the PATTERN (a list of words or a regexp). ** C-h Show the documentation of the prefix key. E.g: C-x 4 C-h *** [[https://github.com/nonsequitur/smex/][Smex]] C-h f, while Smex is active, runs describe-function on the currently selected command. M-. jumps to the definition of the selected command. C-h w shows the key bindings for the selected command. (Via where-is.) ** Files C-x C-f Open a file C-x 4 f Open a file(maybe existed) in a new window without cursoring it C-x i Insert(copy) a file content to curent buffer C-x C-w Save the current buffer with a specified(new) file name (write-file). ** Info C-x l Total line of the buffer C-z/M-: buffer-file-name Show the path name of the current buffrt E.g: C-z(enter)default-directory Return the current buffer's default directory (each buffer's directory maybe different) ** Windows C-x 0 *F4* Close the current window C-x 2 Split the selected window into two windows, one above the other (split-window-below). C-x 3 Split the selected window into two windows, positioned side by side (split-window-right). C-M-v Move another window without leaving current window. C-x + Balance-windows to make windows the same heights and widths. C-x o Select another window (other-window). [C-u - 1 C-x o] to select last window. C-x 4 C-f find-file-other-window C-x 4 C-j dired-jump-other-window *C-x 4 C-o* display-buffer *Without selecting it!!* *C-x 4 b* switch-to-buffer-other-window *And select it* C-x 4 . xref-find-definitions-other-window C-x 4 0 kill-buffer-and-window C-x 4 c clone-indirect-buffer-other-windowd C-x 4 d dired-other-window C-x 4 f find-file-other-window C-x 4 m compose-mail-other-window C-x 4 r find-file-read-only-other-window [C-x C-q switch read-only] ** Edit C-q || 'quoted-insert Insert a tab char *** [[http://ergoemacs.org/emacs/modernization_upcase-word.html][Toggle Case]] C+x C+u upcase-region C+x C+l downcase-region ** Notice Some emoji chars (not everyone) may course emacs display wrongly~~ ** Tutorial [[http://ergoemacs.org/emacs/emacs_fun.html][Fun with Emacs]] ** Swift Mode :iOS: https://github.com/swift-emacs/swift-mode ** Colors & Fonts M-x list-faces-display (Set the font color) ' list-colors-display ' set-face-foreground ' set-face-background ** SSH C-x C-f /ssh:root@celwk.com:~/app.js yum install sshpass sshpass -p my_password ssh root@celwk.com "ls -lah ~/celwk.com" > /Develop/celwk.txt ** Re-indent *C-u * Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. C-M-q Reindent all the lines within one parenthetical grouping. 'indent-code-rigidly Shift all the lines in the region rigidly sideways, but do not alter lines that start inside comments and strings. * LISP ** [[https://www.gnu.org/software/emacs/manual/html_node/eintr/car-cdr-_0026-cons.html][car, cdr, cons, nth, nthcdr, setcar, setcdr: Fundamental Functions]]* CAR and CDR stand for "Contents of the Address Register" and "Contents of the Decrement Register ** [[https://www.gnu.org/software/emacs/manual/html_node/elisp/Iteration.html][while/dolist/dotimes iteration]] ** Macros: [[https://www.kancloud.cn/ituring/on-lisp/56193][On Lisp]] 宏是用来写程序的程序。这句话意味深长,深入地探究这个问题正是本书的主要目的之一。 深思熟虑地使用宏,可以让程序惊人的清晰简洁。这些好处绝非唾手可得。尽管到最后,宏将被视为世上最自然的 东西,但最初理解它的时候却会举步维艰。部分原因是因为宏比函数更加一般化,所以编写的时候要考虑的事情更 多。 但宏难于理解,最主要的原因是它太另类了。没有任何一门语言有像 Lisp 宏那样的东西。所以学习宏,可能先要 从头脑中清除从其他语言那里潜移默化接受的先入为主的观念。这些观念中,首当其冲就是为那些陈词滥调所累的 程序。凭什么数据结构可以变化,并且其中的数据可以修改,而程序却不能呢?在 Lisp 里,程序就是数据,但其 中深意需要假以时日才能体会到。 在 Lisp 里,程序就是数据!! 在我们的大脑,思想也是数据(细胞,原子)! ** Pipe #+BEGIN_SRC lisp (uiop:run-program "sort" :input (uiop:process-info-output (uiop:launch-program "ls" :output :stream)) :output :string) #+END_SRC * eLisp ** Edit *** [[https://www.gnu.org/software/emacs/manual/html_node/emacs/Multi_002dline-Indent.html][Indet]] C-M-\ indent-region ** Default parameter value: (defun command (a &optional b) (or b (setq b default-value)) (command-body a b)) ** [[https://joaotavora.github.io/yasnippet/snippet-development.html][YASnippet]] 'yas-visit-snippet-file Choose a snippet to edit 'yas-describe-tables List the snippets for this file C-c & C-n yas-new-snippet C-c & C-s yas-insert-snippet C-c & C-v yas-visit-snippet-file Examples: #+BEGIN_SRC objective-c //Timestamp: `(current-time-string)` for ($1;$2;$3) { `yas-selected-text`$0 } - (${1:id})${2:foo} { return $2; } - (void)set${2:$(capitalize yas-text)}:($1)aValue { [$2 autorelease]; $2 = [aValue retain]; } $0 #+END_SRC *** Evaluate multiple arguments (format "${1:formatted %s}" "${2:value}") => "${1:$(ignore-errors (format (yas-field-value 1) (yas-field-value 2)))}" The second line will be auto updated by the every argument changing!! *** 'yas-activate-extra-mode To load an extra mode (not relative to the current file) #+BEGIN_SRC emacs-lisp (defun my-org-latex-yas () "Activate org and LaTeX yas expansion in org-mode buffers." (yas-minor-mode) (yas-activate-extra-mode 'latex-mode)) (add-hook 'org-mode-hook #'my-org-latex-yas) #+END_SRC * Programming/Coding ** Collapse Codes Use for comments mostly maybe, but you can also use to any function definition. ' hs-minor-mode key binding --- ------- C-c @ C-a hs-show-all C-c @ C-t hs-hide-all C-c C-t hs-toggle-hiding [C-c @ C-c] C-c @ C-l hs-hide-level ** Line number (global-linum-mode t) (setq linum-format " ") ;; Insert the left padding without showing the line number closed, normal lu (setq linum-format " %d ") ** Code Format :useful: C-u Reindent region! Shift an entire parenthetical grouping rigidly sideways so that its first line is properly indented. *** Comment M-; comment-dwim Insert or realign comment on current line; if the region is active, comment or uncomment the region instead. ** SLIME (Common Lisp) C-c C-d f 'slime-describe-function Describe the function at point. C-x C-e 'slime-eval-last-expression 运行光标前的指令 C-c M-q 'slime-reindent-defun M-TAB [Useful] 'slime-complete-symbol M-. 'slime-edit-definition C-c C-s 'slime-complete-form C-x + Make all windows the same height (balance-windows). C-c C-y 'slime-call-defun 在REPL里调用在当前光标处定义的函数 C-j 'slime-repl-newline-and-indent˘ (global-set-key (kbd "C-c C-q") 'slime-close-all-parens-in-sexp) (global-set-key (kbd "C-c C-c") 'slime-compile-defun) (global-set-key (kbd "C-c C-l") 'slime-load-file) (global-set-key (kbd "C-c C-k") 'slime-compile-file) (global-set-key (kbd "C-M-k") 'slime-repl-clear-buffer) (local-set-key (kbd "C-c C-z") 'slime-switch-to-output-buffer) C-c M-o 'slime-repl-clear-buffer 清空当前缓冲区,只留一个提示符。 C-c C-o 'slime-repl-clear-output 从缓冲区里清空之前表达式的输出和结果 (documentation #'name 'function) (describe #'name) (defun desc (symbol) (documentation symbol 'function)) (desc 'boundp) change-directory (aka !d, cd) M-x show-paren-mode M-: ;; Execute emacs command M-x load-file ;; For emacs C-x C-f load-common-lisp-file ;; For slime C-c M-q M-x slime-reindent-defun *M-n, M-x slime-repl-next-input* M-p, M-x slime-repl-previous-input M-s, M-x slime-repl-next-matching-input M-r, M-x slime-repl-previous-matching-input To cut the text, press C-w. To copy the text, press M-w. To paste the text, press C-y. paste back: M-y C-x { is bound to shrink-window-horizontally C-x } is bound to enlarge-window-horizontally C-x C-w Save to C-x h Select all region M-x write-region Write selected region to a file 全局变量 * , ** , 以及 *** 总是设定为最后三个顶层所返回的值。这些变量在除错的时候很有用。 ** Highlights Brackets (高亮括号) (show-paren-mode 0/1) (setq show-paren-style 'parenthesis) ;; highlight entire expression (setq show-paren-style 'expression) ;; highlight brackets if visible, else entire expression (setq show-paren-style 'mixed) ** Redis *** INFO Keyspace To get the key counts for every db *** DBSIZE Get the current db's key count *** SELECT redis-cli -n ${number} KEYS "u:*" | wc -l **** How many keys of pattern "u:*" in db number * Shell ** In Emacs *shell* :action: C-c M-o comint-clear-buffer Clean the buffer 'shell 'shell-command M-! ** In node.js :nodejs: [[https://www.npmjs.com/package/shelljs][ShellJS - Unix shell commands for Node.js]] ** Command Shortkey! !123 The history command #123 !-2 The last seconde history command (2 command-back) !cat The most recent command beginning with "cat" !! The last command !$ The last command argument ** Find find ~ -name *.plist -or -name *Photo* find ~ -name *.plist -and -name *Photo* ([] ? *) [Not Regular Expression] ** Basic date df -h --Disk free space of the system du -ah --Disk usage statistics sort -frub --ignore-case --reverse --unique --ignore-leading-blanks ** cat = concat file1.txt file2.txt > joined.txt ** grep grep -i Case insensitive -w Word -v Reverse (Only show the not matched) -n Show the line number -c Count of the matched -R Recursive (For folder) -l Only list matched file names (with -R) -L Reverse of -l (NOT matched file names) Search files of the specified suffix --include *.html --include *.js --include=*.${file_extension} ** xargs [ Set the input string as process args ] *** Use the input string as arguments. cat directory-name-list.txt | sort | uniq | xargs -I {} mkdir -p ~/Desktop/{} *** Kill process with the name "badprocess" ps aux | grep "badprocess" | cut -c 18-23 | xargs kill -9 **** cut -c 11-15 because the process id in the column between 11 to 15 *** git log -n 1 --stat --pretty=format:"" | xargs -0 node test.js My case: Use git hook to judge is it necessary to restart the server(by pm2)!! Is every path starts with "static/" ** Useful in Mac tr Translating characters sed 's/[aeiou]/_/g' control+v = \t = tab cut -c 2-10,30-36 file.txt Characters cat file.txt | cut -f 2,6 -d "," Delimiter and column alias hh='h 20 | cut -c 33-' Only show the last 20 history without the front 33 chars of needless time info ** Save manual to PDF man -t emacs | open -fa Preview man -t bash | open -fa Preview ** Pasteboard cut -f 2,6 students.tsv | pbcopy Copy the the pasteboard (Send it) pbcopy < something.txt pbpaste alias pbsort='pbpaste | sort | pbcopy' ** Screen Capture screencapture -v filename Capture the screen video ** Meta data of file mdls file Get the meta data of the file mdfind -onlyin ./ 'kMDItemFSName == "*lisp*"' In recent 2 days mdfind -onlyin ./ 'kMDItemFSCreationDate >= $time.today(-2)' In recent 2 days [$time.yesterday $time.this_week(-1) ] mdfind -onlyin ./ 'kMDItemFSCreationDate >= $time.iso(2019-02-12 12:35:11 -0800)' Create since that time! mdfind -onlyin ./ 'kMDItemFSCreationDate >= $time.now(-100000) && kMDItemFSName == "*lisp*"' In recent 100000 seconds AND file name ... ** Desktop Picure in Login Mode sudo defaults write com.apple.loginWindow DesktopPicture "/Library/Desktop Pictures/El Capitan 2.jpg" ** last To list the last login data ** ssh remote issue!! Don't allow the write permission for GROUP of the ~/.ssh directory!! https://blog.csdn.net/u011350541/article/details/81070275 https://bjornjohansen.no/ssh-timeout * Git ** Basic git init --bare git clone ax:/repo/weplant_ios.git git clone root@celwk.com:/repo/weplant_ios.git (For XCode) ** [[https://aotu.io/notes/2017/04/10/githooks/index.html][Git Hook]] Auto pull the code after pushing in the server, and restart ONLY if necessary!!! Edit the #<<.git/hook/post-update>> file **** unset GIT_DIR **** cd ~/celwk **** git pull **** log=$(git log -n 1 --stat --pretty=format:"") **** echo "$log" | xargs -0 node restart.js # Maybe restart is not necessary if only client files are changed? Whatever~ **** log=$(git log -n 1 --stat --pretty=format:"%s %n[%an] %cd") **** echo -e "$log\n==================================================" >> ~/celwk/log/$(date "+%Y-%m-%d").log *Mon Mar 11 18:23:31 2019* ** Options to limit the output of git log Option Description - Show only the last n commits --since, --after Limit the commits to those made after the specified date. --until, --before Limit the commits to those made before the specified date. --author Only show commits in which the author entry matches the specified string. --committer Only show commits in which the committer entry matches the specified string. --grep Only show commits with a commit message containing the string -S Only show commits adding or removing code matching the string **** git log --pretty="%h - %s" --author='Junio C Hamano' --since="2008-10-01" --before="2008-11-01" --no-merges ** Install the magit package in Emacs https://magit.vc/ https://magit.vc/manual/magit/index.html https://magit.vc/manual/magit/Initiating-a-Commit.html https://magit.vc/manual/magit/Editing-Commit-Messages.html ** Getting started with Magit: *'magit-status* to see git status, and in the status buffer: Type ? to get command help. s to stage files c c to [[https://magit.vc/manual/magit/Editing-Commit-Messages.html#Editing-Commit-Messages][commit]] (type the message then C-c C-c to submit commit or C-c C-k to cancel) b b to switch to another branch Other handy keys: P u to do a git push F u to do a git pull try to press TAB ** Change git folder to bare https://stackoverflow.com/questions/2199897/how-to-convert-a-normal-git-repository-to-a-bare-one ** Rename git path git remote set-url origin root@celwk.com:/repo/celwk.git https://stackoverflow.com/questions/2432764/how-to-change-the-uri-url-for-a-remote-git-repository ** Ignore some foleder touch .gitignore git status git rm -r --cached node_modules && echo "node_modules/" >> .gitignore git rm -r --cached .idea/ git rm -r --cached avatar/ git status ** Don't push *** git update-index --assume-unchanged ...(file path) **** Keep change locally, like .gitignore *** git checkout -- **.cl *** git reset --hard (All the files, forcely) **** discard changes * Works ** Update data from niceschool.cn alias ns-update="lx 'mysqldump -R -uroot --databases --add-drop-database GreatSchool > ~/database/GreatSchool.sql' && lx-update" *** Goto the server: lx [ssh root@niceschool.cn] *** Backup the data in server: mysqldump *** Back to local and run **** Data lx-update **** Avatar: scp -r root@niceschool.cn:~/GreatSchool/avatar/ /Develop/GreatSchool/ * Question ** What is emacs hook? Just like JavaScript events... * Finished #DONE# ** Implement the load all codes in a directory Because [ (add-to-list 'load-path ...) is just for require/provid] I have already implement in [[file:~/emacs.d/can.el::2][(load-directory directory &optional match)]] ** Git automatically restart my node.js server after pushing by clients? [[.git/hook/post-update][Git Hook!]] * TODO ** Execute C compiler and run it by Shell Must be Very quickly and convinently(automatically) ** Solution: make !! * Links [[http://celwk.com][Can's Home Page]]