diff options
| author | Mitja Felicijan <mitja.felicijan@gmail.com> | 2023-12-14 07:10:50 +0100 |
|---|---|---|
| committer | Mitja Felicijan <mitja.felicijan@gmail.com> | 2023-12-14 07:10:50 +0100 |
| commit | e4e86775200ccbf88ff5e4e032a960c2e0266481 (patch) | |
| tree | d8a64e0c054d017d3372d16d86cc1f3545a2d675 | |
| download | dotfiles-e4e86775200ccbf88ff5e4e032a960c2e0266481.tar.gz | |
Engage!
| -rw-r--r-- | README.md | 5 | ||||
| -rwxr-xr-x | emacs.el | 154 | ||||
| -rwxr-xr-x | shenanigans.sh | 128 | ||||
| -rw-r--r-- | vimrc | 52 |
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 | ||
| 2 | ln -s ~/.dotfiles/emacs.el ~/.config/emacs/init.el | ||
| 3 | ln -s ~/.dotfiles/vimrc ~/.vimrc | ||
| 4 | ln -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 | |||
| 7 | NIX_SHELL_PRESERVE_PROMPT=1 | ||
| 8 | TERM=xterm-256color | ||
| 9 | EDITOR=vim | ||
| 10 | |||
| 11 | # Better prompt. | ||
| 12 | |||
| 13 | parse_git_branch() { | ||
| 14 | git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/' | ||
| 15 | } | ||
| 16 | |||
| 17 | is_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 | |||
| 24 | export 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 | |||
| 28 | alias c='clear' | ||
| 29 | alias l='ls -lh' | ||
| 30 | alias ll='ls -lha' | ||
| 31 | alias t='tree -L 2' | ||
| 32 | alias ..='cd ..' | ||
| 33 | alias h='history' | ||
| 34 | alias x='exit' | ||
| 35 | alias grep='grep --color=always' | ||
| 36 | alias less='less -R' | ||
| 37 | alias e='emacs' | ||
| 38 | alias n='nvim' | ||
| 39 | alias gg='lazygit' | ||
| 40 | alias gt='git-town' | ||
| 41 | alias server='python3 -m http.server 6969' | ||
| 42 | |||
| 43 | # Custom folder jump commands. | ||
| 44 | |||
| 45 | alias p='cd ~/Vault/projects' | ||
| 46 | alias j='cd ~/Junk' | ||
| 47 | alias d='cd ~/Downloads' | ||
| 48 | alias v='cd ~/Vault' | ||
| 49 | |||
| 50 | # Additional path settings. | ||
| 51 | |||
| 52 | export PATH=$HOME/Vault/bin:$PATH | ||
| 53 | export PATH=$HOME/Applications:$PATH | ||
| 54 | export PATH=$HOME/.local/bin:$PATH | ||
| 55 | export PATH=$HOME/go/bin:$PATH | ||
| 56 | |||
| 57 | export PATH=$HOME/Android/Sdk/platform-tools:$PATH | ||
| 58 | export PATH=$HOME/Android/Sdk/tools:$PATH | ||
| 59 | |||
| 60 | # History and search. | ||
| 61 | |||
| 62 | HISTCONTROL=ignoreboth | ||
| 63 | shopt -s histappend | ||
| 64 | export HISTSIZE= | ||
| 65 | export HISTFILESIZE= | ||
| 66 | export HISTFILE=~/.bash_history_infinite | ||
| 67 | PROMPT_COMMAND="history -a; history -n; ${PROMPT_COMMAND}" | ||
| 68 | bind '"\e[A": history-search-backward' | ||
| 69 | bind '"\e[B": history-search-forward' | ||
| 70 | alias hh=hstr | ||
| 71 | export HSTR_CONFIG=hicolor | ||
| 72 | if [[ $- =~ .i. ]]; then bind '"\C-h": "\C-a hstr -- \C-j"'; fi | ||
| 73 | |||
| 74 | # Useful function. Much wow! | ||
| 75 | |||
| 76 | backup() { | ||
| 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 | } | ||
| @@ -0,0 +1,52 @@ | |||
| 1 | set nocompatible | ||
| 2 | |||
| 3 | " General sane defaults. | ||
| 4 | syntax enable | ||
| 5 | colorscheme sorbet | ||
| 6 | nnoremap q: <nop> | ||
| 7 | set relativenumber | ||
| 8 | set nohlsearch | ||
| 9 | set smartcase | ||
| 10 | set ignorecase | ||
| 11 | set incsearch | ||
| 12 | set nowrap | ||
| 13 | set nobackup | ||
| 14 | set noswapfile | ||
| 15 | set autoread | ||
| 16 | set wildmenu | ||
| 17 | set autoindent | ||
| 18 | set noesckeys | ||
| 19 | set encoding=utf8 | ||
| 20 | set backspace=2 | ||
| 21 | set scrolloff=4 | ||
| 22 | set spelllang=en_us | ||
| 23 | |||
| 24 | nnoremap <silent> <A-,> :silent :bp<CR> | ||
| 25 | nnoremap <silent> <A-.> :silent :bn<CR> | ||
| 26 | |||
| 27 | " Commenting blocks of code. | ||
| 28 | augroup 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 = '" ' | ||
| 35 | augroup END | ||
| 36 | noremap <silent> gcc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR> | ||
| 37 | noremap <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. | ||
| 40 | filetype plugin indent on | ||
| 41 | autocmd Filetype make,go,sh setlocal noexpandtab tabstop=4 shiftwidth=4 | ||
| 42 | autocmd 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. | ||
| 51 | au BufReadPost *.twig set syntax=html | ||
| 52 | |||
