Skip to content

Instantly share code, notes, and snippets.

@c02y
c02y / config.fish
Last active November 21, 2018 05:45
diff in fish-shell
# diff
# side-by-side
alias diff-s 'diff -r -y -s --suppress-common-line -W $COLUMNS' # side-by-side, only diffs
alias diff-sf 'diff -r -y -s -W $COLUMNS' # like diff-s, but print whole files
alias diff-sw 'diff-s -w' # like diff-s, but ignore all white space
# line by line
alias diff-l 'diff -r -s --suppress-common-line -W $COLUMNS' # line-by-line, only diffs
alias diff-lf 'diff -r -s -W $COLUMNS' # like diff-l, but print whole files
alias diff-lw 'diff-l -w' # like diff-l, but ignore all white space
@c02y
c02y / init.el
Last active November 12, 2018 06:30
tweak bindings
defun delete-line-or-region-or-buffer:
change
(kill-region (line-beginning-position) (line-end-position))
to
(delete-region (line-beginning-position) (line-end-position))
;; (bind-key* "C-c C-SPC" 'er/expand-region) │
(bind-key* "C-c =" 'er/expand-region)
(bind-keys*
@c02y
c02y / config.fish
Created November 1, 2018 07:18
list contents of deb package
alias debl 'dpkg --contents' # list contents of deb package
@c02y
c02y / init.el
Created October 31, 2018 06:43
change sudo string og Tramp
/sudo:root@localhost:
to
/sudo::
@c02y
c02y / gist:e6d31643dc69bb9da11f72eb21df1c83
Created October 24, 2018 07:11
resource how to top process of cpu and mem, useful for tmux status line
#!/bin/bash
MEM=$(ps -eo pid,cmd,%mem --sort=-%mem | sed '2q;d')
TOP_MEM_PID=$(echo $MEM | awk '{print $1}')
TOP_MEM=$(echo $MEM | awk '{print $2}')
TOP_MEM_P=$(echo $MEM | awk '{print $NF}')
CPU=$(ps -eo pid,cmd,%cpu --sort=-%cpu | sed '2q;d')
TOP_CPU_PID=$(echo $CPU | awk '{print $1}')
TOP_CPU=$(echo $CPU | awk '{print $2}')
TOP_CPU_P=$(echo $CPU | awk '{print $NF}')
@c02y
c02y / init.el
Created October 19, 2018 07:15
tweak keybings since it affect the keybings in other modes like elpy-*
(bind-keys :map emacs-lisp-mode-map
("C-x c" . emacs-lisp-byte-compile-and-load)
("C-c c" . eval-buffer)
("C-c C-r" . (lambda () (interactive) (load-file "~/.emacs.d/init.elc")))
)
(bind-keys :map lisp-interaction-mode-map
("C-c C-e" . (lambda () (interactive) (find-file "~/.emacs.d/init.el")))
("C-c C-r" . (lambda () (interactive) (load-file "~/.emacs.d/init.elc")))
;; C-h e to switch to *Message* Buffer
)
@c02y
c02y / init.el
Last active October 18, 2018 07:47
replace nlinum-mode with display-line-numbers-mode which is supported by Emacs 26 and more
https://github.com/emacs-mirror/emacs/blob/ff49d86b6419f88205ff9a5d8b1cc46fcda8371c/etc/NEWS#L493
http://xuchengpeng.com/2018/03/30/emacs-show-line-numbers/
;; M-x profiler-start and do your thing and M-x profiler-report to show the
;; performance report, the following improves the structure of the report
(setq profiler-report-cpu-line-format '((80 left) (24 right ((19 right) (5 right)))))
(setq profiler-report-memory-line-format '((80 left) (24 right ((19 right) (5 right)))))
@c02y
c02y / init.el
Last active October 16, 2018 10:08
python in emacs
https://realpython.com/emacs-the-best-python-editor/
1. remove paradox since it will keep loading the list
2. remove python-mode configuration about company/anaconda since when you open python file, it will say
"comint-send-string: Process Python Internal(file.py) not running"
3. install elpy, py-autopep8
;; Python Development Environment
@c02y
c02y / init.el
Created October 16, 2018 07:55
remove company-ropemacs line in init.el
https://github.com/company-mode/company-mode/issues/159#issuecomment-122598917
@c02y
c02y / init.el
Created October 11, 2018 07:31
cscope config for Emacs
(require 'xcscope)
(cscope-setup)
(setq cscope-option-use-inverted-index t)
(defadvice cscope-bury-buffer (after cscope-bury-buffer activate)
"Kill the *cscope* window after hitting q or Q instead of leaving it open."
(delete-window))
(defun cscope-create-database (top-directory)
"Create cscope* files in one step containing, do this before using cscope:
1. C-c s L
2. C-c s I