Skip to content

Instantly share code, notes, and snippets.

@c02y
c02y / init.el and cofig.fish
Last active March 26, 2019 11:20
use emacsclient to speed up startup of Emacs
remove dired+ and bookmark+ packages
clean dired+ config
;; (setq desktop-save 'ask)
;;desktop-save ask means always ask
;; (desktop-save-mode nil)
(setq confirm-kill-emacs 'y-or-n-p)
(defun ask-before-closing ()
"Useful to be used in emacsclient to avoid accident exit of Emacs like 'Save desktop?'."
(interactive)
@c02y
c02y / config.fish
Created March 25, 2019 02:52
scc to replace tokei which replaces cloc
delete tokei config
download scc bin to ~/.local/bin/
@c02y
c02y / config.fish
Last active March 22, 2019 10:04
conda
# The packages needed to be installed using conda are(only if you have no sudo permission or the offcial is old)
# conda install -c conda-forge ncurses emacs w3m fish the_silver_searcher source-highlight tokei
# conda install -c ripl-org tmux
# conda install -c lebedov tig
delete space at the end of condai
emi -> eme
replace cloc with tokei
abbr cl 'tokei --sort code' # install tokei using `conda install -c conda-forge tokei`
@c02y
c02y / config.fish
Created March 21, 2019 10:12
tweak fu
function fu -d 'fu command and prompt to ask to open it or not'
# $argv could be builtin keyword, function, alias, file(bin/script) in $PATH, abbr
# And they all could be defined in script or temporally (could be found in any file)
set found 0
# Check `type` output, NOTE: `type` doesn't support abbr
if type $argv ^/dev/null # omit the result once error(abbr or not-a-thing) returned, $status = 0
set found 1 # for not-a-thing
set result (type $argv)
end
@c02y
c02y / init.el
Last active March 18, 2019 05:46
cool-moves replaces drag-stuff
delete drag-stuff config and package
;; cool-moves
(require 'cool-moves)
;; M-.. are useful in org-mode, use elpy-mode-map instead of python-mode-map here
(dolist (m (list prog-mode-map elpy-mode-map))
(bind-keys :map m
("M-<up>" . cool-moves/line-backward)
("M-<down>" . cool-moves/line-forward)
("M-<left>" . cool-moves/sexp-backward)
If less gets stuck when opening a file
comment LESSOPEN line
function t -d 'if tmux is running, attach it, if not, create a new tmux session, and check $SHELL'
if not command -sq tmux
echo tmux is not installed, please install it!
return 1
end
if test (basename $SHELL) = "bash"
if test -f ~/anaconda3/bin/fish
set -gx SHELL ~/anaconda3/bin/fish
else if command -sq fish
1. delete `;; You can do M-c/...` line
2. delete `C-x M-c` line
3. delete the comment-style line, since it will affect M-; comment style if it is one line
4. delete sh-mode-hook part
(defun in-comment-p (&optional pos)
"Test if character at POS is comment. If POS is nil, character at `(point)' is tested.
From https://emacs.stackexchange.com/a/14716/794"
(interactive)
@c02y
c02y / t
Last active March 12, 2019 09:08
t in ~/.local/bin/t
#!/bin/bash
t () { # set $SHELL fish if it is not, attach tmux session if exists
if ! hash tmux 2>/dev/null; then
echo tmux is not installed, please install it!
return 1
fi
if [ $(basename $SHELL) != "fish" ]; then
if [ -f ~/anaconda3/bin/fish ]; then
@c02y
c02y / init.el
Last active March 8, 2019 10:43
fold in emacs
delete origami config(and other func mentioned origami) and package since it doesn't work well with Python
delete iy-go-to-char config and package
C-return binding doesn't work with Emacs in terminal, so rebind
;; yafolding
;; (autoload 'yafolding "yafolding" t)
(add-hook 'prog-mode-hook 'yafolding-mode)
(bind-keys :map prog-mode-map
("C-c f" . yafolding-toggle-element)
("C-c F" . yafolding-toggle-all))