aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md5
-rwxr-xr-xemacs.el154
-rwxr-xr-xshenanigans.sh128
-rw-r--r--vimrc52
4 files changed, 339 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a3ea7dd
--- /dev/null
+++ b/README.md
@@ -0,0 +1,5 @@
1```sh
2ln -s ~/.dotfiles/emacs.el ~/.config/emacs/init.el
3ln -s ~/.dotfiles/vimrc ~/.vimrc
4ln -s ~/.dotfiles/shenanigans.sh ~/.shenanigans.sh
5```
diff --git a/emacs.el b/emacs.el
new file mode 100755
index 0000000..7ad08c0
--- /dev/null
+++ b/emacs.el
@@ -0,0 +1,154 @@
1(require 'package)
2(add-to-list 'package-archives '("melpa-stable" . "http://stable.melpa.org/packages/") t)
3(add-to-list 'package-archives '("gnu" . "https://elpa.gnu.org/packages/"))
4(add-to-list 'package-archives '("nongnu" . "https://elpa.nongnu.org/nongnu/"))
5(package-initialize)
6
7(setq custom-file "~/.config/emacs/custom.el")
8(when (file-exists-p custom-file)
9 (load custom-file))
10
11;; Function to install packages if they're not already installed
12(defvar my-packages
13 '(go-mode yaml-mode web-mode markdown-mode tree-sitter tree-sitter-langs
14 editorconfig company drag-stuff eglot helm elfeed crux))
15
16(defun install-my-packages ()
17 (unless package-archive-contents
18 (package-refresh-contents))
19 (dolist (package my-packages)
20 (unless (package-installed-p package)
21 (package-install package))))
22
23(install-my-packages)
24
25;; General stuff
26(menu-bar-mode -1)
27(setq inhibit-startup-message t)
28(setq visible-bell t)
29(setq echo-keystrokes 0.1)
30(setq gc-cons-threshold 20000000)
31(setq make-backup-files nil)
32(setq create-lockfiles nil)
33(setq auto-save-default nil)
34(setq global-auto-revert-non-file-buffers t)
35(setq auto-revert-verbose nil)
36(setq-default tab-width 4)
37(setq-default truncate-lines t)
38(set-default 'indicate-empty-lines t)
39(setq electric-pair-preserve-balance nil)
40(setq byte-compile-warnings '(cl-functions))
41(global-display-line-numbers-mode 1)
42(global-auto-revert-mode 1)
43(electric-pair-mode t)
44(show-paren-mode 1)
45(setq-default fill-column 80)
46(global-hl-line-mode 1)
47(set-face-background hl-line-face "gray13")
48(add-to-list 'default-frame-alist '(foreground-color . "#ffffff"))
49(add-to-list 'default-frame-alist '(background-color . "#151515"))
50
51;; Key rebinds
52(global-set-key (kbd "C-z") 'undo-only)
53(global-set-key (kbd "C-S-z") 'undo-redo)
54(global-set-key (kbd "M-s") 'save-buffer)
55(global-set-key (kbd "C-f") 'isearch-forward)
56(global-set-key (kbd "M-f") 'fill-paragraph)
57(global-set-key (kbd "C-x C-c") 'kill-emacs)
58(global-set-key (kbd "M-q") 'kill-emacs)
59(global-set-key (kbd "M-<right>") 'end-of-line)
60(global-set-key (kbd "M-<left>") 'beginning-of-line)
61(global-set-key (kbd "M-d") 'crux-duplicate-current-line-or-region)
62(global-set-key (kbd "M-k") 'crux-kill-whole-line)
63(global-set-key (kbd "C-h") 'crux-kill-line-backwards)
64(global-set-key (kbd "C-k") 'crux-kill-other-buffers)
65(global-set-key (kbd "M-v") 'visual-line-mode)
66(global-set-key (kbd "C-_") (lambda() (interactive) (comment-line 1) (previous-line 1)))
67
68;; Move line up and down
69(drag-stuff-mode t)
70(global-set-key (kbd "M-<up>") 'drag-stuff-up)
71(global-set-key (kbd "M-<down>") 'drag-stuff-down)
72
73;; Save a list of recent files visited. (open recent file with C-x f)
74(recentf-mode 1)
75(setq recentf-max-saved-items 100)
76
77;; Helm stuff
78(require 'helm)
79(helm-autoresize-mode 1)
80(setq helm-autoresize-max-height 25 helm-autoresize-min-height 25)
81(global-set-key (kbd "M-x") 'helm-M-x)
82(global-set-key (kbd "C-p") 'helm-find-files)
83(global-set-key (kbd "C-b") 'helm-buffers-list)
84(global-set-key (kbd "C-x C-_") 'helm-find)
85
86;; Enables editorconfig
87(editorconfig-mode 1)
88
89;; Enable company mode completion
90(add-hook 'after-init-hook 'global-company-mode)
91
92;; Eglot LSP
93(setq eglot-ignored-server-capabilities '(:inlayHintProvider))
94(add-hook 'c-mode-hook 'eglot-ensure)
95(add-hook 'go-mode-hook 'eglot-ensure)
96(add-hook 'tcl-mode-hook 'eglot-ensure)
97(add-hook 'sh-mode-hook 'eglot-ensure)
98(add-hook 'python-mode-hook 'eglot-ensure)
99(add-hook 'lua-mode-hook 'eglot-ensure)
100(add-hook 'js-mode-hook 'eglot-ensure)
101
102;; Go format before save
103(add-hook 'go-mode-hook
104 (lambda ()
105 (add-hook 'before-save-hook 'gofmt-before-save)
106 (setq tab-width 4)
107 (setq indent-tabs-mode 1)))
108
109;; Enables tree sitter
110(global-tree-sitter-mode)
111(add-hook 'tree-sitter-after-on-hook #'tree-sitter-hl-mode)
112
113;; Templating engines
114(require 'web-mode)
115(add-to-list 'auto-mode-alist '("\\.twig\\'" . web-mode))
116(add-to-list 'auto-mode-alist '("\\.html\\'" . web-mode))
117(add-to-list 'auto-mode-alist '("\\.django\\'" . web-mode))
118(setq web-mode-enable-auto-pairing t)
119(setq web-mode-enable-auto-closing t)
120(setq web-mode-enable-current-element-highlight t)
121(setq web-mode-enable-current-column-highlight t)
122
123;; RSS Feeds
124(setq elfeed-search-filter "@48-months-ago")
125(setq elfeed-feeds '(
126 ("https://landley.net/rss.xml")
127 ("https://blog.regehr.org/feed")
128 ("https://szymonkaliski.com/feed.xml")
129 ("https://world.hey.com/dhh/feed.atom")
130 ("https://workchronicles.com/feed/")
131 ("https://mitchellh.com/feed.xml")
132 ("https://matt-rickard.com/rss")
133 ("https://solar.lowtechmagazine.com/posts/index.xml")
134 ("https://utcc.utoronto.ca/~cks/space/blog/?atom")
135 ("https://gosamples.dev/index.xml")
136 ("https://neil.computer/rss/")
137 ("https://matduggan.com/rss/")
138 ("https://michael.stapelberg.ch/feed.xml")
139 ("https://offbeatpursuit.com/blog/index.rss")
140 ("https://offbeatpursuit.com/paste/index.rss")
141 ("https://offbeatpursuit.com/notes/index.rss")
142 ("https://emacsredux.com/atom.xml")
143 ("https://journal.valeriansaliou.name/rss/")
144 ("https://www.taniarascia.com/rss.xml")
145 ("https://crawl.develz.org/wordpress/feed")
146 ("https://snarky.ca/rss/")
147 ("https://www.jeffgeerling.com/blog.xml")
148 ("https://serokell.io/blog.rss.xml")
149 ("https://www.duskborn.com/index.xml")
150 ("https://mirzapandzo.com/rss.xml")
151 ("https://blog.boot.dev/index.xml")
152 ("https://macwright.com/rss.xml")
153))
154
diff --git a/shenanigans.sh b/shenanigans.sh
new file mode 100755
index 0000000..040f8bc
--- /dev/null
+++ b/shenanigans.sh
@@ -0,0 +1,128 @@
1# Software list.
2# cifs-utils tree jq xmlstarlet s3cmd xclip neovim mc gnupg
3# tilix fzf ripgrep
4
5# Magical environment variables.
6
7NIX_SHELL_PRESERVE_PROMPT=1
8TERM=xterm-256color
9EDITOR=vim
10
11# Better prompt.
12
13parse_git_branch() {
14 git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
15}
16
17is_inside_nix_shell() {
18 nix_shell_name="$(basename "$IN_NIX_SHELL" 2>/dev/null)"
19 if [[ -n "$nix_shell_name" ]]; then
20 echo " \e[0;36m(nix-shell)\e[0m"
21 fi
22}
23
24export PS1="[\033[38;5;9m\]\u@\h\[$(tput sgr0)\]]$(is_inside_nix_shell)\[\033[33m\]\$(parse_git_branch)\[\033[00m\] \w\[$(tput sgr0)\] \n$ "
25
26# General aliases.
27
28alias c='clear'
29alias l='ls -lh'
30alias ll='ls -lha'
31alias t='tree -L 2'
32alias ..='cd ..'
33alias h='history'
34alias x='exit'
35alias grep='grep --color=always'
36alias less='less -R'
37alias e='emacs'
38alias n='nvim'
39alias gg='lazygit'
40alias gt='git-town'
41alias server='python3 -m http.server 6969'
42
43# Custom folder jump commands.
44
45alias p='cd ~/Vault/projects'
46alias j='cd ~/Junk'
47alias d='cd ~/Downloads'
48alias v='cd ~/Vault'
49
50# Additional path settings.
51
52export PATH=$HOME/Vault/bin:$PATH
53export PATH=$HOME/Applications:$PATH
54export PATH=$HOME/.local/bin:$PATH
55export PATH=$HOME/go/bin:$PATH
56
57export PATH=$HOME/Android/Sdk/platform-tools:$PATH
58export PATH=$HOME/Android/Sdk/tools:$PATH
59
60# History and search.
61
62HISTCONTROL=ignoreboth
63shopt -s histappend
64export HISTSIZE=
65export HISTFILESIZE=
66export HISTFILE=~/.bash_history_infinite
67PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}"
68bind '"\e[A": history-search-backward'
69bind '"\e[B": history-search-forward'
70alias hh=hstr
71export HSTR_CONFIG=hicolor
72if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi
73
74# Useful function. Much wow!
75
76backup() {
77 VHOME=/home/$USER/Vault
78 ME=$(whoami)@$(hostname)
79
80 mkdir -p $VHOME/dotfiles
81 cd $VHOME/dotfiles
82
83 # Make a copy of dotfiles.
84 cp /home/$USER/.shenanigans.sh shenanigans.sh
85 cp /home/$USER/.bash_history bash_history
86 cp /home/$USER/.bash_history_infinite bash_history_infinite
87 cp /home/$USER/.smbcredentials smbcredentials
88 cp /home/$USER/.gitconfig gitconfig
89 cp /home/$USER/.s3cfg s3cfg
90
91 cp /home/$USER/.vimrc vimrc
92 cp /home/$USER/.config/nvim/init.lua neovim.lua
93 cp /home/$USER/.config/emacs/init.el init.el
94
95 cp -Rf /home/$USER/.ssh/ ./
96 cp -Rf /home/$USER/.aws/ ./
97
98 dconf dump /com/gexperts/Tilix/ > tilix.dconf
99 # dconf load /com/gexperts/Tilix/ < tilix.dconf
100
101 # Backup screenshots.
102 mkdir -p $VHOME/pictures
103 cp -rfn ~/Pictures/* $VHOME/pictures/
104
105 # Backup screencasts.
106 mkdir -p $VHOME/videos
107 cp -rfn ~/Videos/* $VHOME/videos/
108
109 # Sync with NAS.
110 rsync -azv \
111 --exclude '.venv/' \
112 --exclude '.git/' \
113 --exclude 'node_modules/' \
114 --delete \
115 $VHOME/ /media/Void/Backup/$ME/
116
117 # Sync to off-site DO S3 bucket.
118 s3cmd sync \
119 --host-bucket=vault \
120 --delete-removed \
121 --exclude 'node_modules/*' \
122 --exclude '.git/*' \
123 --exclude '.venv/*' \
124 $VHOME/ s3://vault/backup/$ME/
125
126 # Add to log file.
127 echo `date +"%D %T"` >> ~/.vault.log
128}
diff --git a/vimrc b/vimrc
new file mode 100644
index 0000000..b8af15e
--- /dev/null
+++ b/vimrc
@@ -0,0 +1,52 @@
1set nocompatible
2
3" General sane defaults.
4syntax enable
5colorscheme sorbet
6nnoremap q: <nop>
7set relativenumber
8set nohlsearch
9set smartcase
10set ignorecase
11set incsearch
12set nowrap
13set nobackup
14set noswapfile
15set autoread
16set wildmenu
17set autoindent
18set noesckeys
19set encoding=utf8
20set backspace=2
21set scrolloff=4
22set spelllang=en_us
23
24nnoremap <silent> <A-,> :silent :bp<CR>
25nnoremap <silent> <A-.> :silent :bn<CR>
26
27" Commenting blocks of code.
28augroup commenting_blocks_of_code
29 autocmd!
30 autocmd FileType c,cpp,go,scala let b:comment_leader = '// '
31 autocmd FileType sh,ruby,python let b:comment_leader = '# '
32 autocmd FileType conf,fstab let b:comment_leader = '# '
33 autocmd FileType lua let b:comment_leader = '-- '
34 autocmd FileType vim let b:comment_leader = '" '
35augroup END
36noremap <silent> gcc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
37noremap <silent> gcu :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
38
39" Language specific indentation.
40filetype plugin indent on
41autocmd Filetype make,go,sh setlocal noexpandtab tabstop=4 shiftwidth=4
42autocmd Filetype c,cpp,html,javascript,css,python setlocal expandtab tabstop=2 shiftwidth=2
43
44" Status Line enhancements.
45" set laststatus=2
46" set statusline=%f%m%=%y\ %{strlen(&fenc)?&fenc:'none'}\ %l:%c\ %L\ %P
47" hi StatusLine cterm=NONE ctermbg=black ctermfg=brown
48" hi StatusLineNC cterm=NONE ctermbg=black ctermfg=darkgray
49
50" Throwaway config.
51au BufReadPost *.twig set syntax=html
52