mirror of https://git.decapod.one/brethil/dotfiles
Compare commits
379 Commits
20201208-0
...
master
Author | SHA1 | Date |
---|---|---|
bretello | e021c813b2 | |
bretello | 1e90b5766c | |
bretello | 120cd3f4d9 | |
bretello | c572b2cb10 | |
bretello | 26022ea7b6 | |
bretello | 32df12a6df | |
bretello | 030903dcd7 | |
bretello | 81d8c56836 | |
bretello | edc1934e83 | |
bretello | a9a45864d2 | |
bretello | 62c95b60d5 | |
bretello | c137ef0e0f | |
bretello | 3db7721edb | |
bretello | faf318c3d0 | |
bretello | 1ee73be7f9 | |
bretello | 8cdbefa3de | |
bretello | 22023f667e | |
bretello | 114bbe758e | |
bretello | 7312c868b3 | |
bretello | 56b8f1d05f | |
bretello | 5674865f11 | |
bretello | 0c7d0ec24f | |
bretello | b05fde87c2 | |
bretello | 04bfe043ab | |
bretello | 35575755ef | |
bretello | 10c79f1bad | |
bretello | 25037bde1f | |
bretello | 481c81c68a | |
bretello | 94ed0a6ea8 | |
bretello | 3955481e32 | |
bretello | 471fc948a8 | |
bretello | 7f2fa528fe | |
bretello | fba95ede51 | |
bretello | 2a1b2f5da4 | |
bretello | 3d260ec64d | |
bretello | d70b43dbee | |
bretello | bcad9f77aa | |
bretello | 208057ce91 | |
bretello | 94eb4cded8 | |
bretello | 2805f13208 | |
bretello | 904f53b0e0 | |
bretello | a275d1fefc | |
bretello | 651a14135b | |
bretello | 1038647c2c | |
bretello | 32ce07fcde | |
bretello | d26f542874 | |
bretello | 245eb034f4 | |
bretello | b73838f58b | |
bretello | 58393456a9 | |
bretello | 353378af8c | |
bretello | 439f29318c | |
bretello | f9e4a2c224 | |
bretello | b5ebe15e79 | |
bretello | 37f33a3614 | |
bretello | 0ada46b805 | |
bretello | c41a91e784 | |
bretello | a20bffdf67 | |
bretello | 1537ddcc64 | |
bretello | aaea49ecf8 | |
bretello | 41eb8f1a5f | |
bretello | f4e960be35 | |
bretello | 58201b2ab7 | |
bretello | 4d9462239f | |
bretello | c329308759 | |
bretello | ee531d18cd | |
bretello | 125a4e7aed | |
bretello | cff20cef16 | |
bretello | f307a705a2 | |
bretello | a4019ac53a | |
bretello | cffd1ef025 | |
bretello | bfad3b2a4c | |
bretello | c71f4a83a3 | |
bretello | 5703c21e43 | |
bretello | 7efeedf6d9 | |
bretello | e32676922e | |
bretello | b96f0a6f86 | |
bretello | 51f92885fe | |
bretello | d4bf2f32f8 | |
bretello | e749eedb75 | |
bretello | 455ba2c17e | |
bretello | f6880b715e | |
bretello | de05c9c8f7 | |
bretello | 20baed04d9 | |
bretello | cf6dad897d | |
bretello | fa69ebe8f9 | |
bretello | 0e5f23e864 | |
bretello | 1ccb61013d | |
bretello | a0c5985009 | |
bretello | 90c870b91d | |
bretello | be236d0e25 | |
bretello | f5f6133c53 | |
bretello | 4b19ff0f38 | |
bretello | 9ed23cd5a5 | |
bretello | 99baa7f1e0 | |
bretello | 1dcdb77f97 | |
bretello | c5532fea31 | |
bretello | 70aec3b2b6 | |
bretello | 39abcd4756 | |
bretello | 5a1c3c07ac | |
bretello | 0c52f21233 | |
bretello | b193afe50a | |
bretello | 323542a705 | |
brethil | 24fc7dd2ed | |
brethil | d1135262de | |
bretello | 76579a603e | |
bretello | fbc6934f8f | |
bretello | 4b73ed209f | |
bretello | fc0410eff3 | |
bretello | cea2eed10c | |
bretello | 9ccf8699ec | |
bretello | d72886b6c1 | |
bretello | e08ee08768 | |
bretello | f30468da11 | |
bretello | 05699e751b | |
bretello | f6a405657c | |
bretello | e9ad8a563d | |
bretello | 5563b3434f | |
bretello | ca30bd2d47 | |
bretello | a8c89d32c9 | |
bretello | 3b6cf2b92f | |
bretello | 8e3c36d200 | |
bretello | 2066baee05 | |
bretello | 3f89412fcc | |
bretello | 8d561fea1f | |
bretello | b95fac5c72 | |
bretello | 57caa424e6 | |
bretello | fd05f479d9 | |
bretello | ff696ac5db | |
bretello | 9299c753e0 | |
bretello | 12e521a2c6 | |
bretello | 977a45e109 | |
bretello | 2c36af6615 | |
bretello | 937555cd8d | |
bretello | 5b575986c9 | |
bretello | 3df7a304c4 | |
bretello | b50a9dec24 | |
bretello | c9767aad51 | |
bretello | 0bfa411f7a | |
bretello | 72a02e22e0 | |
karajan1001 | b2df319e18 | |
bretello | dea326e488 | |
bretello | b0ae3d6e3d | |
bretello | 827843d8bd | |
bretello | 6e17084112 | |
bretello | 2fb53e6f2b | |
bretello | 5f4b4538bb | |
bretello | a3f74bf816 | |
bretello | 9f566efa8e | |
bretello | f3bf033fb8 | |
bretello | dff98b066f | |
bretello | 26e313e21e | |
bretello | 75a00b2380 | |
bretello | 76feeb3af0 | |
bretello | 9667cf96c2 | |
bretello | 486ee8afbf | |
bretello | 5393f33795 | |
bretello | f88413ddf8 | |
bretello | 0c95eef23a | |
bretello | 21d9660e64 | |
bretello | bef37c3601 | |
bretello | 0ed9e5373c | |
bretello | d1be12fa3e | |
bretello | 492205e86b | |
bretello | 41b97a1be3 | |
bretello | 9b6494c94d | |
bretello | 2841fada0a | |
bretello | 6235cfb737 | |
bretello | c5be7e7f0c | |
bretello | fe32254093 | |
bretello | 5d8850389f | |
bretello | cb05a031a6 | |
bretello | 624eb4710c | |
bretello | 782accd7ae | |
bretello | 7005372b5a | |
bretello | 78ee86c14a | |
bretello | ecd2472910 | |
bretello | b86622e598 | |
bretello | f73659aa45 | |
bretello | 89c73f3adf | |
bretello | 9d2a3d99bd | |
bretello | 8689c25815 | |
bretello | 21c3f4ac51 | |
bretello | 24e705b332 | |
bretello | 6fa513850c | |
bretello | 85381436cf | |
bretello | fc4972dab3 | |
bretello | c6b110b325 | |
bretello | 73ef8d928a | |
bretello | 41d001a5ce | |
bretello | 925ef0901e | |
bretello | 927601f444 | |
bretello | f48e6fa773 | |
bretello | 8773349238 | |
bretello | afb1a7a795 | |
bretello | c231afe36e | |
bretello | 43426f7ac5 | |
bretello | c6d444c709 | |
bretello | 476fd545b5 | |
bretello | 330d3dbef6 | |
bretello | 66ca1af8b7 | |
bretello | 4bf6198638 | |
bretello | 95e0d56ea7 | |
bretello | c507973d50 | |
bretello | 0b3213632e | |
bretello | ea25269d1f | |
bretello | 683ca475ae | |
bretello | 56d9cf12db | |
bretello | f05a892907 | |
bretello | 7e00071eda | |
bretello | 41816d6821 | |
bretello | ea95b4edce | |
bretello | 40540908e0 | |
bretello | f1454a95f7 | |
bretello | b249ed88f3 | |
bretello | ef244d81e2 | |
bretello | ca7a7453a9 | |
bretello | 207a46b847 | |
bretello | 81a84dacd2 | |
bretello | 8236f71189 | |
bretello | d58d4232e8 | |
bretello | 5d45f454f8 | |
bretello | 6d428ac1e7 | |
bretello | d302f40ffc | |
bretello | 29fc94db68 | |
bretello | 6a5991de8b | |
bretello | d946a2b7d9 | |
bretello | 84236e28ad | |
bretello | f297e2e221 | |
bretello | b7f6ea2fc9 | |
bretello | f8c767bf98 | |
bretello | 1a3856d78d | |
bretello | 86adb6f53a | |
bretello | 52366a3769 | |
bretello | 6d16512c0a | |
bretello | 234f3da804 | |
bretello | 2a43038a48 | |
bretello | b8d56ee083 | |
bretello | 4a985b2ffa | |
bretello | 904b0227b7 | |
bretello | 24999c4776 | |
bretello | f2850c54f1 | |
bretello | cce95a4ab7 | |
bretello | 92e0591129 | |
bretello | a8039caf58 | |
bretello | b6c078fbfe | |
bretello | 54167b0107 | |
bretello | cce075e29c | |
bretello | 8e760f3e3e | |
bretello | 97b49b34c8 | |
bretello | ea6dbc555e | |
bretello | 9bdbd1774d | |
bretello | 54666b0a03 | |
bretello | 9d901364fc | |
bretello | cbcc841ba8 | |
bretello | 601a16f07d | |
bretello | 8f481eb4b7 | |
bretello | f9c08eefd1 | |
bretello | 23a9369e66 | |
bretello | 9b2328aad3 | |
bretello | 55ca57247d | |
bretello | 266b121d68 | |
bretello | 6a1bba6bbd | |
bretello | 38f7bf2c60 | |
bretello | bf933fcf3e | |
bretello | 6f1d1263fa | |
bretello | d8461c69fc | |
bretello | 14be7945e1 | |
bretello | 9fe51f308c | |
bretello | d1a6bf898e | |
bretello | 53b5d0f9f7 | |
bretello | 79e584b7e8 | |
bretello | 8c43d4c7c1 | |
bretello | ca15cbc840 | |
bretello | 32ca99ea14 | |
bretello | ddefba551e | |
bretello | e009704e75 | |
bretello | 517cf45174 | |
bretello | b64781409c | |
bretello | d7ccec7fef | |
bretello | 636a8c185c | |
bretello | 1e86f54f3c | |
bretello | 3acebef599 | |
bretello | 9ae5b71263 | |
bretello | 0cde5c3ea8 | |
bretello | 6cd1f5e07a | |
bretello | 5f84402142 | |
bretello | 5a6dd6bee7 | |
bretello | 926bb413a4 | |
bretello | 98604c6a4c | |
bretello | bbf4c325b8 | |
bretello | 37821a77ab | |
bretello | 9ac97f0af7 | |
bretello | 7f2e0333fd | |
bretello | ab7660a41b | |
bretello | 0cb850b8a4 | |
bretello | d99915b642 | |
bretello | c2ae92ff9e | |
bretello | f8bc1793b7 | |
bretello | 6f5b808787 | |
bretello | f307a2207d | |
bretello | a6a927e6d8 | |
bretello | e1921affdc | |
bretello | 2e19f7d476 | |
bretello | fe83822b56 | |
bretello | 3bab8cd959 | |
bretello | d20c511105 | |
bretello | 61fcdb7ea7 | |
bretello | 40074e5655 | |
bretello | 8a1ca40569 | |
bretello | 681acc90e6 | |
bretello | c5edf934ef | |
bretello | 55abb84de7 | |
bretello | f95cbf6e5c | |
bretello | 1a603373ec | |
bretello | 5a79c63f33 | |
bretello | b3ad761244 | |
bretello | 7bdba383c6 | |
bretello | d88b203b73 | |
bretello | 88c26c90d1 | |
bretello | 185330490b | |
bretello | a8f17dfaa3 | |
bretello | 4f34f5957f | |
bretello | 036c631c0c | |
bretello | 1e4bf92f96 | |
bretello | 529f0f0dff | |
bretello | e50cc58941 | |
bretello | 9dd2aa7ac4 | |
bretello | e38021e324 | |
bretello | f19e9ea485 | |
bretello | f5f70bfc07 | |
bretello | 43b72d36dd | |
bretello | 71f307e12c | |
bretello | dbe581b065 | |
bretello | f9fe64f9f8 | |
bretello | 11ae80412d | |
bretello | deb1563e50 | |
bretello | db74463cd1 | |
bretello | b01bf588eb | |
bretello | 53923d0d58 | |
bretello | 52e4ed0d88 | |
bretello | 4ef43fed16 | |
bretello | 79dcf5e973 | |
bretello | d4ec9a5f2e | |
bretello | 42422738e4 | |
bretello | 45e0800add | |
bretello | 5e4fa5ef03 | |
bretello | b280360a16 | |
bretello | 651bfe01f7 | |
bretello | 9e2e7e1ee0 | |
bretello | 229a97856e | |
bretello | 6c90122583 | |
bretello | 6b97913926 | |
bretello | a6997cc37c | |
bretello | 95e74f1d32 | |
bretello | b4c180b0e8 | |
bretello | 3ee43774cc | |
bretello | 63fdbc59ae | |
bretello | 8317b80841 | |
bretello | 8a6cda547b | |
bretello | 0e3e7cd155 | |
bretello | bc4db32d68 | |
bretello | 6bd0ce46ba | |
bretello | d066906af3 | |
bretello | daf0094409 | |
bretello | 2b6cac6c8d | |
bretello | bc8861451e | |
bretello | 9430765116 | |
bretello | 34fd5a8726 | |
bretello | 4b3b12db5b | |
bretello | 64ade8d864 | |
bretello | 6485af4411 | |
bretello | 74dcf328aa | |
bretello | d6e1aac0f2 | |
bretello | 0b68fec862 | |
bretello | 8f599cc5cc | |
bretello | 12b8cd8360 | |
bretello | 5fbaf3d535 | |
bretello | 8a8d061fe4 | |
bretello | 96d7882471 |
|
@ -0,0 +1,9 @@
|
|||
/.drone.yml
|
||||
/.gitignore
|
||||
/.dotfiles-update
|
||||
.mypy_cache
|
||||
.venv
|
||||
.git
|
||||
.zcompdump*
|
||||
|
||||
.vagrant
|
|
@ -0,0 +1 @@
|
|||
0c3b712
|
|
@ -0,0 +1,40 @@
|
|||
name: Build Image
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: "20 4 * * 6" # saturday at 4.20
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
FORCE_COLOR: "1"
|
||||
DOCKER_REGISTRY: registry.decapod.one
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
- name: Login to docker registry
|
||||
uses: docker/login-action@v3
|
||||
with:
|
||||
registry: registry.decapod.one
|
||||
username: ${{ secrets.REGISTRY_USER }}
|
||||
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
push: true
|
||||
tags: registry.decapod.one/brethil/dotfiles:latest
|
||||
- name: Notify on failure
|
||||
if: failure()
|
||||
run: python -m venv .
|
||||
pip install https://git.decapod.one/brethil/bretellofier
|
||||
|
||||
./bin/bretellofier "[brethil/dotfiles] 💥 Build failed"
|
||||
env:
|
||||
BRETELLOFIER_RECIPIENTS: ${{ secrets.BRETELLOFIER_RECIPIENTS }}
|
||||
BRETELLOFIER_TOKEN: ${{ secrets.BRETELLOFIER_TOKEN}}
|
|
@ -1,8 +1,7 @@
|
|||
.dotfiles-update
|
||||
.DS_store
|
||||
*antigen-compat
|
||||
*.zwc
|
||||
history.sqlite
|
||||
dhist
|
||||
|
||||
ipython/profile_default/{log,db}
|
||||
ipython/profile_default/history.sqlite
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
FROM archlinux:latest as base
|
||||
|
||||
ENV TERM=xterm-256color
|
||||
ENV DOTFILES=/root/.dotfiles
|
||||
|
||||
RUN pacman --noconfirm -Syu && pacman --noconfirm -Sy \
|
||||
vim \
|
||||
tmux \
|
||||
git \
|
||||
fzf \
|
||||
base-devel \
|
||||
ipython \
|
||||
python-pip \
|
||||
htop \
|
||||
python-ruff \
|
||||
python-virtualenv \
|
||||
bash-language-server \
|
||||
&& rm -rf /var/cache/pacman/pkg/*
|
||||
|
||||
# Enable colors in pacman
|
||||
RUN sed -i 's/^#Color/Color/' /etc/pacman.conf
|
||||
|
||||
FROM base as builder
|
||||
|
||||
# Cannot run makepkg as root: add build user
|
||||
RUN useradd build && echo "build ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
|
||||
|
||||
USER build
|
||||
|
||||
# yay (pre-compiled) and bretellofier
|
||||
WORKDIR /home/build/yay
|
||||
RUN git clone https://aur.archlinux.org/yay-bin.git /home/build/yay && \
|
||||
git clone https://aur.archlinux.org/bretellofier.git /home/build/bretellofier && \
|
||||
cd /home/build/yay && env GOCACHE=/home/build makepkg --syncdeps --noconfirm && \
|
||||
cd /home/build/bretellofier && makepkg --syncdeps --noconfirm
|
||||
|
||||
|
||||
FROM base as final
|
||||
WORKDIR /root
|
||||
|
||||
RUN pacman -Sy --noconfirm zsh && chsh -s /bin/zsh
|
||||
|
||||
COPY --from=builder /home/build/yay/*zst /tmp/
|
||||
COPY --from=builder /home/build/bretellofier/*zst /tmp/
|
||||
RUN pacman --noconfirm -U /tmp/*zst && rm -rf /tmp/*zst
|
||||
|
||||
# antibody
|
||||
RUN curl -sL https://git.io/antibody | sh -s - -b /usr/local/bin
|
||||
|
||||
# vim-plug
|
||||
RUN curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
|
||||
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
||||
|
||||
RUN git clone https://git.decapod.one/brethil/dotfiles ${DOTFILES}
|
||||
COPY . ${DOTFILES}
|
||||
|
||||
WORKDIR /root/
|
||||
|
||||
RUN echo -e "export DOTFILES=/root/.dotfiles\nsource \$DOTFILES/brethil_dotfile.sh" >> .zshrc && \
|
||||
ln -s $DOTFILES/vim/vimrc .vimrc && \
|
||||
ln -s $DOTFILES/tmux.conf .tmux.conf && \
|
||||
echo -e "[include]\npath = $DOTFILES/gitconfig" >> .gitconfig
|
||||
|
||||
# Install vim plugins
|
||||
RUN vim -c 'PlugInstall|qa!'
|
||||
|
||||
# Install zsh plugins
|
||||
RUN zsh -c exit
|
||||
|
||||
CMD ["tmux"]
|
183
README.md
183
README.md
|
@ -1,141 +1,94 @@
|
|||
# brethil's dotfiles
|
||||
|
||||
A set of zsh dotfiles based on antibody and oh-my-zsh
|
||||
My own dotfiles. `zsh` configuration based on [antibody](https://github.com/getantibody/antibody) and [oh-my-zsh](https://github.com/ohmyzsh/ohmyzsh), `vim` configuration uses [vim-plug](https://github.com/junegunn/vim-plug), [ALE](https://github.com/dense-analysis/ale) and more.
|
||||
|
||||
[!ci.decapod.one status](https://ci.decapod.one/api/badges/2/status.svg)
|
||||
|
||||
[zsh theme](docs/brethil-theme.png "zsh theme")
|
||||
[vim theme](docs/vim.png "vim theme")
|
||||
[tmux theme](docs/tmux.png "tmux theme")
|
||||
|
||||
## Description
|
||||
|
||||
├── README.md
|
||||
├──────── Main files ────────
|
||||
│ ├── aliases.sh
|
||||
│ │ └── aliases definitions (sources `~/.dotfiles_aliases`)
|
||||
│ ├── colors.sh
|
||||
│ │ └── ANSI color escapes
|
||||
│ ├── functions.sh
|
||||
│ │ └── contains function definitions (sources `~/.dotfiles_functions`)
|
||||
│ ├── ansible
|
||||
│ │ └── ansible playboooks/config
|
||||
│ └── brethil_dotfile.sh:
|
||||
│ └── This file should be sourced by your `.zshrc`
|
||||
├──────── antibody plugins ────────
|
||||
│ ├── antibody_plugins_arch.txt
|
||||
│ └── antibody_plugins.txt
|
||||
├──────── oh-my-zsh themes ────────
|
||||
│ ├── brethil.zsh-theme
|
||||
│ └── brethil-minimal.zsh-theme
|
||||
├──────── Misc rc files────────
|
||||
│ ├── gitconfig
|
||||
│ │ └── git configuration
|
||||
│ ├── ackrc
|
||||
│ │ └── `ack`'s rc: a grep-like text finder
|
||||
│ ├── ipython
|
||||
│ │ ├── profile_default
|
||||
│ │ ├── ipython_config.py
|
||||
│ │ ├── startup
|
||||
│ │ ├── 11-autoreload.py
|
||||
│ │ └── README
|
||||
│ ├── vim
|
||||
│ │ ├── vimrc
|
||||
│ │ │ └── main vim rc
|
||||
│ │ ├── plugs.vim
|
||||
│ │ │ └── plugins to be installed with vim-plug
|
||||
│ │ ├── plugins_config.vim
|
||||
│ │ │ └── plugins configuration
|
||||
│ │ ├── shortcuts.vim
|
||||
│ │ │ └── vim shortcuts definitions
|
||||
│ │ ├── functions.vim
|
||||
│ │ │ └── miscellaneous vim function
|
||||
│ │ └── twilight256.vim
|
||||
│ │ └── an old colorscheme
|
||||
│ └── pdbrc.py
|
||||
│ └── pdb++'s rc (a drop-in replacement for pdb)
|
||||
├──────── Other ─────────────
|
||||
├── check_for_update.sh
|
||||
│ └── selfupdate script
|
||||
└── useful_commands
|
||||
├── README.md
|
||||
├──────── Main files ────────
|
||||
│ ├── aliases/
|
||||
│ │ └── aliases definitions. Add .zsh files here to include more
|
||||
│ ├── functions/
|
||||
│ │ └── functions definitions. ADD .zsh files here to include more
|
||||
│ ├── colors.zsh
|
||||
│ │ └── ANSI color escapes
|
||||
│ ├── ansible
|
||||
│ │ └── ansible playboooks/config
|
||||
│ ├── brethil_dotfile.sh:
|
||||
│ │ └── ansible playboooks/config
|
||||
│ ├── antibody_plugins.txt
|
||||
│ │ zsh plugins sourced by antibody
|
||||
├──────── oh-my-zsh themes ────────
|
||||
│ ├── themes
|
||||
│ │ ├─ brethil.zsh-theme
|
||||
│ └ └─ brethil-minimal.zsh-theme
|
||||
├──────── Misc rc files────────
|
||||
│ ├── gitconfig
|
||||
│ │ └── git configuration
|
||||
│ ├── ipython/
|
||||
│ │ ├── ipython configs
|
||||
│ ├── vim
|
||||
│ │ ├── vimrc
|
||||
│ │ │ └── main vim rc
|
||||
│ │ ├── plugs.vim
|
||||
│ │ │ └── plugins to be installed with vim-plug
|
||||
│ │ ├── plugins_config.vim
|
||||
│ │ │ └── plugins configuration
|
||||
│ │ ├── shortcuts.vim
|
||||
│ │ │ └── vim shortcuts definitions
|
||||
│ │ └── functions.vim
|
||||
│ │ └── miscellaneous vim function
|
||||
│ └── pdbrc.py
|
||||
│ └── pdb++ rc (a drop-in replacement for pdb)
|
||||
├──────── Other ─────────────
|
||||
├── extras/check_for_update.zsh
|
||||
│ └── selfupdate script
|
||||
└── useful_commands
|
||||
|
||||
## Installation
|
||||
|
||||
With ansible:
|
||||
### With ansible:
|
||||
|
||||
```bash
|
||||
[ bash dev/add_community.general.sh ] # if community.general is not installed
|
||||
ansible-playbook -v -i <hosts file> [-e fix_annoyances=true] ansible/playbooks/setup.yml
|
||||
bash dev/add_community.general.sh # only if community.general is not installed
|
||||
ansible-playbook -v -i <hosts file> ansible/playbooks/setup.yml
|
||||
```
|
||||
|
||||
[use this with a docker container](dev/README.md)
|
||||
This playbook can be tested [with a docker container](dev/README.md)
|
||||
|
||||
Use `-e fix_annoyances=true` to fix some small annoyances (only run once)
|
||||
### Manually
|
||||
|
||||
Manually (this only installs the zsh configuration):
|
||||
This requires [antibody](https://github.com/getantibody/antibody) to be installed.
|
||||
|
||||
```bash
|
||||
git clone https://git.decapod.one/brethil/dotfiles ~/.dotfiles
|
||||
echo 'DOTFILES=~/.dotfiles' >> ~/.zshrc
|
||||
echo 'source $DOTFILES/brethil_dotfile.sh'
|
||||
git clone https://git.decapod.one/brethil/dotfiles ~/.dotfiles
|
||||
echo 'DOTFILES=~/.dotfiles' >> ~/.zshrc
|
||||
echo 'source $DOTFILES/brethil_dotfile.sh'
|
||||
ln -s ~/.dotfiles ~/.vimrc
|
||||
```
|
||||
|
||||
## Updating
|
||||
|
||||
A self-update mechanism is included. It asks for confirmation to pull the latest changes
|
||||
from the git repo every two weeks. This also updates the git-sourced repositories installed
|
||||
by the install script. The self-update routine can be called manually by calling
|
||||
|
||||
dotfiles_selfupdate
|
||||
```bash
|
||||
dotfiles_selfupdate
|
||||
```
|
||||
|
||||
If you do not want to run the installer script, you can just add source `brethil_dotfile.sh`
|
||||
in your `.zshrc`. This requires antibody installed.
|
||||
This can be disabling by setting the `DISABLE_DOTFILES_AUTO_UPDATE` env var before before sourcing `brethil_dotfile.sh`
|
||||
|
||||
### Available Functions
|
||||
## Try it out
|
||||
|
||||
0. `cheat`: show cheat sheet for commands using cheat.sh (`cheat <commandname>`)
|
||||
1. Quickly edit/reload profile (`esource`/`resource`)
|
||||
2. `dockertags` list all tags for a given docker image
|
||||
3. `color` to print colored text (see 3. in the Misc section):
|
||||
Docker images are regularly built, and they include a full development environment (hence are quite large)
|
||||
|
||||
color $Red "This will be printed in red"
|
||||
color $Yellow "This will be printed in red"
|
||||
|
||||
4. `mecp` to copy files back to the machine from wich you are ssh-ing.
|
||||
For this to work an ssh tunnel with `Remoteforward` is needed:
|
||||
|
||||
ssh -R 22:localhost:2222 YOURHOSTNAMEHERE
|
||||
|
||||
or specify this in `~/.ssh/config` for a persistent configuration:
|
||||
|
||||
Host YOURHOSTNAMEHERE
|
||||
Remoteforward 2222 localhost:22
|
||||
|
||||
This can be enabled in `~/.ssh/config` globally for all hosts by uncommenting the relevant `Host * Remoteforward`.
|
||||
You might have to manually edit the username in the `mecp` definition in `functions.sh` if this is
|
||||
different between the two machines. `mecp` copies by default on the local machine on `~/Desktop/`
|
||||
|
||||
5. Many more. Use `list_functions` to list defined functions and a small description
|
||||
|
||||
### Files/Folders
|
||||
|
||||
1. `~/bin`, `~/git`, `~/projects` folders
|
||||
2. ssh config (`~/.ssh/config`):
|
||||
- Create ssh keys if not defined already
|
||||
- Keep connections alive by increasing timeout time
|
||||
- Include multiplexer to allow quick multiple connections to the same host
|
||||
- (Optional: Compression, this should allow more responsive shells with slow connections,
|
||||
but will slow things down when copying large files. My suggestion is to have compression enabled
|
||||
on a by-host basis in `~/.ssh/config`)
|
||||
3. `brethil.zsh-theme`, `brethil-minimal.zsh-themes`, themes for oh-my-zsh,
|
||||
symlinked in `$ZSH/custom/themes` (`$ZSH=~/.oh-my-zsh`)
|
||||
4. `~/.dotfiles_functions`, `~/.dotfiles_aliases` are sourced by this dotfiles, allowing for custom functions/aliases
|
||||
5. useful_commands contains a list of useful commands (the first rule of the tautology club...)
|
||||
|
||||
### Misc
|
||||
|
||||
1. Colored output (via `grc`) for several commands.
|
||||
2. Easy names for ANSI color escapes (Black, Red, Green, Yellow, Blue, Cyan, Purple, White, CLEAR), for example:
|
||||
|
||||
echo -e "${Green}This text will be green${CLEAR}"
|
||||
|
||||
will result in green text. Use `$CLEAR` to clear previous escape sequences add B before the variable (check `colors.sh`)
|
||||
name to use **bold** and U to underline (examples: `$BRed`, `$UBlack` for bold red and underlined black)
|
||||
|
||||
3. Autoupdate script running every two weeks, autoupdate function: `dotfiles_selfupdate` (or `git pull` from `$DOTFILES`folder)
|
||||
4. Automatic fix of the`SSH_AUTH_SOCK`environment variable:`~/.ssh/rc` is installed run on every ssh login,
|
||||
and updates a symlink pointing (`~/.ssh/ssh_auth_sock`). `SSH_AUTH_SOCK`points to this (set in`brethil_dotfile.sh`).
|
||||
The idea is that if the user is logging in using `ssh -A`, and using tmux, it will be possible to use
|
||||
the remote socket over different sessions by always using the symlink.
|
||||
```bash
|
||||
docker run -it registry.decapod.one/brethil/dotfiles
|
||||
```
|
||||
|
|
461
ackrc
461
ackrc
|
@ -1,461 +0,0 @@
|
|||
--ignore-file=match:tags
|
||||
--ignore-dir=build
|
||||
--ignore-dir=dist
|
||||
--ignore-dir=node-modules
|
||||
--ignore-dir=.venv
|
||||
--ignore-ack-defaults
|
||||
|
||||
# Vue
|
||||
--type-add=vue:ext:vue
|
||||
|
||||
|
||||
# This is the default ackrc for ack version v3.3.1.
|
||||
|
||||
# There are four different ways to match
|
||||
#
|
||||
# is: Match the filename exactly
|
||||
#
|
||||
# ext: Match the extension of the filename exactly
|
||||
#
|
||||
# match: Match the filename against a Perl regular expression
|
||||
#
|
||||
# firstlinematch: Match the first 250 characters of the first line
|
||||
# of text against a Perl regular expression. This is only for
|
||||
# the --type-add option.
|
||||
|
||||
|
||||
### Directories to ignore
|
||||
|
||||
# Bazaar
|
||||
# https://bazaar.canonical.com/
|
||||
--ignore-directory=is:.bzr
|
||||
|
||||
# Codeville
|
||||
# http://freshmeat.sourceforge.net/projects/codeville
|
||||
--ignore-directory=is:.cdv
|
||||
|
||||
# Interface Builder (Xcode)
|
||||
# https://en.wikipedia.org/wiki/Interface_Builder
|
||||
--ignore-directory=is:~.dep
|
||||
--ignore-directory=is:~.dot
|
||||
--ignore-directory=is:~.nib
|
||||
--ignore-directory=is:~.plst
|
||||
|
||||
# Git
|
||||
# https://git-scm.com/
|
||||
--ignore-directory=is:.git
|
||||
# When submodules are used, .git is a file.
|
||||
--ignore-file=is:.git
|
||||
|
||||
# Mercurial
|
||||
# https://www.mercurial-scm.org/
|
||||
--ignore-directory=is:.hg
|
||||
|
||||
# Quilt
|
||||
# https://directory.fsf.org/wiki/Quilt
|
||||
--ignore-directory=is:.pc
|
||||
|
||||
# Subversion
|
||||
# https://subversion.apache.org/
|
||||
--ignore-directory=is:.svn
|
||||
|
||||
# Monotone
|
||||
# https://www.monotone.ca/
|
||||
--ignore-directory=is:_MTN
|
||||
|
||||
# CVS
|
||||
# https://savannah.nongnu.org/projects/cvs
|
||||
--ignore-directory=is:CVS
|
||||
|
||||
# RCS
|
||||
# https://www.gnu.org/software/rcs/
|
||||
--ignore-directory=is:RCS
|
||||
|
||||
# SCCS
|
||||
# https://en.wikipedia.org/wiki/Source_Code_Control_System
|
||||
--ignore-directory=is:SCCS
|
||||
|
||||
# darcs
|
||||
# http://darcs.net/
|
||||
--ignore-directory=is:_darcs
|
||||
|
||||
# Vault/Fortress
|
||||
--ignore-directory=is:_sgbak
|
||||
|
||||
# autoconf
|
||||
# https://www.gnu.org/software/autoconf/
|
||||
--ignore-directory=is:autom4te.cache
|
||||
|
||||
# Perl module building
|
||||
--ignore-directory=is:blib
|
||||
--ignore-directory=is:_build
|
||||
|
||||
# Perl Devel::Cover module's output directory
|
||||
# https://metacpan.org/release/Devel-Cover
|
||||
--ignore-directory=is:cover_db
|
||||
|
||||
# Node modules created by npm
|
||||
--ignore-directory=is:node_modules
|
||||
|
||||
# CMake cache
|
||||
# https://www.cmake.org/
|
||||
--ignore-directory=is:CMakeFiles
|
||||
|
||||
# Eclipse workspace folder
|
||||
# https://eclipse.org/
|
||||
--ignore-directory=is:.metadata
|
||||
|
||||
# Cabal (Haskell) sandboxes
|
||||
# https://www.haskell.org/cabal/users-guide/installing-packages.html
|
||||
--ignore-directory=is:.cabal-sandbox
|
||||
|
||||
# Python caches
|
||||
# https://docs.python.org/3/tutorial/modules.html
|
||||
--ignore-directory=is:__pycache__
|
||||
--ignore-directory=is:.pytest_cache
|
||||
|
||||
# macOS Finder remnants
|
||||
--ignore-directory=is:__MACOSX
|
||||
--ignore-file=is:.DS_Store
|
||||
|
||||
### Files to ignore
|
||||
|
||||
# Backup files
|
||||
--ignore-file=ext:bak
|
||||
--ignore-file=match:/~$/
|
||||
|
||||
# Emacs swap files
|
||||
--ignore-file=match:/^#.+#$/
|
||||
|
||||
# vi/vim swap files https://www.vim.org/
|
||||
--ignore-file=match:/[._].*[.]swp$/
|
||||
|
||||
# core dumps
|
||||
--ignore-file=match:/core[.]\d+$/
|
||||
|
||||
# minified Javascript
|
||||
--ignore-file=match:/[.-]min[.]js$/
|
||||
--ignore-file=match:/[.]js[.]min$/
|
||||
|
||||
# minified CSS
|
||||
--ignore-file=match:/[.]min[.]css$/
|
||||
--ignore-file=match:/[.]css[.]min$/
|
||||
|
||||
# JS and CSS source maps
|
||||
--ignore-file=match:/[.]js[.]map$/
|
||||
--ignore-file=match:/[.]css[.]map$/
|
||||
|
||||
# PDFs, because they pass Perl's -T detection
|
||||
--ignore-file=ext:pdf
|
||||
|
||||
# Common graphics, just as an optimization
|
||||
--ignore-file=ext:gif,jpg,jpeg,png
|
||||
|
||||
# Common archives, as an optimization
|
||||
--ignore-file=ext:gz,tar,tgz,zip
|
||||
|
||||
# Python compiles modules
|
||||
--ignore-file=ext:pyc,pyd,pyo
|
||||
|
||||
# C extensions
|
||||
--ignore-file=ext:so
|
||||
|
||||
# Compiled gettext files
|
||||
--ignore-file=ext:mo
|
||||
|
||||
### Filetypes defined
|
||||
|
||||
# Makefiles
|
||||
# https://www.gnu.org/s/make/
|
||||
--type-add=make:ext:mk
|
||||
--type-add=make:ext:mak
|
||||
--type-add=make:is:makefile
|
||||
--type-add=make:is:Makefile
|
||||
--type-add=make:is:Makefile.Debug
|
||||
--type-add=make:is:Makefile.Release
|
||||
--type-add=make:is:GNUmakefile
|
||||
|
||||
# Rakefiles
|
||||
# https://rake.rubyforge.org/
|
||||
--type-add=rake:is:Rakefile
|
||||
|
||||
# CMake
|
||||
# https://cmake.org/
|
||||
--type-add=cmake:is:CMakeLists.txt
|
||||
--type-add=cmake:ext:cmake
|
||||
|
||||
# Actionscript
|
||||
--type-add=actionscript:ext:as,mxml
|
||||
|
||||
# Ada
|
||||
# https://www.adaic.org/
|
||||
--type-add=ada:ext:ada,adb,ads
|
||||
|
||||
# ASP
|
||||
# https://docs.microsoft.com/en-us/previous-versions/office/developer/server-technologies/aa286483(v=msdn.10)
|
||||
--type-add=asp:ext:asp
|
||||
|
||||
# ASP.Net
|
||||
# https://dotnet.microsoft.com/apps/aspnet
|
||||
--type-add=aspx:ext:master,ascx,asmx,aspx,svc
|
||||
|
||||
# Assembly
|
||||
--type-add=asm:ext:asm,s
|
||||
|
||||
# DOS/Windows batch
|
||||
--type-add=batch:ext:bat,cmd
|
||||
|
||||
# ColdFusion
|
||||
# https://en.wikipedia.org/wiki/ColdFusion
|
||||
--type-add=cfmx:ext:cfc,cfm,cfml
|
||||
|
||||
# Clojure
|
||||
# https://clojure.org/
|
||||
--type-add=clojure:ext:clj,cljs,edn,cljc
|
||||
|
||||
# C
|
||||
# .xs are Perl C files
|
||||
--type-add=cc:ext:c,h,xs
|
||||
|
||||
# C header files
|
||||
--type-add=hh:ext:h
|
||||
|
||||
# CoffeeScript
|
||||
# https://coffeescript.org/
|
||||
--type-add=coffeescript:ext:coffee
|
||||
|
||||
# C++
|
||||
--type-add=cpp:ext:cpp,cc,cxx,m,hpp,hh,h,hxx
|
||||
|
||||
# C++ header files
|
||||
--type-add=hpp:ext:hpp,hh,h,hxx
|
||||
|
||||
# C#
|
||||
--type-add=csharp:ext:cs
|
||||
|
||||
# CSS
|
||||
# https://www.w3.org/Style/CSS/
|
||||
--type-add=css:ext:css
|
||||
|
||||
# Dart
|
||||
# https://dart.dev/
|
||||
--type-add=dart:ext:dart
|
||||
|
||||
# Delphi
|
||||
# https://en.wikipedia.org/wiki/Embarcadero_Delphi
|
||||
--type-add=delphi:ext:pas,int,dfm,nfm,dof,dpk,dproj,groupproj,bdsgroup,bdsproj
|
||||
|
||||
# Elixir
|
||||
# https://elixir-lang.org/
|
||||
--type-add=elixir:ext:ex,exs
|
||||
|
||||
# Emacs Lisp
|
||||
# https://www.gnu.org/software/emacs
|
||||
--type-add=elisp:ext:el
|
||||
|
||||
# Erlang
|
||||
# https://www.erlang.org/
|
||||
--type-add=erlang:ext:erl,hrl
|
||||
|
||||
# Fortran
|
||||
# https://en.wikipedia.org/wiki/Fortran
|
||||
--type-add=fortran:ext:f,f77,f90,f95,f03,for,ftn,fpp
|
||||
|
||||
# Go
|
||||
# https://golang.org/
|
||||
--type-add=go:ext:go
|
||||
|
||||
# Groovy
|
||||
# https://www.groovy-lang.org/
|
||||
--type-add=groovy:ext:groovy,gtmpl,gpp,grunit,gradle
|
||||
|
||||
# GSP
|
||||
# https://gsp.grails.org/
|
||||
--type-add=gsp:ext:gsp
|
||||
|
||||
# Haskell
|
||||
# https://www.haskell.org/
|
||||
--type-add=haskell:ext:hs,lhs
|
||||
|
||||
# HTML
|
||||
--type-add=html:ext:htm,html,xhtml
|
||||
|
||||
# Jade
|
||||
# http://jade-lang.com/
|
||||
--type-add=jade:ext:jade
|
||||
|
||||
# Java
|
||||
# https://www.oracle.com/technetwork/java/index.html
|
||||
--type-add=java:ext:java,properties
|
||||
|
||||
# JavaScript
|
||||
--type-add=js:ext:js
|
||||
|
||||
# JSP
|
||||
# https://www.oracle.com/technetwork/java/javaee/jsp/index.html
|
||||
--type-add=jsp:ext:jsp,jspx,jspf,jhtm,jhtml
|
||||
|
||||
# JSON
|
||||
# https://json.org/
|
||||
--type-add=json:ext:json
|
||||
|
||||
# Kotlin
|
||||
# https://kotlinlang.org/
|
||||
--type-add=kotlin:ext:kt,kts
|
||||
|
||||
# Less
|
||||
# http://www.lesscss.org/
|
||||
--type-add=less:ext:less
|
||||
|
||||
# Common Lisp
|
||||
# https://common-lisp.net/
|
||||
--type-add=lisp:ext:lisp,lsp
|
||||
|
||||
# Lua
|
||||
# https://www.lua.org/
|
||||
--type-add=lua:ext:lua
|
||||
--type-add=lua:firstlinematch:/^#!.*\blua(jit)?/
|
||||
|
||||
# Markdown
|
||||
# https://en.wikipedia.org/wiki/Markdown
|
||||
--type-add=markdown:ext:md,markdown
|
||||
# We understand that there are many ad hoc extensions for markdown
|
||||
# that people use. .md and .markdown are the two that ack recognizes.
|
||||
# You are free to add your own in your ackrc file.
|
||||
|
||||
# Matlab
|
||||
# https://en.wikipedia.org/wiki/MATLAB
|
||||
--type-add=matlab:ext:m
|
||||
|
||||
# Objective-C
|
||||
--type-add=objc:ext:m,h
|
||||
|
||||
# Objective-C++
|
||||
--type-add=objcpp:ext:mm,h
|
||||
|
||||
# OCaml
|
||||
# https://ocaml.org/
|
||||
--type-add=ocaml:ext:ml,mli,mll,mly
|
||||
|
||||
# Perl
|
||||
# https://perl.org/
|
||||
--type-add=perl:ext:pl,pm,pod,t,psgi
|
||||
--type-add=perl:firstlinematch:/^#!.*\bperl/
|
||||
|
||||
# Perl tests
|
||||
--type-add=perltest:ext:t
|
||||
|
||||
# Perl's Plain Old Documentation format, POD
|
||||
--type-add=pod:ext:pod
|
||||
|
||||
# PHP
|
||||
# https://www.php.net/
|
||||
--type-add=php:ext:php,phpt,php3,php4,php5,phtml
|
||||
--type-add=php:firstlinematch:/^#!.*\bphp/
|
||||
|
||||
# Plone
|
||||
# https://plone.org/
|
||||
--type-add=plone:ext:pt,cpt,metadata,cpy,py
|
||||
|
||||
# Python
|
||||
# https://www.python.org/
|
||||
--type-add=python:ext:py
|
||||
--type-add=python:firstlinematch:/^#!.*\bpython/
|
||||
|
||||
# R
|
||||
# https://www.r-project.org/
|
||||
--type-add=rr:ext:R
|
||||
|
||||
# reStructured Text
|
||||
# https://docutils.sourceforge.io/rst.html
|
||||
--type-add=rst:ext:rst
|
||||
|
||||
# Ruby
|
||||
# https://www.ruby-lang.org/
|
||||
--type-add=ruby:ext:rb,rhtml,rjs,rxml,erb,rake,spec
|
||||
--type-add=ruby:is:Rakefile
|
||||
--type-add=ruby:firstlinematch:/^#!.*\bruby/
|
||||
|
||||
# Rust
|
||||
# https://www.rust-lang.org/
|
||||
--type-add=rust:ext:rs
|
||||
|
||||
# Sass
|
||||
# https://sass-lang.com
|
||||
--type-add=sass:ext:sass,scss
|
||||
|
||||
# Scala
|
||||
# https://www.scala-lang.org/
|
||||
--type-add=scala:ext:scala
|
||||
|
||||
# Scheme
|
||||
# https://groups.csail.mit.edu/mac/projects/scheme/
|
||||
--type-add=scheme:ext:scm,ss
|
||||
|
||||
# Shell
|
||||
--type-add=shell:ext:sh,bash,csh,tcsh,ksh,zsh,fish
|
||||
--type-add=shell:firstlinematch:/^#!.*\b(?:ba|t?c|k|z|fi)?sh\b/
|
||||
|
||||
# Smalltalk
|
||||
# http://www.smalltalk.org/
|
||||
--type-add=smalltalk:ext:st
|
||||
|
||||
# Smarty
|
||||
# https://www.smarty.net/
|
||||
--type-add=smarty:ext:tpl
|
||||
|
||||
# SQL
|
||||
# https://www.iso.org/standard/45498.html
|
||||
--type-add=sql:ext:sql,ctl
|
||||
|
||||
# Stylus
|
||||
# http://stylus-lang.com/
|
||||
--type-add=stylus:ext:styl
|
||||
|
||||
# SVG
|
||||
# https://en.wikipedia.org/wiki/Scalable_Vector_Graphics
|
||||
--type-add=svg:ext:svg
|
||||
|
||||
# Swift
|
||||
# https://developer.apple.com/swift/
|
||||
--type-add=swift:ext:swift
|
||||
--type-add=swift:firstlinematch:/^#!.*\bswift/
|
||||
|
||||
# Tcl
|
||||
# https://www.tcl.tk/
|
||||
--type-add=tcl:ext:tcl,itcl,itk
|
||||
|
||||
# TeX & LaTeX
|
||||
# https://www.latex-project.org/
|
||||
--type-add=tex:ext:tex,cls,sty
|
||||
|
||||
# Template Toolkit (Perl)
|
||||
# http//template-toolkit.org/
|
||||
--type-add=ttml:ext:tt,tt2,ttml
|
||||
|
||||
# Typescript
|
||||
# https://www.typescriptlang.org/
|
||||
--type-add=ts:ext:ts,tsx
|
||||
|
||||
# Visual Basic
|
||||
--type-add=vb:ext:bas,cls,frm,ctl,vb,resx
|
||||
|
||||
# Verilog
|
||||
--type-add=verilog:ext:v,vh,sv
|
||||
|
||||
# VHDL
|
||||
# http://www.eda.org/twiki/bin/view.cgi/P1076/WebHome
|
||||
--type-add=vhdl:ext:vhd,vhdl
|
||||
|
||||
# Vim
|
||||
# https://www.vim.org/
|
||||
--type-add=vim:ext:vim
|
||||
|
||||
# XML
|
||||
# https://www.w3.org/TR/REC-xml/
|
||||
--type-add=xml:ext:xml,dtd,xsd,xsl,xslt,ent,wsdl
|
||||
--type-add=xml:firstlinematch:/<[?]xml/
|
||||
|
||||
# YAML
|
||||
# https://yaml.org/
|
||||
--type-add=yaml:ext:yaml,yml
|
101
aliases.sh
101
aliases.sh
|
@ -1,101 +0,0 @@
|
|||
###########################
|
||||
#### ALIAS #
|
||||
###########################
|
||||
|
||||
####
|
||||
#### Easier life (MAC SPECIFIC)
|
||||
####
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
alias o="open"
|
||||
alias ls="ls -G"
|
||||
## Colorize system.log contents (with grc), and inspect with less.
|
||||
alias console="grc cat /var/log/system.log | sort -r | less -R"
|
||||
|
||||
## Quicklook shortcut
|
||||
alias quicklook='qlmanage -px 2>/dev/null'
|
||||
alias ql='quicklook'
|
||||
|
||||
## Airport command line interface
|
||||
alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport'
|
||||
|
||||
## Flush dns cache
|
||||
#alias dnsflushcache='sudo discoveryutil mdnsflushcache' # used to work until 10.6
|
||||
alias dnsflushcache='sudo killall -HUP mDNSResponder' # Works up until 10.9 and after 10.10.4
|
||||
alias lsrt='ls -G -lrt | tail -5'
|
||||
else
|
||||
alias ls='ls --color'
|
||||
fi
|
||||
|
||||
####
|
||||
#### Easier life (everything)
|
||||
alias dot="cd $DOTFILES"
|
||||
#### Audible bell
|
||||
alias bell='echo -en "\007"'
|
||||
|
||||
alias grep="grep --colour=auto"
|
||||
|
||||
##############
|
||||
## ls aliases
|
||||
############
|
||||
# ls -al, only show files that start with a dot
|
||||
alias lsdot="ls -al | awk '\$9 ~ /^\./ {print \$0}'"
|
||||
|
||||
alias lt='ls -lrt | tail -10'
|
||||
alias ll='ls -lhL' #long ls output
|
||||
|
||||
alias ka="killall"
|
||||
|
||||
alias ipy='ipython'
|
||||
alias ipyl='ipython --pylab'
|
||||
|
||||
## Show the last 10 modified files
|
||||
if [[ ! "$(uname)" == "Darwin" ]]; then
|
||||
alias lsrt="ls -lrt | tail -10"
|
||||
fi
|
||||
|
||||
## Stress one CPU core
|
||||
alias stress='yes >> /dev/null'
|
||||
|
||||
# define ssh without controlmaster
|
||||
alias ssh1="ssh -o ControlMaster=no"
|
||||
|
||||
# git: useful_stuff
|
||||
alias git_sort_branches_by_date="git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'"
|
||||
alias gl5='git log -n 5'
|
||||
|
||||
alias pvim='poetry run vim'
|
||||
|
||||
# grc: try to source the definitions file in /etc/grc.zsh (print a warning if it does not exist)
|
||||
if [[ -f /etc/grc.zsh ]] ; then
|
||||
source /etc/grc.zsh
|
||||
elif [[ -f /usr/local/etc/grc.zsh ]] ; then
|
||||
source /usr/local/etc/grc.zsh
|
||||
else
|
||||
echo "Could not grc completion file (checked /etc/grc.zsh and /usr/local/etc/grc.zsh. Command colorization will not work. Check your grc configuration (is grc installed?)" 1>&2
|
||||
fi
|
||||
|
||||
alias powerline_update="pip install --upgrade --user 'git+https://github.com/powerline/powerline.git@develop#powerline'"
|
||||
|
||||
alias gcf='git commit --fixup=HEAD'
|
||||
alias gcaf='git commit -a --fixup=HEAD'
|
||||
alias gls="git log --pretty=oneline --abbrev-commit" # gls: Git Log Short
|
||||
|
||||
alias watcha='watch ' # note the space after watch. This makes watch work with aliases
|
||||
|
||||
# A short version of docker ps
|
||||
alias dps='docker ps --format "table {{.Image}}\t{{.RunningFor}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}"'
|
||||
# Get ip for a docker container, usage: `docker inspect <container> | dockerip`
|
||||
alias dockerip="jq -r '.[].NetworkSettings.Networks.bridge.IPAddress'"
|
||||
|
||||
alias pvim='poetry run vim'
|
||||
alias pshell='poetry shell'
|
||||
|
||||
# dotfiles user aliases
|
||||
if [[ -f ~/.dotfiles_aliases ]]; then
|
||||
source $HOME/.dotfiles_aliases
|
||||
fi
|
||||
|
||||
# source ssh aliases
|
||||
if [[ -f $HOME/.ssh_aliases ]]; then
|
||||
source $HOME/.ssh_aliases
|
||||
fi
|
|
@ -0,0 +1,4 @@
|
|||
# aliases
|
||||
|
||||
Place custom alias definitions in this folder, with a `.zsh` extension.
|
||||
These files will be sourced on startup
|
|
@ -0,0 +1,88 @@
|
|||
###########################
|
||||
#### ALIAS #
|
||||
###########################
|
||||
|
||||
####
|
||||
#### Easier life (MAC SPECIFIC)
|
||||
####
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
alias o="open"
|
||||
alias ls="ls -G"
|
||||
## Colorize system.log contents (with grc), and inspect with less.
|
||||
alias console="grc cat /var/log/system.log | sort -r | less -R"
|
||||
|
||||
## Quicklook shortcut
|
||||
alias quicklook='qlmanage -px 2>/dev/null'
|
||||
alias ql='quicklook'
|
||||
|
||||
## Airport command line interface
|
||||
alias airport='/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport'
|
||||
|
||||
## Flush dns cache
|
||||
#alias dnsflushcache='sudo discoveryutil mdnsflushcache' # used to work until 10.6
|
||||
alias dnsflushcache='sudo killall -HUP mDNSResponder' # Works up until 10.9 and after 10.10.4
|
||||
alias lsrt='ls -G -lrt | tail -5'
|
||||
else
|
||||
alias ls='ls --color'
|
||||
fi
|
||||
|
||||
####
|
||||
#### Easier life (everything)
|
||||
alias dot="cd $DOTFILES"
|
||||
#### Audible bell
|
||||
alias bell='echo -en "\007"'
|
||||
|
||||
alias grep="grep --colour=auto"
|
||||
alias grepi="grep -i"
|
||||
|
||||
##############
|
||||
## ls aliases
|
||||
############
|
||||
# ls -al, only show files that start with a dot
|
||||
alias lsdot="ls -al | awk '\$9 ~ /^\./ {print \$0}'"
|
||||
|
||||
alias lt='ls -lrt | tail -10'
|
||||
alias ll='ls -lhL' #long ls output
|
||||
|
||||
alias ka="killall"
|
||||
|
||||
alias ipy='ipython'
|
||||
alias ipyl='ipython --pylab'
|
||||
alias treep='tree -I __pycache__'
|
||||
|
||||
## Show the last 10 modified files
|
||||
if [[ ! "$(uname)" == "Darwin" ]]; then
|
||||
alias lsrt="ls -lrt | tail -10"
|
||||
fi
|
||||
|
||||
## Stress one CPU core
|
||||
alias stress='yes >> /dev/null'
|
||||
|
||||
# ssh forcing a new connection (no persistent)
|
||||
alias ssh1="ssh -o ControlMaster=yes -o ControlPersist=no"
|
||||
|
||||
alias watcha='watch ' # note the space after watch. This makes watch work with aliases
|
||||
|
||||
# A short version of docker ps
|
||||
alias dps='docker ps --format "table {{.Image}}\t{{.RunningFor}}\t{{.Status}}\t{{.Ports}}\t{{.Names}}"'
|
||||
# Get ip for a docker container, usage: `docker inspect <container> | dockerip`
|
||||
alias dockerip="jq -r '.[].NetworkSettings.Networks.bridge.IPAddress'"
|
||||
|
||||
alias pvim='poetry run vim'
|
||||
alias pshell='poetry shell'
|
||||
alias venv='source .venv/bin/activate'
|
||||
|
||||
# Run fzf with file preview
|
||||
alias pf="fzf --preview='BAT_STYLE='header,changes' bat --color=always {}' --bind shift-up:preview-page-up,shift-down:preview-page-down"
|
||||
|
||||
# dvc
|
||||
alias dst='dvc status'
|
||||
alias dstc='dvc status --cloud'
|
||||
alias drp='dvc repro'
|
||||
alias drps='dvc repro -s'
|
||||
|
||||
alias -g J="| jq "
|
||||
|
||||
# These two depend on oh-my-zsh's clipcopy/clippaste functions
|
||||
alias -g C='| clipcopy'
|
||||
alias -g P='clippaste'
|
|
@ -0,0 +1,8 @@
|
|||
# git: useful_stuff
|
||||
alias git-sort-branches-by-date="git for-each-ref --sort=committerdate refs/heads/ --format='%(committerdate:short) %(refname:short)'"
|
||||
alias gswr="git-switch-recent-branch" # defined in functions/git.zsh
|
||||
alias gl5='git log -n 5'
|
||||
alias gs='git status'
|
||||
alias gcfx='git-fixup'
|
||||
alias gls="git log --pretty=oneline --abbrev-commit" # gls: Git Log Short
|
||||
alias glsu='git ls-files --others --exclude-standard'
|
|
@ -1,25 +1,32 @@
|
|||
packages:
|
||||
- "vim"
|
||||
- "curl"
|
||||
- "git"
|
||||
- "zsh"
|
||||
- "grc"
|
||||
- "ccze"
|
||||
- "bmon"
|
||||
- "mtr"
|
||||
- "tmux"
|
||||
- "tree"
|
||||
- "byobu"
|
||||
- "ccze"
|
||||
- "curl"
|
||||
- "fzf"
|
||||
- "git"
|
||||
- "grc"
|
||||
- "htop"
|
||||
- "nmap"
|
||||
- "bmon"
|
||||
- "ripgrep"
|
||||
- "tmux"
|
||||
- "tree"
|
||||
- "vim"
|
||||
- "zsh"
|
||||
- "iotop"
|
||||
packages_debian:
|
||||
- "pylint"
|
||||
- "ipython3"
|
||||
- "python3-pip"
|
||||
- "python3-setuptools"
|
||||
- "virtualenv"
|
||||
- "bat"
|
||||
- "mtr-tiny"
|
||||
packages_archlinux:
|
||||
- "man"
|
||||
- "ipython"
|
||||
- "python-pylint"
|
||||
- "python-virtualenv"
|
||||
- "bash-language-server"
|
||||
- "bat"
|
||||
- "mtr"
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
---
|
||||
- hosts: all
|
||||
become: true
|
||||
- name: Setup dotfiles
|
||||
hosts: all
|
||||
vars_files:
|
||||
- ../ansible-packages.yml
|
||||
vars:
|
||||
DOTFILES: "$HOME/.dotfiles"
|
||||
dotfiles_path: "$HOME/.dotfiles"
|
||||
|
||||
tasks:
|
||||
- name: Install required system packages (debian)
|
||||
|
@ -13,72 +13,20 @@
|
|||
update_cache: yes
|
||||
pkg: "{{ packages + packages_debian }}"
|
||||
when: ansible_facts['os_family'] == "Debian"
|
||||
become: true
|
||||
|
||||
- name: Install required system packages (debian)
|
||||
- name: Install required system packages (arch)
|
||||
pacman:
|
||||
update_cache: yes
|
||||
name: "{{ packages + packages_archlinux }}"
|
||||
when: ansible_facts['os_family'] == "Archlinux"
|
||||
become: true
|
||||
|
||||
- name: dotfiles repo
|
||||
- name: Clone dotfiles repo
|
||||
git:
|
||||
repo: https://git.decapod.one/brethil/dotfiles
|
||||
dest: "{{ DOTFILES }}"
|
||||
version: master
|
||||
|
||||
- name: antibody
|
||||
shell: |
|
||||
set -o pipefail
|
||||
curl -sfL https://git.io/antibody | sh -s - -b /usr/local/bin
|
||||
antibody bundle "{{ DOTFILES }}/antibody_plugins.txt"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: /usr/local/bin/antibody
|
||||
|
||||
- name: zsh as default shell
|
||||
user:
|
||||
name: "{{ ansible_user }}"
|
||||
shell: /usr/bin/zsh
|
||||
|
||||
- name: zsh config
|
||||
shell: |
|
||||
echo "export DOTFILES={{ DOTFILES }}" >> "$HOME/.zshrc"
|
||||
echo 'source $DOTFILES/brethil_dotfile.sh' >> "$HOME/.zshrc"
|
||||
args:
|
||||
creates: "~{{ ansible_user }}/.zshrc"
|
||||
|
||||
- name: dotfiles symlink
|
||||
file:
|
||||
src: "{{ DOTFILES }}/{{ item.key }}"
|
||||
dest: "{{ item.value }}"
|
||||
state: link
|
||||
force: yes
|
||||
loop: "{{ files | dict2items }}"
|
||||
vars:
|
||||
files:
|
||||
"ackrc": "~/.ackrc"
|
||||
"vim/vimrc": "~/.vimrc"
|
||||
"pdbrc.py": "~/.pdbrc.py"
|
||||
# "ipython": "~/.ipython" # FIXME: ipython config is more complex
|
||||
"ansible.cfg": "~/.ansible.cfg"
|
||||
|
||||
- name: git config
|
||||
community.general.git_config:
|
||||
name: "include.path"
|
||||
value: "{{ DOTFILES }}/gitconfig"
|
||||
|
||||
- name: annoyances
|
||||
shell: |
|
||||
## Fix scrolling in byobu
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
sed -i '' 's/set -g terminal-overrides/#set -g terminal-overrides/' /usr/share/byobu/profiles/tmux
|
||||
else
|
||||
sed -i 's/set -g terminal-overrides/#set -g terminal-overrides/' /usr/share/byobu/profiles/tmux
|
||||
fi
|
||||
sed 's|ls \\|#ls \\|' /etc/grc.zsh
|
||||
args:
|
||||
executable: /bin/bash
|
||||
when: fix_annoyances is true
|
||||
dest: "{{ dotfiles_path }}"
|
||||
when: local_development is not defined
|
||||
|
||||
- name: directories
|
||||
file:
|
||||
|
@ -91,3 +39,99 @@
|
|||
- "$HOME/bin"
|
||||
- "$HOME/projects"
|
||||
- "$HOME/git"
|
||||
- "$HOME/.config/git"
|
||||
- "$HOME/.ssh/"
|
||||
- "$HOME/.ssh/sockets"
|
||||
|
||||
- name: Install antibody
|
||||
shell: |
|
||||
set -euo pipefail
|
||||
curl -sfL https://git.io/antibody | sh -s - -b $HOME/bin/
|
||||
$HOME/bin/antibody bundle "{{ dotfiles_path }}/antibody_plugins.txt"
|
||||
args:
|
||||
executable: /bin/bash
|
||||
creates: bin/antibody
|
||||
|
||||
- name: Set zsh as default shell
|
||||
user:
|
||||
name: "{{ ansible_user }}"
|
||||
shell: /usr/bin/zsh
|
||||
become: true
|
||||
|
||||
- name: Update zshrc
|
||||
blockinfile:
|
||||
path: $HOME/.zshrc
|
||||
marker: "# {mark} brethil dotfiles"
|
||||
block: |
|
||||
export DOTFILES={{ dotfiles_path }}
|
||||
source $DOTFILES/brethil_dotfile.sh
|
||||
create: true
|
||||
mode: 600
|
||||
|
||||
- name: Update .ssh/config
|
||||
blockinfile:
|
||||
path: $HOME/.ssh/config
|
||||
marker: "# {mark} brethil dotfiles"
|
||||
insertbefore: "BOF"
|
||||
block: |
|
||||
TCPKeepAlive=yes
|
||||
ServerAliveCountMax=6
|
||||
## Uncomment to enable compression for all ssh sessions
|
||||
#Compression=yes
|
||||
|
||||
ControlMaster auto
|
||||
ControlPath ~/.ssh/sockets/%r@%n:%p
|
||||
ControlPersist yes
|
||||
|
||||
Host *
|
||||
ServerAliveInterval 300
|
||||
create: true
|
||||
|
||||
- name: dotfiles symlinks
|
||||
file:
|
||||
src: "{{ dotfiles_path }}/{{ item.key }}"
|
||||
dest: "{{ item.value }}"
|
||||
state: link
|
||||
force: yes
|
||||
loop: "{{ files | dict2items }}"
|
||||
vars:
|
||||
files:
|
||||
"tmux.conf": "~/.tmux.conf"
|
||||
"vim/vimrc": "~/.vimrc"
|
||||
"pdbrc.py": "~/.pdbrc.py"
|
||||
# "ipython": "~/.ipython" # FIXME: ipython config is more complex
|
||||
"ansible/ansible.cfg": "~/.ansible.cfg"
|
||||
"gitignore": "~/.config/git/ignore"
|
||||
|
||||
- name: Exec vim undodir migration (if required)
|
||||
command: |
|
||||
mv ${HOME}/.vim_runtime/temp_dirs/undodir ${HOME}/.vim/undo
|
||||
args:
|
||||
removes: .vim_runtime/temp_dirs/undodir
|
||||
|
||||
- name: Install vim plugins
|
||||
command: |
|
||||
env DOTFILES={{ dotfiles_path }} vim -c 'PlugInstall|qa!'
|
||||
args:
|
||||
creates: .vim/vim-plug
|
||||
|
||||
- name: Get git config facts
|
||||
community.general.git_config:
|
||||
name: "include.path"
|
||||
scope: global
|
||||
register: config_value
|
||||
- debug:
|
||||
msg: "Git config include.path={{ config_value }}"
|
||||
|
||||
- name: Set up git config include if required
|
||||
community.general.git_config:
|
||||
name: "include.path"
|
||||
value: "{{ dotfiles_path }}/gitconfig"
|
||||
scope: global
|
||||
when: config_value is not defined
|
||||
|
||||
- name: git global .gitignore
|
||||
copy:
|
||||
src: ../../gitignore
|
||||
dest: ~/.gitignore
|
||||
mode: "0600"
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
---
|
||||
- hosts: all
|
||||
become: true
|
||||
vars:
|
||||
DOTFILES: "$HOME/.dotfiles"
|
||||
|
||||
tasks:
|
||||
- name: dotfiles
|
||||
ansible.builtin.command: git pull --rebase --autostash
|
||||
args:
|
||||
chdir: "{{ DOTFILES }}"
|
||||
|
||||
- name: antibody
|
||||
command: antibody update
|
||||
|
||||
- name: vim
|
||||
ansible.builtin.shell: DOTFILES={{DOTFILES}} vim -c 'PlugUpdate|qa!'
|
||||
|
||||
- name: check gitignore migration
|
||||
stat: path=${HOME}/.gitignore
|
||||
register: gitignore
|
||||
|
||||
- name: gitignore migration
|
||||
command: mkdir -p ${HOME}/.config/git && ln -s ${DOTFILES}/gitignore ${HOME}/.config/git/ignore && rm -f ~/.gitignore
|
||||
when: gitignore.stat.exists
|
|
@ -0,0 +1,49 @@
|
|||
---
|
||||
- hosts: all
|
||||
|
||||
tasks:
|
||||
- name: Build directory
|
||||
shell:
|
||||
cmd: mkdir /home/build
|
||||
creates: /home/build
|
||||
register: build_dir
|
||||
|
||||
- name: Prepare build dir
|
||||
shell: |
|
||||
chgrp nobody /home/build
|
||||
chmod g+ws /home/build
|
||||
when:
|
||||
- build_dir is defined
|
||||
|
||||
- name: yay repo
|
||||
become: yes
|
||||
become_method: sudo
|
||||
become_user: nobody
|
||||
git:
|
||||
repo: https://aur.archlinux.org/yay.git
|
||||
dest: /home/build/yay
|
||||
version: master
|
||||
register: repo
|
||||
|
||||
- name: Install go (yay dependency)
|
||||
community.general.pacman:
|
||||
name:
|
||||
- go
|
||||
state: present
|
||||
|
||||
- name: build
|
||||
become: yes
|
||||
become_method: sudo
|
||||
become_user: nobody
|
||||
shell: |
|
||||
cd /home/build/yay
|
||||
makepkg
|
||||
environment:
|
||||
- GOCACHE: /home/build
|
||||
- ANSIBLE_REMOTE_TMP: /home/build
|
||||
|
||||
- name: Install yay
|
||||
community.general.pacman:
|
||||
name:
|
||||
- /home/build/yay/yay-*.tar.zst
|
||||
state: present
|
|
@ -1,16 +0,0 @@
|
|||
robbyrussell/oh-my-zsh
|
||||
robbyrussell/oh-my-zsh path:plugins/colored-man-pages
|
||||
robbyrussell/oh-my-zsh path:plugins/common-aliases
|
||||
robbyrussell/oh-my-zsh path:plugins/docker
|
||||
robbyrussell/oh-my-zsh path:plugins/docker-compose
|
||||
robbyrussell/oh-my-zsh path:plugins/git
|
||||
#robbyrussell/oh-my-zsh path:plugins/kubectl
|
||||
robbyrussell/oh-my-zsh path:plugins/sudo
|
||||
robbyrussell/oh-my-zsh path:plugins/vi-mode
|
||||
robbyrussell/oh-my-zsh path:plugins/pyenv
|
||||
djui/alias-tips
|
||||
psprint/zsh-navigation-tools
|
||||
zdharma/fast-syntax-highlighting
|
||||
zsh-users/zsh-autosuggestions
|
||||
zsh-users/zsh-completions
|
||||
MichaelAquilina/zsh-autoswitch-virtualenv
|
|
@ -1,2 +0,0 @@
|
|||
robbyrussell/oh-my-zsh path:plugins/systemd
|
||||
robbyrussell/oh-my-zsh path:plugins/archlinux
|
|
@ -1,5 +1,5 @@
|
|||
# Check for update, set DISABLE_UPDATE_PROMPT=yes to disable the prompt and automatically update
|
||||
env DISABLE_UPDATE_PROMPT=$DISABLE_UPDATE_PROMPT DOTFILES="$DOTFILES" zsh -f "$DOTFILES/check_for_update.sh"
|
||||
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||
export LANG=en_US.UTF-8
|
||||
|
||||
# theme-related variables
|
||||
export ZSH_CUSTOM="$DOTFILES"
|
||||
|
@ -7,15 +7,68 @@ export ZSH_THEME="brethil"
|
|||
export DISABLE_UNTRACKED_FILES_DIRTY=true
|
||||
export VIRTUAL_ENV_DISABLE_PROMPT=true
|
||||
|
||||
# Source all other plugins
|
||||
source <(antibody init)
|
||||
antibody bundle < "$DOTFILES/antibody_plugins.txt"
|
||||
export ZSH="$(antibody path robbyrussell/oh-my-zsh)"
|
||||
uname="$(uname -a)"
|
||||
if [[ $uname == *"ARCH"* || $uname == *"MANJARO"* ]]; then
|
||||
antibody bundle < "$DOTFILES/antibody_plugins_arch.txt"
|
||||
export PATH=$PATH:$HOME/bin
|
||||
|
||||
if [[ -d "$HOME/.cache/antibody" ]]; then
|
||||
# antibody migration cleanup
|
||||
rm -rf $HOME/.cache/antibody
|
||||
fi
|
||||
|
||||
if [[ ! -d $DOTFILES/antidote ]]; then
|
||||
git clone https://github.com/mattmc3/antidote.git ${DOTFILES}/antidote
|
||||
fi
|
||||
|
||||
export ZSH_CACHE_DIR="${XDG_CACHE_HOME:-$HOME/.cache}/oh-my-zsh"
|
||||
[[ -d $ZSH_CACHE_DIR ]] || mkdir -p $ZSH_CACHE_DIR/completions
|
||||
|
||||
# Lazy-load antidote from its functions directory.
|
||||
fpath=($DOTFILES/antidote/functions/ $fpath)
|
||||
autoload -Uz antidote
|
||||
|
||||
autoload -Uz compinit && compinit
|
||||
autoload -Uz bashcompinit && bashcompinit
|
||||
|
||||
|
||||
# Lazy-load antidote and generate the static load file only when needed # TODO: look into deferred loading with zsh-defer
|
||||
zsh_plugins="$DOTFILES/zsh_plugins"
|
||||
if [[ ! ${zsh_plugins}.zsh -nt ${zsh_plugins}.txt ]]; then
|
||||
(
|
||||
source $DOTFILES/antidote/antidote.zsh
|
||||
|
||||
echo "ZSH=$(antidote path ohmyzsh/ohmyzsh)" >${zsh_plugins}.zsh
|
||||
|
||||
antidote bundle <${zsh_plugins}.txt >>${zsh_plugins}.zsh
|
||||
|
||||
if (( $+commands[systemctl] )); then
|
||||
antidote bundle robbyrussell/oh-my-zsh path:plugins/systemd >>${zsh_plugins}.zsh
|
||||
fi
|
||||
if (( $+commands[pacman] )); then
|
||||
antidote bundle robbyrussell/oh-my-zsh path:plugins/archlinux >>${zsh_plugins}.zsh
|
||||
elif (( $+commands[apt-get] )); then
|
||||
antidote bundle robbyrussell/oh-my-zsh path:plugins/debian >>${zsh_plugins}.zsh
|
||||
fi
|
||||
|
||||
)
|
||||
fi
|
||||
|
||||
source ${zsh_plugins}.zsh
|
||||
source "$DOTFILES/themes/brethil.zsh-theme"
|
||||
|
||||
|
||||
# Setup completion style
|
||||
source $DOTFILES/extras/completion_style.zsh
|
||||
source $DOTFILES/extras/colors.zsh
|
||||
source $DOTFILES/extras/fzf-tab-config.zsh
|
||||
|
||||
if (( $+commands[fd] )); then
|
||||
export FZF_CTRL_T_COMMAND='fd'
|
||||
else
|
||||
export FZF_CTRL_T_COMMAND='find'
|
||||
fi
|
||||
export FZF_CTRL_T_OPTS=" --preview-window=right,60% --preview \"bash -c 'if [[ -d \"{}\" ]]; then tree -C \"{}\"; else bat --style=plain --color=always \"{}\"; fi'\" --bind 'ctrl-/:change-preview-window(right,70%|down,40%,border-horizontal|hidden|right)'"
|
||||
|
||||
ZSH_HIGHLIGHT_STYLES[comment]='fg=white,bg=gray,bold'
|
||||
|
||||
# Enable zsh autocorrection
|
||||
setopt CORRECT_ALL
|
||||
|
||||
|
@ -30,52 +83,102 @@ setopt INC_APPEND_HISTORY
|
|||
# Execute commands without verifying after prompt substitution (!!, !$, etc)
|
||||
setopt NO_HIST_VERIFY
|
||||
|
||||
# Silence completion beeps
|
||||
unsetopt LIST_BEEP
|
||||
|
||||
|
||||
## Misc environment variables
|
||||
|
||||
# https://www.xkcd.com/378/
|
||||
export EDITOR="vim" # if antibody_plugins.txt includes robbyrussell/oh-my-zsh path:plugins/vi-mode, this also sets `bindkey -v`
|
||||
export EDITOR="vim" # if antibody_plugins.txt includes robbyrussell/oh-my-zsh path:plugins/vi-mode, this also sets `bindkey -v` # FIXME
|
||||
export VI_MODE_RESET_PROMPT_ON_MODE_CHANGE=true # refresh prompt on every mode change
|
||||
# Fix delete (delete! not backspace) key
|
||||
bindkey -a '^[[3~' delete-char
|
||||
|
||||
export KEYTIMEOUT=1 # reduce the transition time between vim modes to 0.1s
|
||||
export KEYTIMEOUT=50 # reduce the transition time between vim modes to 0.1s
|
||||
# bindkey -M vicmd 'V' edit-command-line # this remaps `vv` to `V` (but overrides `visual-mode`) # add this if the keytimeout is too slow
|
||||
|
||||
export HISTSIZE=100000
|
||||
export LANG=en_US.UTF-8
|
||||
export LC_ALL=en_US.UTF-8
|
||||
if ! grep -q "set editing-mode vi" $HOME/.inputrc &> /dev/null; then
|
||||
echo "set editing-mode vi" >> ~/.inputrc && echo "Warning: set up editing-mode ~/.inputrc"
|
||||
fi
|
||||
|
||||
export HISTSIZE=10000000
|
||||
export SAVEHIST=10000000
|
||||
|
||||
|
||||
# zsh-autosuggestions config
|
||||
export ZSH_AUTOSUGGEST_STRATEGY=(history completion)
|
||||
export ZSH_AUTOSUGGEST_COMPLETION_IGNORE='* \#*' # prevent completion for comments
|
||||
|
||||
# less options
|
||||
export LESS='-xRF-j12' # -j12: displays 12 lines before search results with / and ?
|
||||
if [[ "$(command -v bat)" ]]; then
|
||||
alias cat=bat
|
||||
export LESS='-xRF-j12' # -j12: displays 12 lines before search results with / and ?
|
||||
if (( $+commands[bat] || $+commands[batcat] )); then
|
||||
if (( $+commands[bat] )); then cmd=bat else cmd=batcat fi
|
||||
|
||||
alias cat=$cmd
|
||||
export PAGER=$cmd
|
||||
export BAT_PAGER="less $LESS"
|
||||
export PAGER=bat
|
||||
|
||||
if [[ -n $THEME_PREFER_LIGHT ]]; then
|
||||
export BAT_THEME="gruvbox-light"
|
||||
else
|
||||
export BAT_THEME="gruvbox-dark"
|
||||
fi
|
||||
|
||||
## this breaks symlink testing with [ -h ], best not to activate it
|
||||
# alias -g -- -h='-h 2>&1 | bat --language=help --style=plain'
|
||||
alias bathelp="$cmd --language=help --style=plain"
|
||||
alias -g -- --help='--help 2>&1 | bathelp '
|
||||
fi
|
||||
|
||||
if [[ $SSH_CLIENT ]]; then
|
||||
export SSH_AUTH_SOCK=$HOME/.ssh/ssh_auth_sock
|
||||
fi
|
||||
|
||||
# pip completions
|
||||
if which pip &>/dev/null ; then
|
||||
eval "$(pip completion --zsh)"
|
||||
fi
|
||||
# Automatically enable/disable virtualenv on chdir/step
|
||||
export DOTFILES_AUTOSWITCH_VIRTUALENV=1
|
||||
|
||||
alias esource='$EDITOR $HOME/.zshrc'
|
||||
alias resource='source $HOME/.zshrc'
|
||||
alias dotedit='$EDITOR $DOTFILES/brethil_dotfile.sh'
|
||||
# Custom definitions files
|
||||
alias funedit='$EDITOR ~/.dotfiles_functions.sh'
|
||||
alias aledit='$EDITOR ~/.dotfiles_aliases.sh'
|
||||
alias funedit='$EDITOR ~/.dotfiles_functions'
|
||||
alias aledit='$EDITOR ~/.dotfiles_aliases'
|
||||
|
||||
export p="${HOME}/projects"
|
||||
export g="${HOME}/git"
|
||||
|
||||
|
||||
for defname in aliases functions ; do
|
||||
for def in $DOTFILES/$defname/*zsh ; do
|
||||
source $def
|
||||
done
|
||||
done
|
||||
unset def defname
|
||||
|
||||
# Extras
|
||||
functions_file=$DOTFILES/functions.sh # Function definitions
|
||||
aliases_file=$DOTFILES/aliases.sh # Aliases definitions
|
||||
colors_file=$DOTFILES/colors.sh # Colors definitions
|
||||
functions_file=~/.dotfiles_functions
|
||||
aliases_file=~/.dotfiles_aliases
|
||||
ssh_file=~/.ssh_aliases
|
||||
|
||||
( # migration of old format
|
||||
if [[ -f ${functions_file}.sh ]]; then
|
||||
echo "Migrating ${functions_file}.sh to ${functions_file}"
|
||||
mv ${functions_file}{.sh,}
|
||||
fi
|
||||
if [[ -f ${aliases_file}.sh ]]; then
|
||||
echo "Migrating ${aliases_file}.sh to ${aliases_file}"
|
||||
mv ${aliases_file}{.sh,}
|
||||
fi
|
||||
)
|
||||
|
||||
# Source extras
|
||||
if [ -f "$functions_file" ]; then source "$functions_file"; else echo "[brethil-dotfiles] Couldn't load functions: $functions_file"; fi
|
||||
if [ -f "$aliases_file" ]; then source "$aliases_file"; else echo "[brethil-dotfiles] Couldn't load aliases: $aliases_file"; fi
|
||||
if [ -f "$colors_file" ]; then source "$colors_file"; else echo "[brethil-dotfiles] Couldn't load colors: $colors_file";fi
|
||||
test -f "${functions_file}" && source "${functions_file}"
|
||||
test -f "${aliases_file}" && source "${aliases_file}"
|
||||
test -f "${ssh_file}" && source "${ssh_file}"
|
||||
|
||||
### SETUP PATHS ####
|
||||
export PATH=$PATH:$HOME/bin
|
||||
# autoload -U compinit && compinit
|
||||
# autoload -U bashcompinit && bashcompinit
|
||||
|
||||
# Set DISABLE_DOTFILES_AUTOUPDATE=true to disable updates
|
||||
source "${DOTFILES}/extras/check_for_update.zsh"
|
||||
|
|
|
@ -1,78 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
#
|
||||
# brethil, brutally copied from https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/check_for_upgrade.sh
|
||||
# This also tries to update amix's vimrc and runs "antigen update"
|
||||
# 14 July 2017
|
||||
|
||||
zmodload zsh/datetime
|
||||
|
||||
function _current_epoch() {
|
||||
echo $(( $EPOCHSECONDS / 60 / 60 / 24 ))
|
||||
}
|
||||
|
||||
function _update_dotfiles_update() {
|
||||
echo "LAST_EPOCH=$(_current_epoch)" >! ~/.dotfiles-update
|
||||
}
|
||||
|
||||
function _upgrade_dotfiles() {
|
||||
(cd $DOTFILES; git pull -q --rebase && echo "Succesfully upgraded dotfiles" || echo "Could not upgrade dotfiles.")
|
||||
# amix's vimrc update
|
||||
amix_vimrc=$HOME/.vim_runtime
|
||||
if [[ -d $amix_vimrc ]]; then
|
||||
# the update_plugins.py script makes the vim_runtime dir dirty, so we have to reset --hard
|
||||
(cd $amix_vimrc && git reset --hard HEAD >/dev/null && git pull -q --rebase && echo "Upgraded amix's vimrc" || echo "Could not upgrade amix's vimrc" >&2)
|
||||
(python $amix_vimrc/update_plugins.py >/dev/null || echo "upgraded amix's vimrc's plugins || "echo "Could not upgrade amix's vimrc's plugins" >&2)
|
||||
else
|
||||
echo "Could not upgrade amix's vimrc and plugins (missing .vim_runtime folder)" >&2
|
||||
fi
|
||||
|
||||
antibody update
|
||||
# update the zsh file
|
||||
_update_dotfiles_update
|
||||
}
|
||||
|
||||
epoch_target=$UPDATE_ZSH_DAYS
|
||||
if [[ -z "$epoch_target" ]]; then
|
||||
# Default to old behavior
|
||||
epoch_target=13
|
||||
fi
|
||||
|
||||
# Cancel upgrade if the current user doesn't have write permissions for the
|
||||
# dotfiles directory.
|
||||
[[ -w "$DOTFILES" ]] || return 0
|
||||
|
||||
# Cancel upgrade if git is unavailable on the system
|
||||
whence git >/dev/null || return 0
|
||||
|
||||
# Clean up old lock files
|
||||
find $DOTFILES/update.lock -mmin 60 -exec rm {} \; &>/dev/null
|
||||
|
||||
if mkdir "$DOTFILES/update.lock" 2>/dev/null; then
|
||||
if [ -f ~/.dotfiles-update ]; then
|
||||
. ~/.dotfiles-update
|
||||
|
||||
if [[ -z "$LAST_EPOCH" ]]; then
|
||||
_update_dotfiles_update && return 0;
|
||||
fi
|
||||
|
||||
epoch_diff=$(($(_current_epoch) - $LAST_EPOCH))
|
||||
if [ $epoch_diff -gt $epoch_target ]; then
|
||||
if [ "$DISABLE_UPDATE_PROMPT" = "true" ]; then
|
||||
_upgrade_dotfiles
|
||||
else
|
||||
echo "[brethil dotfiles] Would you like to check for updates? [Y/n]: \c"
|
||||
read line
|
||||
if [[ "$line" == Y* ]] || [[ "$line" == y* ]] || [ -z "$line" ]; then
|
||||
_upgrade_dotfiles
|
||||
else
|
||||
_update_dotfiles_update
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
# create the dotfiles file
|
||||
_update_dotfiles_update
|
||||
fi
|
||||
|
||||
rmdir $DOTFILES/update.lock
|
||||
fi
|
|
@ -12,4 +12,5 @@ COPY id_ed25519.pub /root/.ssh/authorized_keys
|
|||
|
||||
WORKDIR /root/
|
||||
COPY entrypoint.sh /
|
||||
VOLUME ["/root/.dotfiles"]
|
||||
CMD ["bash", "/entrypoint.sh"]
|
||||
|
|
|
@ -13,4 +13,5 @@ COPY id_ed25519.pub /root/.ssh/authorized_keys
|
|||
|
||||
WORKDIR /root/
|
||||
COPY entrypoint.sh /
|
||||
VOLUME ["/root/.dotfiles"]
|
||||
CMD ["bash", "/entrypoint.sh"]
|
||||
|
|
47
dev/Makefile
47
dev/Makefile
|
@ -1,5 +1,18 @@
|
|||
SHELL=/bin/bash
|
||||
|
||||
ifndef VERBOSE
|
||||
.SILENT:
|
||||
endif
|
||||
|
||||
CLEAR="\033[0m"
|
||||
BOLD="\033[1m"
|
||||
GREEN="\033[32m"
|
||||
RED="\033[31m"
|
||||
BLUE="\033[34m"
|
||||
WHITE="\033[37m"
|
||||
|
||||
.PHONY: clean list_targets build build-arch build-debian arch archlinux debian run ansible release
|
||||
|
||||
all: list_targets
|
||||
|
||||
list_targets:
|
||||
|
@ -9,17 +22,37 @@ list_targets:
|
|||
debian: clean build-debian run
|
||||
arch archlinux: clean build-arch run
|
||||
|
||||
build-debian:
|
||||
build: build-arch
|
||||
|
||||
build-debian: Dockerfile.debian
|
||||
docker build -t brethil/dotfiles:dev -f Dockerfile.debian .
|
||||
|
||||
build-arch:
|
||||
build-arch: Dockerfile.archlinux
|
||||
docker build -t brethil/dotfiles:dev -f Dockerfile.archlinux .
|
||||
|
||||
run:
|
||||
docker run -d --name=dotfiles-dev brethil/dotfiles:dev
|
||||
echo "*** Started container, listening on ${BOLD}${WHITE}`docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dotfiles-dev`:22${CLEAR}"
|
||||
run: _run
|
||||
echo -e ${GREEN} "***" ${CLEAR} Watching logs from the container. Hit Ctrl+C to stop watching.
|
||||
docker logs -f dotfiles-dev
|
||||
|
||||
_run: Dockerfile.archlinux Dockerfile.debian build clean
|
||||
docker run -d --name=dotfiles-dev -v ${PWD}/..:/root/.dotfiles brethil/dotfiles:dev
|
||||
echo -en ${GREEN} "***" ${CLEAR} Started container, listening on
|
||||
echo -e ${BOLD}${WHITE} `docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' dotfiles-dev`:22 ${CLEAR}
|
||||
echo -e ${BLUE} "***" ${CLEAR} Run \`make clean\` to stop and remove the container
|
||||
|
||||
ansible: ../ansible/playbooks/setup.yml _run
|
||||
ANSIBLE_HOST_KEY_CHECKING=False ansible-playbook -i ansible-hosts -e local_development=true ../ansible/playbooks/setup.yml
|
||||
|
||||
release: build-arch ansible
|
||||
docker commit -m "install and initialize dotfiles (ansible)" dotfiles-dev brethil/dotfiles:latest
|
||||
docker tag brethil/dotfiles:latest brethil/dotfiles:`git rev-parse --short HEAD &2>/dev/null`
|
||||
echo -e ${GREEN} "***" ${CLEAR} committed and tagged the \"dockerfiles-dev\" to brethil/dotfiles:latest and :`git rev-parse HEAD --short`
|
||||
if ! git diff --quiet --exit-code; then \
|
||||
docker tag brethil/dotfiles:latest brethil/dotfiles:dev && \
|
||||
echo -e ${GREEN} "***" ${CLEAR} committed and tagged the \"dockerfiles-dev\" to brethil/dotfiles:dev; \
|
||||
fi
|
||||
|
||||
clean:
|
||||
docker stop dotfiles-dev || echo "no containers to stop"
|
||||
docker rm dotfiles-dev || echo "no containers to remove"
|
||||
echo -e ${GREEN} "***" ${CLEAR} Stopping and removing \"dockerfiles-dev\" container...
|
||||
docker kill dotfiles-dev &>/dev/null &>/dev/null && echo -e ${GREEN} "***" ${CLEAR} Killed container: dotfiles-dev || echo -e ${BLUE} "***" ${CLEAR} no containers to stop
|
||||
docker rm dotfiles-dev &>/dev/null && echo -e ${GREEN} "***" ${CLEAR} Removed container: dotfiles-dev || echo -e ${BLUE} "***" ${CLEAR} no containers to remove
|
||||
|
|
|
@ -13,7 +13,7 @@ make debian # this builds a docker image based on debian and runs it
|
|||
Start a builder in one shell:
|
||||
|
||||
```bash
|
||||
while true; do make; done
|
||||
while true; do make _run; done
|
||||
```
|
||||
|
||||
_check for the docker IP of the started container_.
|
||||
|
@ -25,3 +25,32 @@ ansible-playbook -v -i ./ansible-hosts playbooks/setup.yml
|
|||
```
|
||||
|
||||
note: the ip address in `ansible-hosts` might have changed from `172.18.0.2`.
|
||||
|
||||
## Docker images
|
||||
|
||||
- Build: `make build-arch` or `make build-debian` to build the image.
|
||||
- Run: `make run` to run the docker container. This bind-mounts `../` to
|
||||
`/root/.dotfiles`, making it possible to test the repo in the container.
|
||||
|
||||
## Docker + Ansible
|
||||
|
||||
Run `dotfiles-dev` image using `make run`. This starts the container with
|
||||
the local repository bind-mounted on `/root/.dotfiles`. To use a custom volume:
|
||||
|
||||
```bash
|
||||
docker run -v <volume>:/root/dofiles`
|
||||
```
|
||||
|
||||
**IMPORTANT** if bind-mounting an already existing repository, run
|
||||
`ansible` with `-e local_development=true` to avoid
|
||||
clobbering the git history if you have unpushed commit (it won't
|
||||
work if your repo is dirty).
|
||||
|
||||
Ansible can now be used to test the installation.
|
||||
|
||||
make ansible
|
||||
|
||||
## Releasing
|
||||
|
||||
Use `make release` to build an image from scratch, run it, install dotfiles
|
||||
in the container using ansible, then commit the resulting container.
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
Binary file not shown.
After Width: | Height: | Size: 45 KiB |
Binary file not shown.
After Width: | Height: | Size: 249 KiB |
|
@ -0,0 +1,10 @@
|
|||
#_tmux_sourced=1 exec tmux
|
||||
if [[ -z $TMUX ]] && [[ -n $SSH_TTY ]]; then
|
||||
session=tmux
|
||||
|
||||
if tmux has-session -t "$session" 2>/dev/null; then
|
||||
exec tmux attach-session -t "$session"
|
||||
else
|
||||
exec tmux new-session -s "$session"
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,97 @@
|
|||
#!/usr/bin/env zsh
|
||||
# brethil, brutally copied from https://github.com/robbyrussell/oh-my-zsh/blob/master/tools/check_for_upgrade.sh
|
||||
# This also runs antibody update"
|
||||
# First version: 14 July 2017
|
||||
# Rebased on upstream: 08 December 2020
|
||||
|
||||
|
||||
local DOTFILES_UPDATEFILE=${DOTFILES}/.dotfiles-update
|
||||
# Migrate .dotfiles-update file to $DOTFILES
|
||||
if [[ -f ~/.dotfiles-update && ! -f "${DOTFILES_UPDATEFILE}" ]]; then
|
||||
mv ~/.dotfiles-update "${DOTFILES_UPDATEFILE}"
|
||||
fi
|
||||
|
||||
# Cancel update if:
|
||||
# - the automatic update is disabled.
|
||||
# - git is unavailable on the system.
|
||||
if [[ -n $DISABLE_DOTFILES_AUTOUPDATE ]] || ! command -v git &>/dev/null; then
|
||||
return
|
||||
fi
|
||||
|
||||
|
||||
function current_epoch() {
|
||||
zmodload zsh/datetime
|
||||
echo $(( EPOCHSECONDS / 60 / 60 / 24 ))
|
||||
}
|
||||
|
||||
function _update_dotfiles_update() {
|
||||
echo "LAST_EPOCH=$(current_epoch)" >! "${DOTFILES_UPDATEFILE}"
|
||||
}
|
||||
|
||||
function update_dotfiles() {
|
||||
(cd $DOTFILES; git pull -q --rebase && echo "Succesfully upgraded dotfiles" || echo "Could not upgrade dotfiles.")
|
||||
(cd $DOTFILES/antidote && git pull --rebase || echo "Could not upgrade antidote")
|
||||
vim -c 'PlugUpdate|PlugClean|qa!'
|
||||
# update the zsh file
|
||||
_update_dotfiles_update
|
||||
}
|
||||
|
||||
() {
|
||||
if [[ -n $DOTFILES_FORCEUPDATE ]]; then
|
||||
update_dotfiles;
|
||||
return;
|
||||
fi
|
||||
|
||||
local epoch_target mtime option LAST_EPOCH
|
||||
|
||||
# Remove lock directory if older than a day
|
||||
zmodload zsh/datetime
|
||||
zmodload -F zsh/stat b:zstat
|
||||
if mtime=$(zstat +mtime "$DOTFILES/update.lock" 2>/dev/null); then
|
||||
if (( (mtime + 3600 * 24) < EPOCHSECONDS )); then
|
||||
command rm -f "$DOTFILES/update.lock"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for lock directory
|
||||
if ! command mkdir "$DOTFILES/update.lock" 2>/dev/null; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Remove lock directory on exit. `return 1` is important for when trapping a SIGINT:
|
||||
# The return status from the function is handled specially. If it is zero, the signal is
|
||||
# assumed to have been handled, and execution continues normally. Otherwise, the shell
|
||||
# will behave as interrupted except that the return status of the trap is retained.
|
||||
trap "
|
||||
unset -f current_epoch _update_dotfiles_update update_dotfiles &>/dev/null
|
||||
command rmdir '$DOTFILES/update.lock' &>/dev/null
|
||||
return 1
|
||||
" EXIT INT QUIT
|
||||
|
||||
# Create or update .zsh-update file if missing or malformed
|
||||
if ! source "${DOTFILES_UPDATEFILE}" 2>/dev/null || [[ -z "$LAST_EPOCH" ]]; then
|
||||
_update_dotfiles_update
|
||||
return
|
||||
fi
|
||||
|
||||
# Number of days before trying to update again
|
||||
epoch_target=${UPDATE_DOTFILES_DAYS:-5}
|
||||
# Test if enough time has passed until the next update
|
||||
if (( ( $(current_epoch) - $LAST_EPOCH ) < $epoch_target )); then
|
||||
return
|
||||
fi
|
||||
|
||||
# Ask for confirmation before updating unless disabled
|
||||
if [[ "$DISABLE_UPDATE_PROMPT" = true ]]; then
|
||||
update_dotfiles
|
||||
else
|
||||
echo -n "[brethil-dotfiles] Would you like to update? [Y/n] "
|
||||
read -r -k 1 option
|
||||
case "$option" in
|
||||
[yY$'\n']) update_dotfiles ;;
|
||||
[nN]) _update_dotfiles_update ;;
|
||||
*) echo -n "[brethil dotfiles] Skipping. Update using \`dotfiles_selfupdate\`" && echo ;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
unset -f current_epoch update_dotfiles _update_dotfiles_update
|
|
@ -1,3 +1,9 @@
|
|||
# ansi colors are pretty simple. In 256 color mode, for a given
|
||||
# (r, g, b) tuple:
|
||||
# \x1b[38;2;r;g;bm - foreground
|
||||
# \x1b[48;2;r;g;bm - background
|
||||
|
||||
|
||||
# ANSI COLOR ESCAPES
|
||||
# CLEAR
|
||||
CLEAR='\e[0m' # CLEAR
|
||||
|
@ -23,6 +29,9 @@ BCyan='\e[1;36m' # Cyan
|
|||
BWhite='\e[1;37m' # White
|
||||
|
||||
# Underline
|
||||
if command -v tput &>/dev/null; then
|
||||
UNDERLINE="$(tput smul)"
|
||||
fi
|
||||
UBlack='\e[4;30m' # Black
|
||||
URed='\e[4;31m' # Red
|
||||
UGreen='\e[4;32m' # Green
|
||||
|
@ -85,3 +94,34 @@ LIGHTCYAN="\e[36m"; LIGHTRED="\033[31m"; LIGHTPURPLE="\033[35m";
|
|||
YELLOW="\e[33m"; WHITE="\033[37m"
|
||||
BACKGROUND_BLACK="\e[40"; BACKGROUND_RED="\033[41";
|
||||
BACKGROUND_GREEN="\e[42"; BACKGROUND_YELLOW="\033[43m"
|
||||
|
||||
|
||||
## Color string with given color. Usage: `color $NAME "string"`, available colors below
|
||||
function color
|
||||
{
|
||||
local color=$1
|
||||
shift 1
|
||||
echo -e "${color}$@${CLEAR}"
|
||||
}
|
||||
|
||||
## These functions return a colored version of the input string. Usage: red "string"
|
||||
function red
|
||||
{
|
||||
echo -e "$Red$@$CLEAR"
|
||||
}
|
||||
function green
|
||||
{
|
||||
echo -e "$Green$@$CLEAR"
|
||||
}
|
||||
function yellow
|
||||
{
|
||||
echo -e "$Yellow$@$CLEAR"
|
||||
}
|
||||
function blue
|
||||
{
|
||||
echo -e "$Blue$@$CLEAR"
|
||||
}
|
||||
function bold
|
||||
{
|
||||
echo -e "$BOLD$@$CLEAR"
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
# stolen from https://github.com/Phantas0s/.dotfiles/blob/master/zsh/completion.zsh
|
||||
|
||||
|
||||
## General
|
||||
# zstyle pattern for the completion
|
||||
# :completion:<function>:<completer>:<command>:<argument>:<tag>
|
||||
|
||||
# Should be called before compinit
|
||||
zmodload zsh/complist
|
||||
|
||||
# Use hjlk in menu selection (during completion)
|
||||
# Doesn't work well with interactive mode
|
||||
bindkey -M menuselect 'h' vi-backward-char
|
||||
bindkey -M menuselect 'k' vi-up-line-or-history
|
||||
bindkey -M menuselect 'j' vi-down-line-or-history
|
||||
bindkey -M menuselect 'l' vi-forward-char
|
||||
|
||||
bindkey -M menuselect '^xg' clear-screen
|
||||
bindkey -M menuselect '^xi' vi-insert # Insert
|
||||
bindkey -M menuselect '^xh' accept-and-hold # Hold
|
||||
bindkey -M menuselect '^xn' accept-and-infer-next-history # Next
|
||||
bindkey -M menuselect '^xu' undo # Undo
|
||||
|
||||
#setopt GLOB_COMPLETE # Show autocompletion menu with globs
|
||||
#setopt MENU_COMPLETE # Automatically highlight first element of completion menu
|
||||
setopt AUTO_LIST # Automatically list choices on ambiguous completion.
|
||||
|
||||
## Zstyles
|
||||
# Ztyle pattern
|
||||
# :completion:<function>:<completer>:<command>:<argument>:<tag>
|
||||
|
||||
# Define completers
|
||||
zstyle ':completion:*' completer _extensions _complete _approximate
|
||||
|
||||
# Use cache for commands using cache
|
||||
zstyle ':completion:*' use-cache on
|
||||
zstyle ':completion:*' cache-path "$HOME/.cache/zsh/.zcompcache"
|
||||
# Complete the alias when _expand_alias is used as a function
|
||||
zstyle ':completion:*' complete true
|
||||
|
||||
zle -C alias-expension complete-word _generic
|
||||
bindkey '^A' alias-expension
|
||||
zstyle ':completion:alias-expension:*' completer _expand_alias
|
||||
|
||||
# Allow you to select in a menu
|
||||
zstyle ':completion:*' menu select
|
||||
|
||||
# Autocomplete options for cd instead of directory stack
|
||||
zstyle ':completion:*' complete-options true
|
||||
|
||||
zstyle ':completion:*' file-sort modification
|
||||
|
||||
|
||||
zstyle ':completion:*:*:*:*:corrections' format '%F{yellow}!- %d (errors: %e) -!%f'
|
||||
zstyle ':completion:*:*:*:*:descriptions' format '%F{blue}-- %D %d --%f'
|
||||
zstyle ':completion:*:*:*:*:messages' format ' %F{purple} -- %d --%f'
|
||||
zstyle ':completion:*:*:*:*:warnings' format ' %F{red}-- no matches found --%f'
|
||||
# zstyle ':completion:*:default' list-prompt '%S%M matches%s'
|
||||
# Colors for files and directory
|
||||
zstyle ':completion:*:*:*:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
|
||||
# Only display some tags for the command cd
|
||||
zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
|
||||
# zstyle ':completion:*:complete:git:argument-1:' tag-order !aliases
|
||||
|
||||
# Required for completion to be in good groups (named after the tags)
|
||||
zstyle ':completion:*' group-name ''
|
||||
|
||||
zstyle ':completion:*:*:-command-:*:*' group-order aliases builtins functions commands
|
||||
|
||||
# See ZSHCOMPWID "completion matching control"
|
||||
zstyle ':completion:*' matcher-list '' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=*' 'l:|=* r:|=*'
|
||||
|
||||
zstyle ':completion:*' keep-prefix true
|
||||
|
||||
zstyle -e ':completion:*:(ssh|scp|sftp|rsh|rsync):hosts' hosts 'reply=(${=${${(f)"$(cat {/etc/ssh_,~/.ssh/known_}hosts(|2)(N) /dev/null)"}%%[# ]*}//,/ })'
|
||||
|
||||
# kubectl
|
||||
zstyle ':completion:*:*:kubectl:*' list-grouped false
|
||||
|
||||
# docker
|
||||
zstyle ':completion:*:*:docker:*' option-stacking yes
|
||||
zstyle ':completion:*:*:docker-*:*' option-stacking yes
|
|
@ -0,0 +1,25 @@
|
|||
# disable sort when completing options of any command
|
||||
zstyle ':completion:complete:*:options' sort false
|
||||
|
||||
# use input as query string when completing zlua
|
||||
zstyle ':fzf-tab:complete:_zlua:*' query-string input
|
||||
|
||||
# (experimental, may change in the future)
|
||||
# some boilerplate code to define the variable `extract` which will be used later
|
||||
# please remember to copy them
|
||||
local extract="
|
||||
# trim input(what you select)
|
||||
local in=\${\${\"\$(<{f})\"%\$'\0'*}#*\$'\0'}
|
||||
# get ctxt for current completion(some thing before or after the current word)
|
||||
local -A ctxt=(\"\${(@ps:\2:)CTXT}\")
|
||||
# real path
|
||||
local realpath=\${ctxt[IPREFIX]}\${ctxt[hpre]}\$in
|
||||
realpath=\${(Qe)~realpath}
|
||||
"
|
||||
|
||||
# give a preview of commandline arguments when completing `kill`
|
||||
zstyle ':completion:*:*:*:*:processes' command "ps -u $USER -o pid,user,comm,cmd -w -w"
|
||||
zstyle ':fzf-tab:complete:kill:argument-rest' extra-opts --preview=$extract'ps --pid=$in[(w)1] -o cmd --no-headers -w -w' --preview-window=down:3:wrap
|
||||
|
||||
# give a preview of directory by exa when completing cd
|
||||
zstyle ':fzf-tab:complete:cd:*' extra-opts --preview=$extract'exa -1 --color=always $realpath'
|
|
@ -0,0 +1,50 @@
|
|||
#!/usr/bin/env zsh
|
||||
# Reads output from zprof.
|
||||
# Usage:
|
||||
# 1. add the following to the beginning of your zshrc
|
||||
# if [[ -n $profiling ]]; then
|
||||
# zmodload zsh/zprof
|
||||
# zmodload zsh/datetime
|
||||
# setopt PROMPT_SUBST
|
||||
# PS4='+$EPOCHREALTIME %N:%i> '
|
||||
#
|
||||
# logfile=$(mktemp zsh_profile.XXXXXXXX)
|
||||
# echo "Logging to $logfile"
|
||||
# exec 3>&2 2>$logfile
|
||||
#
|
||||
# setopt XTRACE
|
||||
# fi
|
||||
# 2. add this to the end of your zshrc
|
||||
# if [[ -n $profiling ]]; then
|
||||
# unsetopt XTRACE
|
||||
# exec 2>&3 3>&-
|
||||
# zprof
|
||||
# fi
|
||||
# 3. zsh -i -c exit
|
||||
# 4. sort_timings.zsh zsh_profile.* # or use the newly-created file
|
||||
|
||||
typeset -a lines
|
||||
typeset -i prev_time=0
|
||||
typeset prev_command
|
||||
|
||||
while read line; do
|
||||
if [[ $line =~ '^.*\+([0-9]{10})\.([0-9]{6})[0-9]* (.+)' ]]; then
|
||||
integer this_time=$match[1]$match[2]
|
||||
|
||||
if [[ $prev_time -gt 0 ]]; then
|
||||
time_difference=$(( $this_time - $prev_time ))
|
||||
lines+="$time_difference $prev_command"
|
||||
fi
|
||||
|
||||
prev_time=$this_time
|
||||
|
||||
local this_command=$match[3]
|
||||
if [[ ${#this_command} -le 80 ]]; then
|
||||
prev_command=$this_command
|
||||
else
|
||||
prev_command="${this_command}..."
|
||||
fi
|
||||
fi
|
||||
done < ${1:-/dev/stdin}
|
||||
|
||||
print -l ${(@On)lines} # | sort -h | vim -
|
|
@ -0,0 +1,4 @@
|
|||
#!/bin/bash
|
||||
if test "$SSH_AUTH_SOCK" ; then
|
||||
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
|
||||
fi
|
|
@ -0,0 +1,15 @@
|
|||
# Make sure SSH_AUTH_sock is symlinked
|
||||
if test "$SSH_AUTH_SOCK" ; then
|
||||
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
|
||||
fi
|
||||
|
||||
#_tmux_sourced=1 exec tmux
|
||||
if [[ -z $TMUX ]] && [[ -n $SSH_TTY ]]; then
|
||||
session=tmux
|
||||
|
||||
if tmux has-session -t "$session" 2>/dev/null; then
|
||||
exec tmux attach-session -t "$session"
|
||||
else
|
||||
exec tmux new-session -s "$session"
|
||||
fi
|
||||
fi
|
|
@ -0,0 +1,18 @@
|
|||
|
||||
# Make sure SSH_AUTH_sock is symlinked
|
||||
if test "$SSH_AUTH_SOCK" ; then
|
||||
ln -sf $SSH_AUTH_SOCK ~/.ssh/ssh_auth_sock
|
||||
fi
|
||||
|
||||
#_tmux_sourced=1 exec tmux
|
||||
if [[ -z $TMUX ]] && [[ -n $SSH_TTY ]]; then
|
||||
set -x
|
||||
session=tmux
|
||||
|
||||
if tmux has-session -t "$session" 2>/dev/null; then
|
||||
exec tmux attach-session -t "$session"
|
||||
else
|
||||
tmux new-session -s "$session"
|
||||
exec tmux attach-session -t "$session"
|
||||
fi
|
||||
fi
|
279
functions.sh
279
functions.sh
|
@ -1,279 +0,0 @@
|
|||
###########################
|
||||
#### Function Definitions #
|
||||
###########################
|
||||
## Selfupdate
|
||||
function dotfiles_selfupdate
|
||||
{
|
||||
(. $DOTFILES/check_for_update.sh && _upgrade_dotfiles)
|
||||
}
|
||||
|
||||
## get cheat sheets for commands from cheat.sh. Usage: cheat commandname
|
||||
function cheat
|
||||
{
|
||||
curl "https://cheat.sh/$1"
|
||||
}
|
||||
# get cheat sheets for commands matching $1
|
||||
function cheatall
|
||||
{
|
||||
curl "https://cheat.sh/~$1"
|
||||
}
|
||||
|
||||
# List all docker tags for an image
|
||||
function dockertags
|
||||
{
|
||||
if [[ -z $(command -v jq) ]]; then
|
||||
echo "jq not installed. Please install jq." 1>&2
|
||||
return
|
||||
fi
|
||||
i=0
|
||||
while [[ $? == 0 ]]; do
|
||||
i=$(($i+1))
|
||||
curl "https://registry.hub.docker.com/v2/repositories/library/$1/tags/?page=$i" 2>/dev/null | jq '."results"[]["name"]'
|
||||
done
|
||||
}
|
||||
|
||||
# watch with grc enabled
|
||||
function watchgrc
|
||||
{
|
||||
watch -n 1 -c grc --colour=on "$@"
|
||||
}
|
||||
|
||||
## Simple calculator. Usage: calc 1+1, calc 5/7, calc "sqrt(2)"
|
||||
function calc
|
||||
{
|
||||
awk "BEGIN { print $* }"
|
||||
}
|
||||
|
||||
## Make new directory and cd to that directory. Usage: mcd newfolder
|
||||
function mcd
|
||||
{
|
||||
mkdir -p "$1"
|
||||
cd $1
|
||||
}
|
||||
|
||||
## Print full path of item in current directory
|
||||
function ppath
|
||||
{
|
||||
echo "$PWD/$1"
|
||||
}
|
||||
|
||||
## Color string with given color. Usage: color $colorname "string", available colors in colors.sh
|
||||
function color
|
||||
{
|
||||
color=$1
|
||||
set -x
|
||||
shift 1
|
||||
echo -e "$"$color"$@${CLEAR}\n"
|
||||
set +x
|
||||
}
|
||||
|
||||
|
||||
## These functions return a colored version of the input string. Usage: red "string"
|
||||
function red
|
||||
{
|
||||
echo -e "$Red$@$CLEAR"
|
||||
}
|
||||
function green
|
||||
{
|
||||
echo -e "$Green$@$CLEAR"
|
||||
}
|
||||
function blue
|
||||
{
|
||||
echo -e "$Blue$@$CLEAR"
|
||||
}
|
||||
|
||||
## Flashes the screen until user presses a key
|
||||
function flasher
|
||||
{
|
||||
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
||||
}
|
||||
|
||||
## Beep until user presses a key
|
||||
function beeper
|
||||
{
|
||||
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
||||
}
|
||||
|
||||
|
||||
## Simple http server for current directory (or path)
|
||||
function httpserver
|
||||
{
|
||||
(
|
||||
if [[ -d $1 ]]; then
|
||||
cd "$1" && echo "Starting webserver in $(realpath $1)/" || echo "directory: $1 does not exist" >&2 || exit 1
|
||||
else
|
||||
echo "Starting webserver in $PWD/"
|
||||
fi
|
||||
open "http://localhost:8000" &>/dev/null &
|
||||
if [[ "$(command -v python3)" ]]; then
|
||||
python=python3
|
||||
else
|
||||
python=python
|
||||
fi
|
||||
$python -m http.server 8000
|
||||
)
|
||||
}
|
||||
alias webserver='httpserver'
|
||||
|
||||
## Upload something using the transfer.sh service. Usage: transfer filename
|
||||
function transfer
|
||||
{
|
||||
basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g')
|
||||
out=$(curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile")
|
||||
echo -e "Done, file at:\t$out"
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
echo "$out" | pbcopy
|
||||
else
|
||||
echo "$out"
|
||||
fi
|
||||
}
|
||||
|
||||
## If connecting through ssh and reverse forwarding port 2222 (ssh -R 2222:localhost:22 ), this function allows to copy the files back to the machine one is connecting from by typing 'mecp filename' (configure the username for "localhost" in ~/.ssh/config or add an username)
|
||||
function mecp
|
||||
{
|
||||
rsync -r -P -e "ssh -p 2222" -R "$@" localhost:~/Desktop/
|
||||
}
|
||||
|
||||
|
||||
## generate a password using pwgen, generate_password 20 generates a 20 characters long password
|
||||
function generate_password
|
||||
{
|
||||
pwgen -1sycn $1
|
||||
}
|
||||
|
||||
## Generate a password from dev urandom using only printable characters
|
||||
function genpwd
|
||||
{
|
||||
if [[ $1 ]]; then
|
||||
strlen=$1
|
||||
else
|
||||
strlen=32
|
||||
fi
|
||||
# All characters excluding backlash
|
||||
env LC_CTYPE=C tr -dc '[:graph]\' < /dev/urandom | fold -w $strlen | head -n 1
|
||||
}
|
||||
|
||||
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
## Copy output of previous command to termbin.com (command line pastebin) and put in in clipboard
|
||||
function termbin
|
||||
{
|
||||
nc termbin.com 9999 | pbcopy && echo -n "$(pbpaste) --> in clipboard"
|
||||
}
|
||||
else
|
||||
## Copy output of previous command to termbin.com (command line pastebin)
|
||||
function termbin
|
||||
{
|
||||
nc termbin.com 9999
|
||||
}
|
||||
fi
|
||||
|
||||
## List defined functions in $DOTFILES/functions.sh
|
||||
function list_functions
|
||||
{
|
||||
grep --color=no -A 1 '^##' $DOTFILES/functions.sh | sed -E 's/function (.*)/\1/g'
|
||||
}
|
||||
|
||||
|
||||
###########################
|
||||
## MAC SPECIFIC #
|
||||
###########################
|
||||
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
## Create a RAM disk. Default size 1GB. If supplied, first argument defines the RAM disk size in GB
|
||||
function ramdisk
|
||||
{
|
||||
if [[ -e $1 ]]; then
|
||||
sizeingb=$1
|
||||
else
|
||||
sizeingb=1
|
||||
fi
|
||||
|
||||
# Numsectors is size in bytes / 512 (sector size in bytes)
|
||||
name='RAM_disk'
|
||||
sizeinbytes=$(($sizeingb*1000**3))
|
||||
NUMSECTORS=$(($sizeinbytes/512))
|
||||
mydev=$(hdiutil attach -nomount ram://$NUMSECTORS )
|
||||
# strip whitespace (hdiutil outputs a lot of spaces/tabs along with the device name)
|
||||
mydev=$(echo "$mydev"| xargs echo)
|
||||
newfs_hfs "$mydev"
|
||||
mkdir -p "/tmp/$name"
|
||||
mount -t hfs "$mydev" "/tmp/$name"
|
||||
echo "RAM Disk mounted: /tmp/$name"
|
||||
echo "To eject (destroy) RAM disk, use:"
|
||||
echo " $ diskutil eject $mydev"
|
||||
}
|
||||
|
||||
## Open a pdf version of the man in Preview
|
||||
function man2pdf
|
||||
{
|
||||
man -t "$1" | open -f -a Preview
|
||||
}
|
||||
|
||||
## Open Man in separate (different-looking) window
|
||||
function nman
|
||||
{
|
||||
if [ $# -eq 1 ] ; then
|
||||
open "x-man-page://$1"
|
||||
elif [ $# -eq 2 ] ; then
|
||||
open "x-man-page://$1/$2"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
### end of mac-specific functions
|
||||
|
||||
pipupdate(){
|
||||
set -x
|
||||
if [[ "$1" == "user" ]]; then
|
||||
user_flags='--user'
|
||||
shift
|
||||
fi
|
||||
if [[ -n "$@" ]]; then
|
||||
pip="$1"
|
||||
shift
|
||||
flags="$*"
|
||||
echo "pip command is: '$pip $flags'"
|
||||
if ! command -v "$pip" ; then
|
||||
echo "Given command ($1) does not exist." 1>&2
|
||||
return
|
||||
fi
|
||||
|
||||
else
|
||||
pip='python'
|
||||
flags='-m pip'
|
||||
echo "Using default pip: $pip $flags"
|
||||
fi
|
||||
|
||||
for package in $($pip $flags freeze $user_flags --local | grep -v '^\-e' | cut -d = -f 1) ; do
|
||||
$pip $flags install "$user_flags" -U "$package"
|
||||
done
|
||||
set +x
|
||||
}
|
||||
|
||||
# unzip file to directory with the same name of the zip file (without extension)
|
||||
function unzipd {
|
||||
zip_file="$1"
|
||||
filename=$(basename -- "$zip_file")
|
||||
extension="${filename##*.}"
|
||||
name="${filename%.*}"
|
||||
unzip -d "$name" "$zip_file"
|
||||
}
|
||||
|
||||
# remove local branches which have been merged into master
|
||||
function git_prune_branches(){
|
||||
git branch --merged master | grep -v '^[ * ]*master$' | xargs git branch -d
|
||||
}
|
||||
|
||||
fvim() {
|
||||
if [[ -n "$@" ]]; then
|
||||
vim `fzf -q $@`
|
||||
else
|
||||
vim `fzf`
|
||||
fi
|
||||
}
|
||||
|
||||
# dotfiles user functions
|
||||
if [[ -f $HOME/.dotfiles_functions ]]; then
|
||||
source "$HOME/.dotfiles_functions"
|
||||
fi
|
|
@ -0,0 +1,4 @@
|
|||
# functions
|
||||
|
||||
Place custom functions definitions in this folder, with a `.zsh` extension.
|
||||
These files will be sourced on startup
|
|
@ -0,0 +1,43 @@
|
|||
function switch-asciinema-user
|
||||
{
|
||||
local conf_dir="$HOME/.config/asciinema"
|
||||
local current_id=$(basename $(readlink -f ${conf_dir}/install-id ))
|
||||
function get_ids {
|
||||
find ${conf_dir} -name 'install-id-*' -exec basename {} \;
|
||||
}
|
||||
|
||||
if [[ $1 == "-l" || $1 == "--list" ]]; then
|
||||
echo "$(color $BOLD Available ids): (current = $(color $UNDERLINE ${current_id}))"
|
||||
for _id in $(get_ids); do
|
||||
echo " $(green ➡️) ${_id}"
|
||||
done
|
||||
return
|
||||
fi
|
||||
|
||||
local ids=$(get_ids)
|
||||
local query
|
||||
local new_id
|
||||
if [[ -n "$@" ]]; then
|
||||
query="-q $@"
|
||||
fi
|
||||
new_id=$(echo $ids| fzf --height=$(($(wc -l <<< $ids)+2)) ${query} )
|
||||
if [[ -z $new_id ]]; then
|
||||
yellow "Keeping curent id ($(color $UNDERLINE ${current_id}))"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "$new_id" == "$current_id" ]]; then
|
||||
yellow "id $new_id is already set."
|
||||
return
|
||||
fi
|
||||
|
||||
local id_file="${conf_dir}/${new_id}"
|
||||
if [[ ! -f ${id_file} ]]; then
|
||||
red "${id_file} does not exist"
|
||||
return
|
||||
fi
|
||||
|
||||
ln -sf "${id_file}" "${conf_dir}/install-id" && \
|
||||
green "Set \"$new_id\"." || \
|
||||
red "Could not set id \"$new_id\". (run with -l for a list of available profiles)"
|
||||
}
|
|
@ -0,0 +1,125 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||
#
|
||||
# Miscellaneous git helpers
|
||||
|
||||
|
||||
# Create a gitignore for the given argument (e.g. python, cpp, etc)
|
||||
function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/$@; }
|
||||
|
||||
|
||||
|
||||
# Completion helper, from requires __completion_wrapper from `misc.zsh`
|
||||
__git_completion_wrapper() {
|
||||
# Wrapper for `__git_*` completion functions
|
||||
# Can be used to force loading of specialized git completions
|
||||
# When defining custom commands. See below for usage examples.
|
||||
__completion_wrapper $1 _git
|
||||
}
|
||||
|
||||
|
||||
# remove local branches which have been merged into master/main
|
||||
function git-prune-branches(){
|
||||
local main=$(git_main_branch)
|
||||
git branch --merged $main | grep -v '^[ * ]*'$main'$' | xargs git branch -d
|
||||
}
|
||||
|
||||
|
||||
|
||||
# sort branches by latest commit
|
||||
function git-sort-branch-by-usage(){
|
||||
git for-each-ref --sort=committerdate refs/heads/ --format='%(refname:short)'
|
||||
}
|
||||
|
||||
# switch to a recent branch
|
||||
function git-switch-recent-branch(){
|
||||
git switch $1
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_recent_branches" git-switch-recent-branch
|
||||
|
||||
function git-commit-show() {
|
||||
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" $@ |
|
||||
fzf --ansi --no-sort --reverse --tiebreak=index --preview \
|
||||
'f() {
|
||||
set -- $(echo -- "$@" | grep -o "[a-f0-9]\{7\}")
|
||||
[ $# -eq 0 ] || git show --color=always $1
|
||||
}
|
||||
f {}' \
|
||||
--bind "j:down,k:up,alt-j:preview-down,alt-k:preview-up,ctrl-f:preview-page-down,ctrl-b:preview-page-up,q:abort,ctrl-m:execute:
|
||||
(grep -o '[a-f0-9]\{7\}' | head -1 |
|
||||
xargs -I % sh -c 'git show --color=always % | less -R') << 'FZF-EOF'
|
||||
{} FZF-EOF" \
|
||||
--preview-window=right:60%
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_recent_commits" git-commit-show
|
||||
|
||||
function git-fixup() {
|
||||
git commit --fixup=$1
|
||||
git -c sequence.editor=true rebase --interactive --autosquash $1^
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_recent_commits" git-fixup
|
||||
|
||||
function git-diff-branch() {
|
||||
git diff $@
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_branch_names" git-diff-branch
|
||||
|
||||
|
||||
function git-show-changes(){
|
||||
git log --reverse HEAD^..
|
||||
}
|
||||
|
||||
# oh-my-zsh has some aliases which we might want to override
|
||||
# with functions
|
||||
function _disable_alias() {
|
||||
[[ -n $(alias "$1") ]] && unalias "$1"
|
||||
|
||||
}
|
||||
|
||||
_disable_alias gco
|
||||
function gco() {
|
||||
if [[ "$#" -ge 1 ]]; then
|
||||
g checkout $@
|
||||
elif [[ "$#" -eq 0 ]]; then
|
||||
local selected
|
||||
selected=$(git branch --format "%(refname)" | cut -d / -f 3- | fzf)
|
||||
if [[ -n $selected ]]; then
|
||||
git checkout "$selected"
|
||||
else
|
||||
echo "Nothing selected"
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
}
|
||||
compdef "__git_completion_wrapper _git-checkout" gco
|
||||
|
||||
|
||||
_disable_alias gcor
|
||||
function gcor() {
|
||||
if [[ "$#" -ge 1 ]]; then
|
||||
git checkout $@
|
||||
elif [[ "$#" -eq 0 ]]; then
|
||||
git checkout --track $(gbr | fzf)
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
_disable_alias gbd
|
||||
function gbd() {
|
||||
if [[ "$#" -ge 1 ]]; then
|
||||
g branch -d $@
|
||||
elif [[ "$#" -eq 0 ]]; then
|
||||
g branch -d $(gb | fzf -m)
|
||||
fi
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_recent_branches" gbd
|
||||
|
||||
_disable_alias gbD
|
||||
function gbD() {
|
||||
if [[ "$#" -ge 1 ]]; then
|
||||
git branch -D $@
|
||||
elif [[ "$#" -eq 0 ]]; then
|
||||
git branch -D $(git branch | fzf -m)
|
||||
fi
|
||||
}
|
||||
compdef "__git_completion_wrapper __git_recent_branches" gbD
|
|
@ -0,0 +1,19 @@
|
|||
function fuzzyman() {
|
||||
local preview_cmd
|
||||
preview_cmd='command man {+1} 2>/dev/null | bat --style=plain --language=man --color=always'
|
||||
|
||||
apropos_args=$@
|
||||
if [[ -z $apropos_args ]]; then
|
||||
apropos_args="."
|
||||
fi
|
||||
|
||||
man $(command man -k "${apropos_args}" \
|
||||
| fzf \
|
||||
--preview="${preview_cmd}" \
|
||||
--preview-window=right,60% \
|
||||
| awk '{print $1}'
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
compdef _man fuzzyman=man
|
|
@ -0,0 +1,335 @@
|
|||
###########################
|
||||
#### Function Definitions #
|
||||
###########################
|
||||
## Selfupdate
|
||||
function dotfiles_selfupdate
|
||||
{
|
||||
(DOTFILES_FORCEUPDATE=1 source $DOTFILES/extras/check_for_update.zsh || echo "[dotfiles_selfupdate] failed")
|
||||
}
|
||||
|
||||
## get cheat sheets for commands from cheat.sh. Usage: cheat commandname
|
||||
function cheat
|
||||
{
|
||||
curl "https://cheat.sh/$1"
|
||||
}
|
||||
# get cheat sheets for commands matching $1
|
||||
function cheatall
|
||||
{
|
||||
curl "https://cheat.sh/~$1"
|
||||
}
|
||||
|
||||
# List all docker tags for an image
|
||||
function dockertags
|
||||
{
|
||||
if [[ -z $(command -v jq) ]]; then
|
||||
echo "jq not installed. Please install jq." 1>&2
|
||||
return
|
||||
fi
|
||||
i=0
|
||||
while [[ $? == 0 ]]; do
|
||||
i=$(($i+1))
|
||||
curl "https://registry.hub.docker.com/v2/repositories/library/$1/tags/?page=$i" 2>/dev/null | jq '."results"[]["name"]'
|
||||
done
|
||||
}
|
||||
|
||||
# watch with grc enabled
|
||||
function watchgrc
|
||||
{
|
||||
watch -n 1 -c grc --colour=on "$@"
|
||||
}
|
||||
|
||||
## Simple calculator. Usage: calc 1+1, calc 5/7, calc "sqrt(2)"
|
||||
function calc
|
||||
{
|
||||
awk "BEGIN { print $* }"
|
||||
}
|
||||
|
||||
function warning {
|
||||
echo -e "${Yellow}Warning:$CLEAR $@" >&2
|
||||
}
|
||||
|
||||
function error {
|
||||
echo -e "${Red}Error:$CLEAR $@" >&2
|
||||
}
|
||||
|
||||
function info {
|
||||
echo -e "${Green}Info:$CLEAR $@"
|
||||
}
|
||||
|
||||
|
||||
## Flashes the screen until user presses a key
|
||||
function flasher
|
||||
{
|
||||
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
||||
}
|
||||
|
||||
## Beep until user presses a key
|
||||
function beeper
|
||||
{
|
||||
while true; do printf "\e[?5h\007"; sleep 0.25; printf "\e[?5l"; read -s -n -t1 && break; done;
|
||||
}
|
||||
|
||||
# set an alarm in seconds, minutes, hours
|
||||
function alarm {
|
||||
if [[ -z $1 ]]; then
|
||||
echo "Usage: alarm 5[s]|5m|1h"
|
||||
return 1
|
||||
fi
|
||||
local t
|
||||
if [[ $1 = *"m" ]]; then
|
||||
t=$((${1/m/}*60))
|
||||
extra="($1)"
|
||||
elif [[ $1 = *"h" ]]; then
|
||||
t=$((${1/h/}*3600))
|
||||
extra="($1)"
|
||||
elif [[ $1 = *"s" ]]; then
|
||||
t=${1/s/}
|
||||
else
|
||||
t=$1
|
||||
fi
|
||||
|
||||
echo "Setting a timer for $1 $extra"
|
||||
|
||||
sleep $t && beeper
|
||||
}
|
||||
|
||||
|
||||
## Simple http server for current directory (or path)
|
||||
function httpserver
|
||||
{
|
||||
(
|
||||
if [[ -d $1 ]]; then
|
||||
cd "$1" && echo "Starting webserver in $(realpath $1)/" || echo "directory: $1 does not exist" >&2 || exit 1
|
||||
else
|
||||
echo "Starting webserver in $PWD/"
|
||||
fi
|
||||
open "http://localhost:8000" &>/dev/null &
|
||||
python -m http.server 8000
|
||||
)
|
||||
}
|
||||
alias webserver='httpserver'
|
||||
|
||||
## Upload something using the 0x0.st service. Usage: upload [filename|url]
|
||||
function upload
|
||||
{
|
||||
local url
|
||||
if echo "$@" | grep -E -s -q "^http[s]://"; then
|
||||
url=true
|
||||
fi
|
||||
if [[ $url == true ]]; then
|
||||
out="$(curl -F"url=$@" https://0x0.st)"
|
||||
else
|
||||
out=$(curl --progress-bar -F"file=@$@" "https://0x0.st/")
|
||||
fi
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo -e "Failed uploading $@:\n $out" >&2
|
||||
return
|
||||
fi
|
||||
|
||||
echo -e "Done, file at:\t$out"
|
||||
if [[ $(uname) == "Darwin" ]]; then
|
||||
clipboard="pbcopy"
|
||||
elif command -v wl-copy &>/dev/null; then
|
||||
clipboard="wl-copy"
|
||||
elif command -v xclip &>/dev/null ; then
|
||||
clipboard="xclip"
|
||||
else
|
||||
clipboard="cat"
|
||||
fi
|
||||
echo -en "$out" | $clipboard
|
||||
}
|
||||
|
||||
## If connecting through ssh and reverse forwarding port 2222 (ssh -R 2222:localhost:22 ), this function allows to copy the files back to the machine one is connecting from by typing 'mecp filename' (configure the username for "localhost" in ~/.ssh/config or add an username)
|
||||
function mecp
|
||||
{
|
||||
rsync -r -P -e "ssh -p 2222" -R "$@" localhost:~/Desktop/
|
||||
}
|
||||
|
||||
|
||||
## generate a password using pwgen, generate_password 20 generates a 20 characters long password
|
||||
function generate_password
|
||||
{
|
||||
pwgen -1sycn $1
|
||||
}
|
||||
|
||||
## Generate a password from dev urandom using only printable characters
|
||||
function genpwd
|
||||
{
|
||||
if [[ $1 ]]; then
|
||||
strlen=$1
|
||||
else
|
||||
strlen=32
|
||||
fi
|
||||
# All characters excluding backlash
|
||||
env LC_CTYPE=C tr -dc '[:graph]\' < /dev/urandom | fold -w $strlen | head -n 1
|
||||
}
|
||||
|
||||
|
||||
## List defined functions in $DOTFILES/functions.sh
|
||||
function list_functions
|
||||
{
|
||||
grep --color=no -A 1 '^##' $DOTFILES/functions/*.zsh| sed -E 's/function (.*)/\1/g'
|
||||
}
|
||||
|
||||
|
||||
# MacOS only
|
||||
if [[ "$(uname)" == "Darwin" ]]; then
|
||||
## Create a RAM disk. Default size 1GB. If supplied, first argument defines the RAM disk size in GB
|
||||
function ramdisk
|
||||
{
|
||||
if [[ -e $1 ]]; then
|
||||
sizeingb=$1
|
||||
else
|
||||
sizeingb=1
|
||||
fi
|
||||
|
||||
# Numsectors is size in bytes / 512 (sector size in bytes)
|
||||
name='RAM_disk'
|
||||
sizeinbytes=$(($sizeingb*1000**3))
|
||||
NUMSECTORS=$(($sizeinbytes/512))
|
||||
mydev=$(hdiutil attach -nomount ram://$NUMSECTORS )
|
||||
# strip whitespace (hdiutil outputs a lot of spaces/tabs along with the device name)
|
||||
mydev=$(echo "$mydev"| xargs echo)
|
||||
newfs_hfs "$mydev"
|
||||
mkdir -p "/tmp/$name"
|
||||
mount -t hfs "$mydev" "/tmp/$name"
|
||||
echo "RAM Disk mounted: /tmp/$name"
|
||||
echo "To eject (destroy) RAM disk, use:"
|
||||
echo " $ diskutil eject $mydev"
|
||||
}
|
||||
fi
|
||||
|
||||
|
||||
# unzip file to directory with the same name of the zip file (without extension)
|
||||
function unzipd {
|
||||
zip_file="$1"
|
||||
filename=$(basename -- "$zip_file")
|
||||
extension="${filename##*.}"
|
||||
name="${filename%.*}"
|
||||
unzip -d "$name" "$zip_file"
|
||||
}
|
||||
|
||||
fvim() {
|
||||
if [[ -n "$@" ]]; then
|
||||
vim `fzf -q $@`
|
||||
else
|
||||
vim `fzf`
|
||||
fi
|
||||
}
|
||||
|
||||
# retry command until it succeeds (waiting one second or $RETRY_INTERVAL)
|
||||
function retry() {
|
||||
until $@; do sleep ${RETRY_INTERVAL:-1}; done
|
||||
}
|
||||
|
||||
|
||||
__completion_wrapper(){
|
||||
# Wrapper for completion functions.
|
||||
# These can be used to force loading of all completions
|
||||
# for the given command in order to access specialized
|
||||
# completion functions
|
||||
local _completion_function=$1
|
||||
local _completion_base=$2
|
||||
if ! command -v $_completion_function &>/dev/null; then
|
||||
$_completion_base
|
||||
fi
|
||||
$_completion_function
|
||||
}
|
||||
|
||||
|
||||
if command -v pacman &>/dev/null ; then
|
||||
pacbins() {
|
||||
pacman -Ql $1 | sed -n -e 's/.*\/bin\///p' | tail -n +2
|
||||
}
|
||||
_pacbins(){
|
||||
# fix completion
|
||||
__completion_wrapper _pacman_completions_installed_packages _pacman
|
||||
}
|
||||
compdef _pacbins pacbins
|
||||
fi
|
||||
|
||||
if command -v rustc &>/dev/null
|
||||
then
|
||||
rexplain() {
|
||||
rustc --explain $@ | bat --language=rust -
|
||||
}
|
||||
fi
|
||||
|
||||
if command -v fzf &>/dev/null ; then
|
||||
falias() {
|
||||
alias | fzf $@ | cut -d= -f 1
|
||||
}
|
||||
fi
|
||||
|
||||
make_backup() {
|
||||
name="$1"
|
||||
backup_name="backup_$1_$(date +%Y-%m-%d).tar.gz"
|
||||
echo "Backing up to $backup_name"
|
||||
tar -czf "$backup_name" "$1"
|
||||
echo "done"
|
||||
}
|
||||
|
||||
function find_by_mtime() {
|
||||
find $@ -printf "%T+ %p\n" | sort
|
||||
}
|
||||
|
||||
|
||||
function mangrep() {
|
||||
if [[ -z "$@" ]]; then
|
||||
echo "Usage: $0 <pattern> <command>"
|
||||
echo "Opens man page for <command> at the first match for <pattern>"
|
||||
return
|
||||
fi
|
||||
pattern=$1
|
||||
cmd=$2
|
||||
if [[ -z "$cmd" ]]; then
|
||||
man "$cmd"
|
||||
return
|
||||
fi
|
||||
|
||||
MANPAGER="less -p \"$pattern\"" man "$cmd"
|
||||
}
|
||||
|
||||
|
||||
# watches the given file and executes the given action whenever the file is changed. Usage: watch_file <file> <command>
|
||||
function watch_file() {
|
||||
if ! which inotifywait 2>&1 &>/dev/null ; then echo "$0 requires inotifywait"; return 1; fi
|
||||
|
||||
[[ -z "$1" ]] && echo "Usage: $0 <file> <action>" && return 1
|
||||
local file=$1
|
||||
shift
|
||||
|
||||
[[ -z "$@" ]] && echo "Usage: $0 <file> <action>" && return 1
|
||||
|
||||
local action="$@"
|
||||
local _bg_job_pid
|
||||
|
||||
local TRAPINT(){
|
||||
|
||||
if [[ -n ${_bg_job_pid} ]]; then
|
||||
kill -9 ${_bg_job_pid}
|
||||
fi
|
||||
yellow '\nQuitting.'
|
||||
break;
|
||||
}
|
||||
|
||||
{
|
||||
set +m # disable job control messages
|
||||
while true; do
|
||||
zsh -c "$action" &
|
||||
_bg_job_pid=$!
|
||||
disown
|
||||
echo -e "$Cyan ==> Running \"$action\" with pid=${_bg_job_pid}$CLEAR"
|
||||
|
||||
# block until the file has been written to
|
||||
inotifywait -e close_write "$file" &>/dev/null
|
||||
|
||||
# the job might have failed, ignore errors
|
||||
kill -9 ${_bg_job_pid} &>/dev/null || true
|
||||
done
|
||||
} always {
|
||||
# remove ctrl-c trap
|
||||
unset -f TRAPINT
|
||||
set -m # restore job control messages
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
if ! command -v pacman &>/dev/null; then return; fi
|
||||
|
||||
function pacpreview() {
|
||||
if ! command -v fzf &>/dev/null; then
|
||||
echo "Requires fzf! Quitting"
|
||||
return 1
|
||||
fi
|
||||
pacman -Slq | fzf --multi --preview 'grc --colour=on pacman -Si {1}' | xargs -ro sudo pacman -S
|
||||
}
|
|
@ -0,0 +1,82 @@
|
|||
mkvenv(){
|
||||
local source_venv force_create venv_name
|
||||
while getopts "sf" opt; do
|
||||
case $opt in
|
||||
s|source) source_venv=y ;;
|
||||
f|force) force_create=y ;;
|
||||
*) echo "Unknown option: $opt"; return 1 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND-1))
|
||||
if [[ -n $1 ]]; then
|
||||
venv_name=$1
|
||||
shift
|
||||
else
|
||||
venv_name=.venv
|
||||
fi
|
||||
# any other arguments are passed on to the `venv` module as flags/arguments
|
||||
|
||||
|
||||
if [[ -e ${venv_name} ]]; then
|
||||
if [[ -n ${force_create} ]]; then
|
||||
if [[ -n $VIRTUAL_ENV ]]; then # deactivate venv if enabled
|
||||
deactivate && warning "Deactivated existing virtualenv" || red "Could not run deactivate";
|
||||
fi
|
||||
rm -rf ${venv_name} && warning "Deleted existing virtualenv."
|
||||
else
|
||||
error "$(color $BOLD .venv) already exists. Run with -f to recreate it." >&2
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
info "Creating virtualenv ${venv_name}... "
|
||||
|
||||
if ! python -m virtualenv $@ ${venv_name} ; then
|
||||
error "Failed to create virtualenv. Is virtualenv installed? Try:\n $ pip install virtualenv"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [[ -z ${source_venv} ]]; then
|
||||
echo -n " done. Enable? [Y/n] "
|
||||
read source_venv
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
|
||||
if [[ $source_venv != "n" ]]; then
|
||||
source ${venv_name}/bin/activate && \
|
||||
echo -e " → $(color $BOLD Enabled!) 🐍 $(color $BOLD$PURPLE $(python --version | cut -d " " -f2 )) ($(color $BOLD$GREEN $(pip --version | cut -d " " -f -2)))"
|
||||
fi
|
||||
}
|
||||
|
||||
function enable_venv() {
|
||||
local root
|
||||
local activate
|
||||
|
||||
root=$(git rev-parse --show-toplevel 2>/dev/null)
|
||||
if [[ -z $root ]]; then root=$PWD; fi
|
||||
activate="$root/.venv/bin/activate"
|
||||
if [[ -f "$activate" ]]; then
|
||||
source "$activate"
|
||||
fi
|
||||
}
|
||||
|
||||
function disable_venv() {
|
||||
if [[ -z ${VIRTUAL_ENV} ]]; then
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ ! "$PWD" =~ $(dirname $VIRTUAL_ENV)}* ]]; then
|
||||
echo "Deactivating venv..."
|
||||
deactivate
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
if [[ -n $DOTFILES_AUTOSWITCH_VIRTUALENV ]]; then
|
||||
add-zsh-hook chpwd enable_venv
|
||||
add-zsh-hook chpwd disable_venv
|
||||
|
||||
enable_venv
|
||||
fi
|
|
@ -0,0 +1,22 @@
|
|||
#!/bin/zsh
|
||||
|
||||
function start_tracing {
|
||||
zmodload zsh/zprof
|
||||
zmodload zsh/datetime
|
||||
|
||||
setopt PROMPT_SUBST
|
||||
PS4+='+$EPOCHREALTIME %N:%i> '
|
||||
logfile=$(mktemp --tmpdir zsh_profile.XXXXXXXX)
|
||||
echo "logging to $logfile"
|
||||
exec 3>&2 2>$logfile
|
||||
setopt XTRACE
|
||||
}
|
||||
|
||||
function stop_tracing {
|
||||
unsetopt XTRACE
|
||||
exec 2>&3 3>&-
|
||||
zprof | tee zprof_out.log | vim -c "set buftype=nofile" -
|
||||
|
||||
zmodload -u zsh/zprof
|
||||
zmodload -u zsh/datetime
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
# open vim with a scratch window that can be discarded on exit.
|
||||
vimscratch() {
|
||||
local args
|
||||
# if running in a pipe, use stdin (-) as arg.
|
||||
# -t checks if the given FD is a terminal
|
||||
if [ ! -t 0 ] ; then
|
||||
stdin_arg="-"
|
||||
fi
|
||||
set +x
|
||||
if [[ -n "$1" ]]; then
|
||||
filetype=$1
|
||||
shift
|
||||
vim -c "set buftype=nofile" -c "set filetype=$filetype" $@ $stdin_arg
|
||||
else
|
||||
vim -c "set buftype=nofile" $filetype_arg $@ $stdin_arg
|
||||
fi
|
||||
|
||||
}
|
|
@ -0,0 +1,278 @@
|
|||
# Copyright (c) 2009 rupa deadwyler. Licensed under the WTFPL license, Version 2
|
||||
|
||||
# maintains a jump-list of the directories you actually use
|
||||
#
|
||||
# INSTALL:
|
||||
# * put something like this in your .bashrc/.zshrc:
|
||||
# . /path/to/z.sh
|
||||
# * cd around for a while to build up the db
|
||||
# * PROFIT!!
|
||||
# * optionally:
|
||||
# set $_Z_CMD in .bashrc/.zshrc to change the command (default z).
|
||||
# set $_Z_DATA in .bashrc/.zshrc to change the datafile (default ~/.z).
|
||||
# set $_Z_MAX_SCORE lower to age entries out faster (default 9000).
|
||||
# set $_Z_NO_RESOLVE_SYMLINKS to prevent symlink resolution.
|
||||
# set $_Z_NO_PROMPT_COMMAND if you're handling PROMPT_COMMAND yourself.
|
||||
# set $_Z_EXCLUDE_DIRS to an array of directories to exclude.
|
||||
# set $_Z_OWNER to your username if you want use z while sudo with $HOME kept
|
||||
#
|
||||
# USE:
|
||||
# * z foo # cd to most frecent dir matching foo
|
||||
# * z foo bar # cd to most frecent dir matching foo and bar
|
||||
# * z -r foo # cd to highest ranked dir matching foo
|
||||
# * z -t foo # cd to most recently accessed dir matching foo
|
||||
# * z -l foo # list matches instead of cd
|
||||
# * z -e foo # echo the best match, don't cd
|
||||
# * z -c foo # restrict matches to subdirs of $PWD
|
||||
# * z -x # remove the current directory from the datafile
|
||||
# * z -h # show a brief help message
|
||||
|
||||
[ -d "${_Z_DATA:-$HOME/.z}" ] && {
|
||||
echo "ERROR: z.sh's datafile (${_Z_DATA:-$HOME/.z}) is a directory."
|
||||
}
|
||||
|
||||
_z() {
|
||||
|
||||
local datafile="${_Z_DATA:-$HOME/.z}"
|
||||
|
||||
# if symlink, dereference
|
||||
[ -h "$datafile" ] && datafile=$(readlink "$datafile")
|
||||
|
||||
# bail if we don't own ~/.z and $_Z_OWNER not set
|
||||
[ -z "$_Z_OWNER" -a -f "$datafile" -a ! -O "$datafile" ] && return
|
||||
|
||||
_z_dirs () {
|
||||
[ -f "$datafile" ] || return
|
||||
|
||||
local line
|
||||
while read line; do
|
||||
# only count directories
|
||||
[ -d "${line%%\|*}" ] && echo "$line"
|
||||
done < "$datafile"
|
||||
return 0
|
||||
}
|
||||
|
||||
# add entries
|
||||
if [ "$1" = "--add" ]; then
|
||||
shift
|
||||
|
||||
# $HOME and / aren't worth matching
|
||||
[ "$*" = "$HOME" -o "$*" = '/' ] && return
|
||||
|
||||
# don't track excluded directory trees
|
||||
if [ ${#_Z_EXCLUDE_DIRS[@]} -gt 0 ]; then
|
||||
local exclude
|
||||
for exclude in "${_Z_EXCLUDE_DIRS[@]}"; do
|
||||
case "$*" in "$exclude"*) return;; esac
|
||||
done
|
||||
fi
|
||||
|
||||
# maintain the data file
|
||||
local tempfile="$datafile.$RANDOM"
|
||||
local score=${_Z_MAX_SCORE:-9000}
|
||||
_z_dirs | awk -v path="$*" -v now="$(date +%s)" -v score=$score -F"|" '
|
||||
BEGIN {
|
||||
rank[path] = 1
|
||||
time[path] = now
|
||||
}
|
||||
$2 >= 1 {
|
||||
# drop ranks below 1
|
||||
if( $1 == path ) {
|
||||
rank[$1] = $2 + 1
|
||||
time[$1] = now
|
||||
} else {
|
||||
rank[$1] = $2
|
||||
time[$1] = $3
|
||||
}
|
||||
count += $2
|
||||
}
|
||||
END {
|
||||
if( count > score ) {
|
||||
# aging
|
||||
for( x in rank ) print x "|" 0.99*rank[x] "|" time[x]
|
||||
} else for( x in rank ) print x "|" rank[x] "|" time[x]
|
||||
}
|
||||
' 2>/dev/null >| "$tempfile"
|
||||
# do our best to avoid clobbering the datafile in a race condition.
|
||||
if [ $? -ne 0 -a -f "$datafile" ]; then
|
||||
command rm -f "$tempfile"
|
||||
else
|
||||
[ "$_Z_OWNER" ] && command chown $_Z_OWNER:"$(id -ng $_Z_OWNER)" "$tempfile"
|
||||
command mv -f "$tempfile" "$datafile" || command rm -f "$tempfile"
|
||||
fi
|
||||
|
||||
# tab completion
|
||||
elif [ "$1" = "--complete" -a -s "$datafile" ]; then
|
||||
_z_dirs | awk -v q="$2" -F"|" '
|
||||
BEGIN {
|
||||
q = substr(q, 3)
|
||||
if( q == tolower(q) ) imatch = 1
|
||||
gsub(/ /, ".*", q)
|
||||
}
|
||||
{
|
||||
if( imatch ) {
|
||||
if( tolower($1) ~ q ) print $1
|
||||
} else if( $1 ~ q ) print $1
|
||||
}
|
||||
' 2>/dev/null
|
||||
|
||||
else
|
||||
# list/go
|
||||
local echo fnd last list opt typ
|
||||
while [ "$1" ]; do case "$1" in
|
||||
--) while [ "$1" ]; do shift; fnd="$fnd${fnd:+ }$1";done;;
|
||||
-*) opt=${1:1}; while [ "$opt" ]; do case ${opt:0:1} in
|
||||
c) fnd="^$PWD $fnd";;
|
||||
e) echo=1;;
|
||||
h) echo "${_Z_CMD:-z} [-cehlrtx] args" >&2; return;;
|
||||
l) list=1;;
|
||||
r) typ="rank";;
|
||||
t) typ="recent";;
|
||||
x) sed -i -e "\:^${PWD}|.*:d" "$datafile";;
|
||||
esac; opt=${opt:1}; done;;
|
||||
*) fnd="$fnd${fnd:+ }$1";;
|
||||
esac; last=$1; [ "$#" -gt 0 ] && shift; done
|
||||
[ "$fnd" -a "$fnd" != "^$PWD " ] || list=1
|
||||
|
||||
# if we hit enter on a completion just go there
|
||||
case "$last" in
|
||||
# completions will always start with /
|
||||
/*) [ -z "$list" -a -d "$last" ] && builtin cd "$last" && return;;
|
||||
esac
|
||||
|
||||
# no file yet
|
||||
[ -f "$datafile" ] || return
|
||||
|
||||
local cd
|
||||
cd="$( < <( _z_dirs ) awk -v t="$(date +%s)" -v list="$list" -v typ="$typ" -v q="$fnd" -F"|" '
|
||||
function frecent(rank, time) {
|
||||
# relate frequency and time
|
||||
dx = t - time
|
||||
return int(10000 * rank * (3.75/((0.0001 * dx + 1) + 0.25)))
|
||||
}
|
||||
function output(matches, best_match, common) {
|
||||
# list or return the desired directory
|
||||
if( list ) {
|
||||
if( common ) {
|
||||
printf "%-10s %s\n", "common:", common > "/dev/stderr"
|
||||
}
|
||||
cmd = "sort -n >&2"
|
||||
for( x in matches ) {
|
||||
if( matches[x] ) {
|
||||
printf "%-10s %s\n", matches[x], x | cmd
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if( common && !typ ) best_match = common
|
||||
print best_match
|
||||
}
|
||||
}
|
||||
function common(matches) {
|
||||
# find the common root of a list of matches, if it exists
|
||||
for( x in matches ) {
|
||||
if( matches[x] && (!short || length(x) < length(short)) ) {
|
||||
short = x
|
||||
}
|
||||
}
|
||||
if( short == "/" ) return
|
||||
for( x in matches ) if( matches[x] && index(x, short) != 1 ) {
|
||||
return
|
||||
}
|
||||
return short
|
||||
}
|
||||
BEGIN {
|
||||
gsub(" ", ".*", q)
|
||||
hi_rank = ihi_rank = -9999999999
|
||||
}
|
||||
{
|
||||
if( typ == "rank" ) {
|
||||
rank = $2
|
||||
} else if( typ == "recent" ) {
|
||||
rank = $3 - t
|
||||
} else rank = frecent($2, $3)
|
||||
if( $1 ~ q ) {
|
||||
matches[$1] = rank
|
||||
} else if( tolower($1) ~ tolower(q) ) imatches[$1] = rank
|
||||
if( matches[$1] && matches[$1] > hi_rank ) {
|
||||
best_match = $1
|
||||
hi_rank = matches[$1]
|
||||
} else if( imatches[$1] && imatches[$1] > ihi_rank ) {
|
||||
ibest_match = $1
|
||||
ihi_rank = imatches[$1]
|
||||
}
|
||||
}
|
||||
END {
|
||||
# prefer case sensitive
|
||||
if( best_match ) {
|
||||
output(matches, best_match, common(matches))
|
||||
exit
|
||||
} else if( ibest_match ) {
|
||||
output(imatches, ibest_match, common(imatches))
|
||||
exit
|
||||
}
|
||||
exit(1)
|
||||
}
|
||||
')"
|
||||
|
||||
if [ "$?" -eq 0 ]; then
|
||||
if [ "$cd" ]; then
|
||||
if [ "$echo" ]; then echo "$cd"; else builtin cd "$cd"; fi
|
||||
fi
|
||||
else
|
||||
return $?
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
if command -v fzf &>/dev/null; then
|
||||
# use fzf with z, from https://github.com/junegunn/fzf/wiki/Examples#integration-with-z
|
||||
z() {
|
||||
[ $# -gt 0 ] && _z "$*" && return
|
||||
cd "$(_z -l 2>&1 | fzf --height 40% --nth 2.. --reverse --inline-info +s --tac --query "${*##-* }" | sed 's/^[0-9,.]* *//')"
|
||||
}
|
||||
zz() {
|
||||
cd "$(_z -l 2>&1 | sed 's/^[0-9,.]* *//' | fzf -q "$_last_z_args")"
|
||||
}
|
||||
else
|
||||
alias ${_Z_CMD:-z}='_z 2>&1'
|
||||
fi
|
||||
|
||||
[ "$_Z_NO_RESOLVE_SYMLINKS" ] || _Z_RESOLVE_SYMLINKS="-P"
|
||||
|
||||
if type compctl >/dev/null 2>&1; then
|
||||
# zsh
|
||||
[ "$_Z_NO_PROMPT_COMMAND" ] || {
|
||||
# populate directory list, avoid clobbering any other precmds.
|
||||
if [ "$_Z_NO_RESOLVE_SYMLINKS" ]; then
|
||||
_z_precmd() {
|
||||
(_z --add "${PWD:a}" &)
|
||||
: $RANDOM
|
||||
}
|
||||
else
|
||||
_z_precmd() {
|
||||
(_z --add "${PWD:A}" &)
|
||||
: $RANDOM
|
||||
}
|
||||
fi
|
||||
[[ -n "${precmd_functions[(r)_z_precmd]}" ]] || {
|
||||
precmd_functions[$(($#precmd_functions+1))]=_z_precmd
|
||||
}
|
||||
}
|
||||
_z_zsh_tab_completion() {
|
||||
# tab completion
|
||||
local compl
|
||||
read -l compl
|
||||
reply=(${(f)"$(_z --complete "$compl")"})
|
||||
}
|
||||
compctl -U -K _z_zsh_tab_completion _z
|
||||
elif type complete >/dev/null 2>&1; then
|
||||
# bash
|
||||
# tab completion
|
||||
complete -o filenames -C '_z --complete "$COMP_LINE"' ${_Z_CMD:-z}
|
||||
[ "$_Z_NO_PROMPT_COMMAND" ] || {
|
||||
# populate directory list. avoid clobbering other PROMPT_COMMANDs.
|
||||
grep "_z --add" <<< "$PROMPT_COMMAND" >/dev/null || {
|
||||
PROMPT_COMMAND="$PROMPT_COMMAND"$'\n''(_z --add "$(command pwd '$_Z_RESOLVE_SYMLINKS' 2>/dev/null)" 2>/dev/null &);'
|
||||
}
|
||||
}
|
||||
fi
|
13
gitconfig
13
gitconfig
|
@ -1,6 +1,6 @@
|
|||
# vi:syntax=gitconfig
|
||||
[core]
|
||||
excludesfile = ~/.gitignore
|
||||
#[core] # DEPRECATED: excludesfile should be in ~/.config/git/ignore
|
||||
#excludesfile = ~/.gitignore
|
||||
|
||||
#[init]
|
||||
# templatedir = ~/.git_template
|
||||
|
@ -11,16 +11,17 @@ rebase = true
|
|||
|
||||
[merge]
|
||||
ff = only
|
||||
tool = vimdiff2
|
||||
tool = vimdiff
|
||||
|
||||
[mergetool]
|
||||
keepBackup = false
|
||||
|
||||
[diff]
|
||||
tool = vimdiff2
|
||||
tool = vimdiff
|
||||
|
||||
[difftool]
|
||||
prompt=true
|
||||
|
||||
[rebase]
|
||||
autostash = true
|
||||
autosquash = true
|
||||
|
@ -30,7 +31,9 @@ squash = true
|
|||
abbrevcommit = true
|
||||
|
||||
[format]
|
||||
#pretty = format:%C(yellow)commit %h%Cred%d %Creset%nAuthor: %Cblue%>(12)%an%n%CgreenDate: %ar%Creset%n%n%B
|
||||
|
||||
[alias]
|
||||
showtool = "!showci () { rev=${1:-HEAD}; git difftool $rev~1 $rev; }; showci $1"
|
||||
mylog = "log --pretty='format:👉 %C(yellow)commit: %h%C(auto)%d %Creset%nAuthor: %C(auto,cyan)%>(12)%an (%aE)%n%C(reset)Date: %C(auto,green)%ar%Creset%nContent: %s'"
|
||||
flog = "!flog() { git log --oneline $@ | fzf --multi --preview 'git -p show --color=always {+1}' --preview-window=right,60% | awk '{print $1}'; }; flog"
|
||||
taglist = "tag --list --sort=-creatordate --format=\"%(authordate:relative)%09│ %(refname:short)\""
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
c.TerminalInteractiveShell.editing_mode = "vi"
|
||||
c.TerminalInteractiveShell.mouse_support = True # prevents from selecting text
|
||||
c.TerminalInteractiveShell.true_color = True
|
||||
config = get_config()
|
||||
|
||||
config.TerminalInteractiveShell.editing_mode = "vi"
|
||||
config.TerminalInteractiveShell.mouse_support = True # prevents from selecting text
|
||||
config.TerminalInteractiveShell.true_color = True
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
import os
|
||||
|
||||
os.environ["PAGER"] = "bat --style=plain"
|
62
pdbrc.py
62
pdbrc.py
|
@ -1,53 +1,25 @@
|
|||
import os
|
||||
import pdb
|
||||
|
||||
if False:
|
||||
from pygments.styles import get_all_styles
|
||||
from pygments.styles import get_style_by_name
|
||||
|
||||
all_styles = get_all_styles()
|
||||
|
||||
all_styles = [
|
||||
"default",
|
||||
"emacs",
|
||||
"friendly",
|
||||
"colorful",
|
||||
"autumn",
|
||||
"murphy",
|
||||
"manni",
|
||||
"monokai",
|
||||
"perldoc",
|
||||
"pastie",
|
||||
"borland",
|
||||
"trac",
|
||||
"native",
|
||||
"fruity",
|
||||
"bw",
|
||||
"vim",
|
||||
"vs",
|
||||
"tango",
|
||||
"rrt",
|
||||
"xcode",
|
||||
"igor",
|
||||
"paraiso-light",
|
||||
"paraiso-dark",
|
||||
"lovelace",
|
||||
"algol",
|
||||
"algol_nu",
|
||||
"arduino",
|
||||
"rainbow_dash",
|
||||
"abap",
|
||||
"solarized-dark",
|
||||
"solarized-light",
|
||||
"sas",
|
||||
"stata",
|
||||
"stata-light",
|
||||
"stata-dark",
|
||||
"inkpot",
|
||||
]
|
||||
if os.getenv("THEME_PREFER_LIGHT"):
|
||||
pygments_style = "gruvbox-light"
|
||||
else:
|
||||
pygments_style = "gruvbox-dark"
|
||||
|
||||
|
||||
class Config(pdb.DefaultConfig):
|
||||
sticky_by_default = True
|
||||
pygments_formatter_class = "pygments.formatters.TerminalTrueColorFormatter"
|
||||
pygments_formatter_kwargs = {"style": "solarized-dark"}
|
||||
# prompt = "(Pdb++) "
|
||||
use_pygments = True
|
||||
pygments_formatter_class = "pygments.formatters.TerminalTrueColorFormatter"
|
||||
pygments_formatter_kwargs = {"style": get_style_by_name(pygments_style)}
|
||||
|
||||
editor = "vim"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from pygments.styles import get_all_styles
|
||||
|
||||
all_styles = get_all_styles()
|
||||
print(list(all_styles))
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||
|
||||
local ret_status="%(?:%{$fg_bold[green]%}➜%{$reset_color%}:%{$fg[red]%}➜%{$reset_color%})"
|
||||
local user="%(#:root@:)"
|
||||
PROMPT='[%{$fg[red]%}${user}%M%{$reset_color%}][:%{$fg[green]%}%c%{$reset_color%}]$(git_prompt_info) ${ret_status} '
|
||||
|
|
|
@ -1,45 +1,39 @@
|
|||
# vim:ft=zsh ts=2 sw=2 sts=2
|
||||
# color chart available at https://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html
|
||||
# %F{202}: orange
|
||||
# %K{202}: background orange
|
||||
# 255: white
|
||||
# See the prompt expansion section in `info zsh` for more info
|
||||
# brethil oh-my-zsh theme
|
||||
# See "EXPANSION OF PROMPT SEQUENCES" in `man zshmisc`
|
||||
# Note: Most of the expansions/color sequences can be tested using `print -P`
|
||||
|
||||
function user_prompt(){
|
||||
# root printed on a red background
|
||||
local USER_PROMPT="%(#.%K{160}%F{255}[root]%k%f.)"
|
||||
echo "$USER_PROMPT"
|
||||
# if [[ -n $SSH_CONNECTION ]]; then
|
||||
# local host="${purple}%B%m%b${default}"
|
||||
# host="%U${host}%u"
|
||||
# echo "$host"
|
||||
# fi
|
||||
}
|
||||
# prints hostname on an orange background if on an ssh connection, adds username if root
|
||||
|
||||
function job_prompt() {
|
||||
local JOB_PROMPT="%(1j.%B%K{202}%F{220} %j %k%b.)" # Shows jobs number on an orange background if there are background jobs
|
||||
echo "$JOB_PROMPT"
|
||||
}
|
||||
local user='%(!.%K{160}%F{255}%B%n%b%k%f.)' # prints 'root' on a red background if user is root
|
||||
local host='%K{202}%B%F{255}%m%f%k%b' # bold host name on an orange background
|
||||
local open_bracket='%(!.[.)'
|
||||
local close_bracket='%(!.].)'
|
||||
local at='%(!.@.)'
|
||||
local user_prompt
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
user_prompt="[${user}${at}${host}]"
|
||||
else
|
||||
user_prompt="${open_bracket}${user}${close_bracket}"
|
||||
fi
|
||||
|
||||
function shlvl_prompt() {
|
||||
local SHLVL_PROMPT
|
||||
if [[ -n "$BYOBU_PREFIX" ]]; then
|
||||
SHLVL_PROMPT="%(3L.%K{161}%F{255}%B $((SHLVL-1)) %f%b%k.)" # Shows SHLVL on a magenta background if SHLVL > 1
|
||||
else
|
||||
SHLVL_PROMPT="%(2L.%K{161}%F{255}%B %L %f%b%k.)" # Shows SHLVL on a magenta background if SHLVL > 1
|
||||
fi
|
||||
echo "$SHLVL_PROMPT"
|
||||
}
|
||||
local job_prompt="%(1j.%B%K{202}%F{220} %j %k%b.)"
|
||||
|
||||
function path_prompt(){
|
||||
# Shows last 3 items in path if there are more than 4
|
||||
local PATH_PROMPT="%F{white}[%F{green}%(4~:…/%3~:%~)%F{white}]%f"
|
||||
echo "$PATH_PROMPT"
|
||||
}
|
||||
|
||||
local shlvl_prompt
|
||||
# Shows SHLVL on a magenta background if SHLVL > 1 (2 if in a tmux session)
|
||||
if [[ -z "$TMUX" ]]; then
|
||||
shlvl_prompt="%(2L.%K{161}%F{255}%B %L %f%b%k.)"
|
||||
else
|
||||
shlvl_prompt="%(3L.%K{161}%F{255}%B $((SHLVL-1)) %f%b%k.)"
|
||||
fi
|
||||
|
||||
# Shows last 3 items in path if there are more than 4
|
||||
local path_prompt='[%F{green}%(4~:…/%3~:%~)%f]'
|
||||
|
||||
# PREFIX/SUFFIX are added before/after `git_prompt_info`
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX="%f%{$fg[yellow]%} "
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_PREFIX=" %f%{$fg[yellow]%} "
|
||||
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} |"
|
||||
|
||||
ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg[white]%}%{$fg[red]%}x%{$reset_color%}"
|
||||
ZSH_THEME_GIT_PROMPT_CLEAN=" %{$fg[white]%}%{$fg[green]%}√%{$reset_color%}"
|
||||
|
@ -57,70 +51,45 @@ ZSH_THEME_GIT_PROMPT_UNTRACKED="%B%F{red}?%b%f" # red
|
|||
|
||||
# The following are part of `git_remote_status`
|
||||
# ZSH_THEME_GIT_PROMPT_EQUAL_REMOTE="%{$fg[green]%}="
|
||||
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE="%F{255}>%f"
|
||||
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="%F{255}<%f"
|
||||
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="%F{255}<>%f"
|
||||
ZSH_THEME_GIT_PROMPT_AHEAD_REMOTE=">"
|
||||
ZSH_THEME_GIT_PROMPT_BEHIND_REMOTE="<"
|
||||
ZSH_THEME_GIT_PROMPT_DIVERGED_REMOTE="<>"
|
||||
|
||||
|
||||
local BOLD_PURPLE='%B%F{5}'
|
||||
local CLEAR='%f%b'
|
||||
local venv
|
||||
function virtualenv_info {
|
||||
[ -z "$VIRTUAL_ENV" ] && return
|
||||
|
||||
local BOLD_PURPLE='%B%F{5}'
|
||||
local CLEAR='%f%b'
|
||||
local venv
|
||||
venv="$(basename "$VIRTUAL_ENV")"
|
||||
if [[ "$venv" == ".venv" ]]; then
|
||||
venv="$(basename $(dirname "$VIRTUAL_ENV") )"
|
||||
fi
|
||||
|
||||
echo -n "$BOLD_PURPLE"
|
||||
echo -n " <$venv> "
|
||||
echo -n "$CLEAR"
|
||||
# bold (%B) purple (%F{5})
|
||||
echo -n " %B%F{5}<$venv>%b%f "
|
||||
}
|
||||
|
||||
function git_prompt() {
|
||||
if [[ -n "$(git status 2>/dev/null)" ]]; then
|
||||
local GIT_PROMPT="%F{255}($(git_prompt_info)%B%F{255}|%f%b$(git_prompt_status)$(git_remote_status)%F{255})%f"
|
||||
echo "$GIT_PROMPT"
|
||||
else
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
function check_last_exit_code() {
|
||||
local LAST_EXIT_CODE=$?
|
||||
if [[ $LAST_EXIT_CODE -ne 0 ]]; then
|
||||
local EXIT_CODE_PROMPT
|
||||
EXIT_CODE_PROMPT+="%B%F{88}-$LAST_EXIT_CODE-%f%b"
|
||||
echo "$EXIT_CODE_PROMPT"
|
||||
fi
|
||||
}
|
||||
local git_prompt='$(git_prompt_info)$(git_prompt_status)$(git_remote_status)'
|
||||
|
||||
function return_code_RPS1() {
|
||||
# For right-side prompt
|
||||
local return_code="%(?..$(check_last_exit_code))" # for RPS1
|
||||
echo "$return_code"
|
||||
}
|
||||
local return_code_RPS1='%(?..%B%F{88}-$?-%f%b)'
|
||||
|
||||
function ret_status() {
|
||||
local ret_status="%(?:%B%F{28} →%f%b:%{$fg[red]%} x%{$reset_color%})"
|
||||
echo "$ret_status"
|
||||
}
|
||||
|
||||
_PROMPT_PROTO='$(virtualenv_info)$(user_prompt)$(path_prompt)$(git_prompt)$(job_prompt)$(shlvl_prompt)'
|
||||
local success="%B%F{28} →%f%b"
|
||||
local failure="%B%{$fg[red]%} x%b%{$reset_color%}"
|
||||
local prompt_with_previous_return_status="%(?:$success:$failure) "
|
||||
|
||||
function prompt_too_long(){
|
||||
local zero='%([BSUbfksu]|([FK]|){*})'
|
||||
local stripped="$(echo ${(S%%)_PROMPT_PROTO//$~zero/} | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" ) "
|
||||
local prompt_len=${#stripped}
|
||||
local max_len=$(($COLUMNS/2))
|
||||
if [[ $prompt_len -ge $max_len ]]; then
|
||||
echo true
|
||||
fi
|
||||
# prints a newline if less than $COLUMNS/2 characters remain to the right margin, see end of `man zshmisc`
|
||||
echo "%-$((COLUMNS/2))(l..\n)"
|
||||
}
|
||||
PROMPT="$(echo "$_PROMPT_PROTO")"
|
||||
NEWLINE=$'\n'
|
||||
PROMPT+='${$(prompt_too_long)/true/${NEWLINE}}'
|
||||
PROMPT+='$(ret_status) '
|
||||
|
||||
## oh-my-zsh vi-mode plugins indicators:
|
||||
export MODE_INDICATOR="[%B%K{red}nav%k%b]" # red background
|
||||
export INSERT_MODE_INDICATOR="[%B%K{28}ins%k%b]" # green background
|
||||
|
||||
# put it all together
|
||||
PROMPT='$(virtualenv_info)'"${user_prompt}${path_prompt}${git_prompt}${job_prompt}${shlvl_prompt}$(prompt_too_long)${prompt_with_previous_return_status}"
|
||||
|
||||
# Right prompt is just return code and time
|
||||
RPS1='$(return_code_RPS1) %F{255}[%*]%f'
|
||||
RPS1="${return_code_RPS1}"'$(vi_mode_prompt_info)[%*]'
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
set-option -ga mouse
|
||||
|
||||
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
|
||||
set-option -g status-style bg=colour235,fg=colour136,default # bg=base02, fg=yellow
|
||||
|
||||
# default window title colors
|
||||
set-window-option -g window-status-style fg=colour244,bg=default,dim # fg=base0
|
||||
|
||||
# active window title colors
|
||||
set-window-option -g window-status-current-style fg=colour166,bg=default,bright # fg=orange
|
||||
|
||||
# pane border
|
||||
set-option -g pane-border-style fg=colour235 #fg=base02
|
||||
set-option -g pane-active-border-style fg=colour240 #fg=base01
|
||||
|
||||
# message text
|
||||
set-option -g message-style bg=colour235,fg=colour166 # bg=base02, fg=orange
|
||||
|
||||
# pane number display
|
||||
set-option -g display-panes-active-colour colour33 #blue
|
||||
set-option -g display-panes-colour colour166 #orange
|
||||
# clock
|
||||
set-window-option -g clock-mode-colour green #green
|
||||
|
||||
set -g history-limit 10000
|
||||
set -g status-interval 1
|
||||
set -g status-justify centre # center align window list
|
||||
set -g status-left-length 20
|
||||
set -g status-right-length 140
|
||||
set -g status-left '#[fg=green]#H #[fg=black]• #[fg=green,bright]#(uname -r | cut -c 1-6)#[default]'
|
||||
set -g status-right '#[fg=green,bg=default,bright]#(tmux-mem-cpu-load) #[fg=red,dim,bg=default]#(uptime | cut -f 4-5 -d " " | cut -f 1 -d ",") #[fg=white,bg=default]%a%l:%M:%S %p#[default] #[fg=blue]%Y-%m-%d'
|
||||
|
||||
# C-b is not acceptable -- Vim uses it
|
||||
set-option -g prefix C-a
|
||||
bind-key C-a last-window
|
||||
|
||||
# # Start numbering at 1
|
||||
# set -g base-index 1
|
||||
|
||||
# Allows for faster key repetition
|
||||
set -s escape-time 0
|
||||
set-option -sg escape-time 0
|
||||
|
||||
# Rather than constraining window size to the maximum size of any client
|
||||
# connected to the *session*, constrain window size to the maximum size of any
|
||||
# client connected to *that window*. Much more reasonable.
|
||||
setw -g aggressive-resize on
|
||||
|
||||
# Allows us to use C-a a <command> to send commands to a TMUX session inside
|
||||
# another TMUX session
|
||||
bind-key a send-prefix
|
||||
|
||||
# Activity monitoring
|
||||
# setw -g monitor-activity on
|
||||
set -g visual-activity on
|
||||
|
||||
# hjkl pane traversal
|
||||
bind h select-pane -L
|
||||
bind j select-pane -D
|
||||
bind k select-pane -U
|
||||
bind l select-pane -R
|
||||
|
||||
bind-key C command-prompt -p "Name of new window: " "new-window -n '%%'"
|
||||
|
||||
# reload config
|
||||
bind r source-file ~/.tmux.conf \; display-message "Config reloaded"
|
||||
|
||||
# auto window rename
|
||||
set-window-option -g automatic-rename
|
||||
|
||||
# https://github.com/edkolev/dots/blob/master/tmux.conf
|
||||
# Updates for tmux 1.9's current pane splitting paths.
|
||||
|
||||
# Colors
|
||||
# How to use true colors in vim under tmux? #1246 for 2.6 and higher
|
||||
# https://github.com/tmux/tmux/issues/1246:
|
||||
# set -g default-terminal "tmux-256color"
|
||||
# set -ga terminal-overrides ",*256col*:Tc"
|
||||
# 2.5 and lower:
|
||||
# set -g default-terminal "screen-256color"
|
||||
|
||||
# True color settings, see https://jdhao.github.io/2018/10/19/tmux_nvim_true_color/ for the details.
|
||||
set -g default-terminal "xterm-256color"
|
||||
# If terminal supports true color, use the following options.
|
||||
set -ga terminal-overrides ",xterm-256color*:Tc"
|
||||
|
||||
setw -g mode-keys vi
|
||||
|
||||
# use vim-like keys for splits and windows
|
||||
bind-key v split-window -h -c "#{pane_current_path}"
|
||||
bind-key s split-window -v -c "#{pane_current_path}"
|
||||
bind-key h select-pane -L
|
||||
bind-key j select-pane -D
|
||||
bind-key k select-pane -U
|
||||
bind-key l select-pane -R
|
||||
bind-key t swap-window -t +1
|
||||
bind-key T swap-window -t -1
|
||||
bind-key S choose-window 'join-pane -v -s "%%"'
|
||||
bind-key V choose-window 'join-pane -h -s "%%"'
|
||||
|
||||
bind-key W choose-window 'swap-window -t "%%"'
|
||||
|
||||
bind A command-prompt "rename-window \"%%\""
|
||||
|
||||
bind C customize-mode
|
|
@ -252,3 +252,5 @@ emacs -batch -l dunnet
|
|||
# BINARY CLOCK!
|
||||
watch -n 1 'echo "obase=2;`date +%s`" | bc'
|
||||
|
||||
# dbus introspection
|
||||
busctl -j --user introspect org.freedesktop.Notifications "/fr/emersion/Mako"
|
||||
|
|
|
@ -10,8 +10,8 @@ function! WinZoomToggle() abort
|
|||
wincmd |
|
||||
let w:WinZoomIsZoomed = 1
|
||||
elseif w:WinZoomIsZoomed == 1
|
||||
execute "resize " . w:WinZoomOldHeight
|
||||
execute "vertical resize " . w:WinZoomOldWidth
|
||||
execute 'resize ' . w:WinZoomOldHeight
|
||||
execute 'vertical resize ' . w:WinZoomOldWidth
|
||||
let w:WinZoomIsZoomed = 0
|
||||
endif
|
||||
endfunction
|
||||
|
@ -42,8 +42,8 @@ endfunction
|
|||
" Don't close window, when deleting a buffer
|
||||
command! Bclose call <SID>BufcloseCloseIt()
|
||||
function! <SID>BufcloseCloseIt()
|
||||
let l:currentBufNum = bufnr("%")
|
||||
let l:alternateBufNum = bufnr("#")
|
||||
let l:currentBufNum = bufnr('%')
|
||||
let l:alternateBufNum = bufnr('#')
|
||||
|
||||
if buflisted(l:alternateBufNum)
|
||||
buffer #
|
||||
|
@ -51,30 +51,35 @@ function! <SID>BufcloseCloseIt()
|
|||
bnext
|
||||
endif
|
||||
|
||||
if bufnr("%") == l:currentBufNum
|
||||
if bufnr('%') == l:currentBufNum
|
||||
new
|
||||
endif
|
||||
|
||||
if buflisted(l:currentBufNum)
|
||||
execute("bdelete! ".l:currentBufNum)
|
||||
execute('bdelete! '.l:currentBufNum)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! CmdLine(str)
|
||||
call feedkeys(":" . a:str)
|
||||
call feedkeys(':' . a:str)
|
||||
endfunction
|
||||
|
||||
" Call Git show on the selected text (must be a git ref)
|
||||
function! GitShowVisual() range
|
||||
execute 'Git show ' . @*
|
||||
endfunction
|
||||
|
||||
function! VisualSelection(direction, extra_filter) range
|
||||
let l:saved_reg = @"
|
||||
execute "normal! vgvy"
|
||||
execute 'normal! vgvy'
|
||||
|
||||
let l:pattern = escape(@", "\\/.*'$^~[]")
|
||||
let l:pattern = substitute(l:pattern, "\n$", "", "")
|
||||
let l:pattern = escape(@', "\\/.*'$^~[]")
|
||||
let l:pattern = substitute(l:pattern, '\n$', '', '')
|
||||
|
||||
if a:direction == 'gv'
|
||||
call CmdLine("Ack '" . l:pattern . "' " )
|
||||
elseif a:direction == 'replace'
|
||||
call CmdLine("%s" . '/'. l:pattern . '/')
|
||||
if a:direction ==# 'ack'
|
||||
call CmdLine("Ack '" . l:pattern . "' ")
|
||||
elseif a:direction ==# 'replace'
|
||||
call CmdLine('%s' . '/'. l:pattern . '/')
|
||||
endif
|
||||
|
||||
let @/ = l:pattern
|
||||
|
@ -83,5 +88,63 @@ endfunction
|
|||
|
||||
function! GitStatus()
|
||||
let [a,m,r] = GitGutterGetHunkSummary()
|
||||
return printf('+%d ~%d -%d', a, m, r)
|
||||
echo printf('+%d ~%d -%d', a, m, r)
|
||||
endfunction
|
||||
|
||||
command! GitStatus call GitStatus()
|
||||
|
||||
" Redirect command into scratch buffer. Stolen from romainl
|
||||
function! Redir(cmd, rng, start, end)
|
||||
for win in range(1, winnr('$'))
|
||||
if getwinvar(win, 'scratch')
|
||||
execute win . 'windo close'
|
||||
endif
|
||||
endfor
|
||||
if a:cmd =~? '^!'
|
||||
let cmd = a:cmd =~?' %'
|
||||
\ ? matchstr(substitute(a:cmd, ' %', ' ' . expand('%:p'), ''), '^!\zs.*')
|
||||
\ : matchstr(a:cmd, '^!\zs.*')
|
||||
if a:rng == 0
|
||||
let output = systemlist(cmd)
|
||||
else
|
||||
let joined_lines = join(getline(a:start, a:end), '\n')
|
||||
let cleaned_lines = substitute(shellescape(joined_lines), "'\\\\''", "\\\\'", 'g')
|
||||
let output = systemlist(cmd . ' <<< $' . cleaned_lines)
|
||||
endif
|
||||
else
|
||||
redir => output
|
||||
execute a:cmd
|
||||
redir END
|
||||
let output = split(output, "\n")
|
||||
endif
|
||||
vnew
|
||||
let w:scratch = 1
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
|
||||
call setline(1, output)
|
||||
endfunction
|
||||
|
||||
command! -nargs=1 -complete=command -bar -range Redir silent call Redir(<q-args>, <range>, <line1>, <line2>)
|
||||
|
||||
" Gets the man page for the given command
|
||||
function! Man(cmd)
|
||||
vnew
|
||||
let w:scratch=1
|
||||
setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile filetype=man nonumber norelativenumber
|
||||
let output = system('env COLUMNS=80 man ' . a:cmd)
|
||||
call setline(1, split(output, '\n'))
|
||||
endfunction
|
||||
|
||||
command! -nargs=1 -complete=shellcmd Vert Man silent call Man(<q-args>)
|
||||
|
||||
" Execute the given command and print it in a scratch buffer
|
||||
function! Cmd(cmd)
|
||||
let output = system(a:cmd)
|
||||
vnew
|
||||
let w:scratch=1
|
||||
" setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
|
||||
setlocal buftype=popup bufhidden=wipe nobuflisted noswapfile
|
||||
setlocal nonumber norelativenumber
|
||||
call setline(1, split(output, '\n'))
|
||||
endfunction
|
||||
|
||||
command! -nargs=1 -complete=shellcmd Cmd silent call Cmd(<q-args>)
|
||||
|
|
|
@ -1,64 +1,135 @@
|
|||
"""" PLUGINS CONFIGURATION
|
||||
let g:ack_default_options = " --cc --cpp --shell --python --html --js --vue"
|
||||
|
||||
" ALE configuration
|
||||
"
|
||||
let g:ale_python_auto_poetry = 1
|
||||
let g:ale_set_balloons = 1 " enable tooltips
|
||||
let g:ale_fixers = {
|
||||
\ '*': ['remove_trailing_lines', 'trim_whitespace'],
|
||||
\ 'bash': ['shfmt'],
|
||||
\ 'sh': ['shfmt'],
|
||||
\ 'json': ['prettier'],
|
||||
\ 'c': ['clang-format'],
|
||||
\ 'cpp': ['clang-format'],
|
||||
\ 'cmake': ['cmakeformat'],
|
||||
\ 'css': ['prettier'],
|
||||
\ 'html': ['prettier'],
|
||||
\ 'kotlin': ['ktlint'],
|
||||
\ 'markdown': ['prettier'],
|
||||
\ 'java': ['eclipselsp'],
|
||||
\ 'terraform': ['terraform'],
|
||||
\ 'yaml': ['prettier'],
|
||||
\ 'python': ['black', 'isort'],
|
||||
\ 'go': ['gofmt', "goimports"],
|
||||
\ 'python': ['ruff_format'],
|
||||
\ 'go': ['gofmt', 'goimports'],
|
||||
\ 'rust': ['rustfmt'],
|
||||
\ "javascript": ["prettier", "eslint"],
|
||||
\ "vue": ["prettier", "eslint"]
|
||||
\ 'sql': ['pgformatter'],
|
||||
\ 'java': ['clang-format'],
|
||||
\ 'javascript': ['prettier', 'eslint'],
|
||||
\ 'vue': ['prettier', 'eslint'],
|
||||
\}
|
||||
let g:ale_fixers_aliases = {'vue': ['vue', 'javascript']}
|
||||
let g:ale_fixers_aliases = {'vue': ['vue', 'javascript'], 'arduino': 'cpp'}
|
||||
|
||||
let g:ale_python_bandit_options = "-c banditrc"
|
||||
" let g:ale_python_pylint_options = "--rcfile pylintrc --disable=W0511" " if the rcfile does not exist, pylint will exit without linting
|
||||
let g:ale_python_pylint_options = "--disable=W0511"
|
||||
let g:ale_cpp_clang_options = '-std=c++17 -Wall -Wpedantic'
|
||||
let g:ale_cpp_gcc_options = '-std=c++17 -Wall -Wpedantic'
|
||||
let g:ale_arduino_ccls_executable = 'ccls'
|
||||
let g:ale_arduino_ccls_init_options = {}
|
||||
|
||||
let g:ale_popup_menu_enabled = 1
|
||||
let g:ale_python_bandit_options = '-c banditrc'
|
||||
let g:ale_python_pylint_options = '-j0 --disable=W0511'
|
||||
let g:ale_python_mypy_options = '--ignore-missing-imports'
|
||||
|
||||
" let g:ale_cpp_clang_options = '-std=c++17 -Wall -Wpedantic'
|
||||
" let g:ale_cpp_gcc_options = '-std=c++17 -Wall -Wpedantic'
|
||||
let g:ale_rust_cargo_use_clippy = 1
|
||||
|
||||
let g:ale_linters = {
|
||||
\ 'bash': ['bashlint', "shellcheck"],
|
||||
\ 'dockerfile': ["hadolint"],
|
||||
\ 'zsh': ['bashlint', "shellcheck"],
|
||||
\ 'python': ['pyls', 'pylint', 'bandit'],
|
||||
\ 'bash': ['bash-language-server', 'bashlint', 'shellcheck'],
|
||||
\ 'dockerfile': ['hadolint'],
|
||||
\ 'zsh': ['bashlint', 'shellcheck'],
|
||||
\ 'c': ['ccls', 'clangd'],
|
||||
\ 'cpp': ['clangd'],
|
||||
\ 'qml': ['qmllint'],
|
||||
\ 'python': ['pylsp', 'mypy', 'ruff'],
|
||||
\ 'go': ['gopls', 'gobuild'],
|
||||
\ 'rust': ['analyzer', 'rustc'],
|
||||
\ 'rust': ['analyzer', 'cargo'],
|
||||
\ 'yaml': ['yamllint'],
|
||||
\ 'javascript': ["yarn lint", "eslint", "vls"]
|
||||
\ 'javascript': ['yarn lint', 'eslint'],
|
||||
\ 'xml': ['android'],
|
||||
\ 'groovy': ['android'],
|
||||
\ 'java': ['eclipselsp', 'android'],
|
||||
\ 'kotlin': ['android', 'ktlint', 'languageserver'],
|
||||
\ 'vue': ['volar', 'eslint']
|
||||
\}
|
||||
let g:ale_linter_aliases = {'vue': ['vue', 'javascript']}
|
||||
|
||||
let g:ale_set_quickfix=1
|
||||
let g:ale_set_loclist=0
|
||||
let g:ale_linter_aliases = {'vue': ['vue', 'javascript'], 'arduino': 'cpp'}
|
||||
|
||||
" disable gradle signs/loclist as they conflict with ALE (vim-android)
|
||||
let g:gradle_loclist_show = 0
|
||||
let g:gradle_show_signs = 0
|
||||
|
||||
let g:ale_java_eclipselsp_path = '~/git/eclipse.jdt.ls'
|
||||
|
||||
let g:ale_yaml_yamllint_options = '--config .editorconfig'
|
||||
|
||||
let g:ale_open_list = 0
|
||||
let g:ale_keep_list_window_open = 1
|
||||
|
||||
let g:ale_lint_on_save = 1
|
||||
" let g:ale_lint_on_enter = 0 " uncomment if you do not want to lint files on open
|
||||
let g:ale_lint_on_enter = 1
|
||||
let g:ale_lint_on_insert_leave = 1
|
||||
" let g:ale_lint_on_text_changed = 1
|
||||
let g:ale_lint_on_text_changed = 0
|
||||
let g:ale_lint_delay = 2500 " lint 2.5 seconds after text has changed
|
||||
|
||||
augroup androiddev
|
||||
" avoid death by gradle
|
||||
autocmd! FileType java,kotlin let g:ale_lint_on_insert_leave = 0
|
||||
augroup END
|
||||
|
||||
|
||||
let g:ale_fix_on_save = 1
|
||||
let g:ale_cursor_detail=1
|
||||
let g:ale_detail_to_floating_preview = 1
|
||||
let g:ale_completion_enabled = 1
|
||||
" let g:ale_completion_autoimport = 1
|
||||
|
||||
let g:ale_lsp_show_message_severity = 'information'
|
||||
let g:ale_lsp_suggestions = 1
|
||||
let g:ale_rename_tsserver_find_in_comment = 1
|
||||
|
||||
let g:ale_sign_priority = 99
|
||||
let g:ale_sign_error = "xx"
|
||||
let g:ale_sign_warning = ">>"
|
||||
let g:ale_sign_info = "--"
|
||||
let g:ale_sign_error = 'xx'
|
||||
let g:ale_sign_warning = '>>'
|
||||
let g:ale_sign_info = '--'
|
||||
"let g:ale_sign_style_error =
|
||||
"let g:ale_sign_style_warning =
|
||||
highlight link ALEVirtualTextError ALEError
|
||||
highlight link ALEVirtualTextWarning ALEWarning
|
||||
|
||||
let g:ale_completion_symbols = {
|
||||
\ 'text': '',
|
||||
\ 'method': '',
|
||||
\ 'function': '',
|
||||
\ 'constructor': '',
|
||||
\ 'field': '',
|
||||
\ 'variable': '',
|
||||
\ 'class': '',
|
||||
\ 'interface': '',
|
||||
\ 'module': '',
|
||||
\ 'property': '',
|
||||
\ 'unit': 'unit',
|
||||
\ 'value': 'val',
|
||||
\ 'enum': '',
|
||||
\ 'keyword': 'keyword',
|
||||
\ 'snippet': '',
|
||||
\ 'color': 'color',
|
||||
\ 'file': '',
|
||||
\ 'reference': 'ref',
|
||||
\ 'folder': '',
|
||||
\ 'enum member': '',
|
||||
\ 'constant': '',
|
||||
\ 'struct': '',
|
||||
\ 'event': 'event',
|
||||
\ 'operator': '',
|
||||
\ 'type_parameter': 'type param',
|
||||
\ '<default>': 'v'
|
||||
\ }
|
||||
|
||||
packadd termdebug "useless shit
|
||||
|
||||
|
@ -66,34 +137,32 @@ packadd termdebug "useless shit
|
|||
let g:gitgutter_enabled = 1
|
||||
let g:gitgutter_sign_allow_clobber = 0 " do not allow gitgutter to overwrite signs
|
||||
let g:gitgutter_sign_priority = 50
|
||||
" let g:gitgutter_set_sign_backgrounds = 1
|
||||
" let g:gitgutter_override_sign_column_highlight = 0
|
||||
|
||||
" highlight clear GitGutterAdd GitGutterChange GitGutterModified GitGutterDelete SignColumn
|
||||
highlight SignColumn ctermbg=none
|
||||
|
||||
highlight GitGutterAdd ctermbg=none ctermfg=2
|
||||
highlight GitGutterChange ctermbg=none ctermfg=3
|
||||
highlight GitGutterDelete ctermbg=none ctermfg=1
|
||||
highlight GitGutterChangeDelete ctermbg=none ctermfg=1
|
||||
|
||||
let g:gitgutter_sign_added = '+'
|
||||
let g:gitgutter_sign_modified = '~'
|
||||
let g:gitgutter_sign_modified_removed = 'x'
|
||||
|
||||
" Improve vimdiff colors (deprecated, this was useful for the twilight256 colorscheme)
|
||||
" highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
|
||||
" highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
|
||||
" highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
|
||||
" highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
|
||||
|
||||
" Airline config
|
||||
set laststatus=2
|
||||
" set laststatus=2
|
||||
let g:airline#extensions#tabline#enabled = 1
|
||||
let g:airline#extensions#tabline#show_splits = 1
|
||||
" let g:airline#extensions#tabline#tab_nr_type = 2
|
||||
|
||||
let g:airline#extensions#tabline#buffer_idx_mode = 1
|
||||
nmap <leader>1 <Plug>AirlineSelectTab1
|
||||
nmap <leader>2 <Plug>AirlineSelectTab2
|
||||
nmap <leader>3 <Plug>AirlineSelectTab3
|
||||
nmap <leader>4 <Plug>AirlineSelectTab4
|
||||
nmap <leader>5 <Plug>AirlineSelectTab5
|
||||
nmap <leader>6 <Plug>AirlineSelectTab6
|
||||
nmap <leader>7 <Plug>AirlineSelectTab7
|
||||
nmap <leader>8 <Plug>AirlineSelectTab8
|
||||
nmap <leader>9 <Plug>AirlineSelectTab9
|
||||
nmap <leader>0 <Plug>AirlineSelectTab0
|
||||
nmap <leader>- <Plug>AirlineSelectPrevTab
|
||||
nmap <leader>+ <Plug>AirlineSelectNextTab
|
||||
|
||||
let g:airline_theme='gruvbox'
|
||||
" " default linenr symbol is '☰' and it sucks
|
||||
" let g:airline_symbols.linenr = ''
|
||||
" " powerline symbols
|
||||
if !exists('g:airline_symbols')
|
||||
let g:airline_symbols = {}
|
||||
endif
|
||||
|
@ -101,13 +170,53 @@ let g:airline_left_sep = ''
|
|||
let g:airline_left_alt_sep = ''
|
||||
let g:airline_right_sep = ''
|
||||
let g:airline_right_alt_sep = ''
|
||||
" let g:airline_symbols = {}
|
||||
let g:airline_symbols.branch = ''
|
||||
let g:airline_symbols.readonly = ''
|
||||
"let g:airline_symbols.linenr = '☰'
|
||||
let g:airline_symbols.colnr = ':'
|
||||
let g:airline_symbols.linenr = ''
|
||||
"let g:airline_symbols.maxlinenr = ''
|
||||
" let g:airline_symbols.dirty='⚡'
|
||||
let g:airline_symbols.maxlinenr = ''
|
||||
let g:airline_section_y = ''
|
||||
let g:airline#extensions#tagbar#enabled = 1
|
||||
let g:airline_section_x=' %{tagbar#currenttag("%s", "", "f")}'
|
||||
let g:airline#extensions#tagbar#flags = 's'
|
||||
let g:airline#extensions#tagbar#searchmethod = 'scoped-stl'
|
||||
|
||||
" only these functions will only be defined when lightline#gradle#... funtions
|
||||
" are defined, which happens when vim-android is loaded
|
||||
if exists('lightline#gradle#running')
|
||||
call airline#parts#define_function(
|
||||
\ 'gradle-running',
|
||||
\ 'lightline#gradle#running'
|
||||
\)
|
||||
|
||||
call airline#parts#define_function(
|
||||
\ 'gradle-errors',
|
||||
\ 'lightline#gradle#errors'
|
||||
\)
|
||||
|
||||
call airline#parts#define_function(
|
||||
\ 'gradle-warnings',
|
||||
\ 'lightline#gradle#warnings'
|
||||
\)
|
||||
|
||||
call airline#parts#define_function(
|
||||
\ 'gradle-project',
|
||||
\ 'lightline#gradle#project'
|
||||
\)
|
||||
|
||||
let g:airline_section_x= airline#section#create_right([
|
||||
\ 'filetype',
|
||||
\ 'gradle-running',
|
||||
\ 'gradle-errors',
|
||||
\ 'gradle-warnings'
|
||||
\])
|
||||
let g:gradle_glyph_gradle = ''
|
||||
let g:gradle_glyph_android = ''
|
||||
let g:gradle_glyph_error = ''
|
||||
let g:gradle_glyph_warning = ''
|
||||
let g:gradle_glyph_building = ''
|
||||
endif
|
||||
|
||||
|
||||
" These are the default mappings for vim-multi-cursor
|
||||
let g:multi_cursor_start_word_key = '<C-n>'
|
||||
|
@ -126,9 +235,48 @@ let g:indent_guides_start_level = 2
|
|||
let g:indent_guides_guide_size = 1
|
||||
|
||||
|
||||
let g:ctrlp_custom_ignore = {
|
||||
\ 'dir': '\v(target|build|dist|.venv)$',
|
||||
\ 'file': '\v\.(exe|so|dll)$',
|
||||
\ 'link': 'some_bad_symbolic_links',
|
||||
\ }
|
||||
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
|
||||
"" Gutentags"
|
||||
let g:gutentags_cache_dir = expand('~/.vim/ctags_cache/')
|
||||
|
||||
let g:gutentags_file_list_command = {
|
||||
\ 'markers': {
|
||||
\ '.git': 'git ls-files',
|
||||
\ '.hg': 'hg files',
|
||||
\ },
|
||||
\ }
|
||||
let g:gutentags_generate_on_empty_buffer = 1
|
||||
let g:gutentags_ctags_exclude = ['build', 'dist', '*css', '*json', '*yaml', '*md', '.venv', '*rst']
|
||||
let g:gutentags_ctags_extra_args = ['--tag-relative=always', ]
|
||||
"" nerdtree
|
||||
let NERDTreeIgnore=['__pycache__']
|
||||
|
||||
" ultisnips
|
||||
let g:UltiSnipsExpandTrigger='<tab>'
|
||||
let g:UltiSnipsJumpForwardTrigger='<c-j>'
|
||||
let g:UltiSnipsJumpBackwardTrigger='<c-k>'
|
||||
let g:UltiSnipsEditSplit='context'
|
||||
|
||||
"" Fzf
|
||||
let g:fzf_layout = { 'window': { 'width': 1, 'height': 0.9 } }
|
||||
let g:fzf_colors =
|
||||
\ { 'fg': ['fg', 'Normal'],
|
||||
\ 'bg': ['bg', 'Normal'],
|
||||
\ 'hl': ['fg', 'Comment'],
|
||||
\ 'fg+': ['fg', 'CursorLine', 'CursorColumn', 'Normal'],
|
||||
\ 'bg+': ['bg', 'CursorLine', 'CursorColumn'],
|
||||
\ 'hl+': ['fg', 'Statement'],
|
||||
\ 'info': ['fg', 'PreProc'],
|
||||
\ 'border': ['fg', 'Ignore'],
|
||||
\ 'prompt': ['fg', 'Conditional'],
|
||||
\ 'pointer': ['fg', 'Exception'],
|
||||
\ 'marker': ['fg', 'Keyword'],
|
||||
\ 'spinner': ['fg', 'Label'],
|
||||
\ 'header': ['fg', 'Comment'] }
|
||||
|
||||
autocmd! FileType fzf
|
||||
autocmd FileType fzf set laststatus=0 noshowmode noruler
|
||||
\| autocmd BufLeave <buffer> set laststatus=2 showmode ruler
|
||||
|
||||
|
||||
let g:goyo_width='85%'
|
||||
let g:goyo_linenr=1
|
||||
|
|
|
@ -11,10 +11,12 @@ call plug#begin('~/.vim/vim-plug')
|
|||
Plug 'tpope/vim-sensible'
|
||||
" Colorscheme
|
||||
Plug 'https://github.com/morhetz/gruvbox'
|
||||
|
||||
" Csv files 🤦
|
||||
Plug 'https://github.com/mechatroner/rainbow_csv', { 'for': 'csv' }
|
||||
|
||||
" Asynchronous Linting Engine
|
||||
Plug 'https://github.com/dense-analysis/ale'
|
||||
" Open files/recent files/tags quickly
|
||||
Plug 'https://github.com/ctrlpvim/ctrlp.vim'
|
||||
" Git
|
||||
Plug 'https://github.com/tpope/vim-fugitive'
|
||||
" Comment shit easily
|
||||
|
@ -24,24 +26,36 @@ Plug 'https://github.com/scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
|
|||
" status line
|
||||
Plug 'vim-airline/vim-airline'
|
||||
Plug 'vim-airline/vim-airline-themes'
|
||||
" Tags integration
|
||||
Plug 'https://github.com/preservim/tagbar'
|
||||
" Insert parentheses in pairs
|
||||
Plug 'https://github.com/jiangmiao/auto-pairs'
|
||||
Plug 'https://github.com/amix/open_file_under_cursor.vim'
|
||||
" Multi cursor
|
||||
Plug 'https://github.com/mg979/vim-visual-multi'
|
||||
" Easily explore open buffers
|
||||
Plug 'https://github.com/vim-scripts/bufexplorer.zip'
|
||||
" Search
|
||||
Plug 'https://github.com/mileszs/ack.vim'
|
||||
" Yank history
|
||||
Plug 'https://github.com/maxbrunsfeld/vim-yankstack'
|
||||
" Mark indentation level
|
||||
Plug 'https://github.com/nathanaelkane/vim-indent-guides'
|
||||
|
||||
" snipmate
|
||||
Plug 'https://github.com/MarcWeber/vim-addon-mw-utils'
|
||||
Plug 'https://github.com/tomtom/tlib_vim'
|
||||
Plug 'https://github.com/garbas/vim-snipmate'
|
||||
|
||||
if executable('meson')
|
||||
Plug 'https://github.com/igankevich/mesonic'
|
||||
endif
|
||||
|
||||
" fzf
|
||||
Plug 'junegunn/fzf'
|
||||
Plug 'junegunn/fzf.vim'
|
||||
" Open tags with fzf's :Tags
|
||||
if executable('ctags')
|
||||
Plug 'https://github.com/ludovicchabant/vim-gutentags.git'
|
||||
endif
|
||||
|
||||
" snippets
|
||||
if has('python3')
|
||||
Plug 'https://github.com/SirVer/ultisnips'
|
||||
Plug 'https://github.com/honza/vim-snippets'
|
||||
endif
|
||||
|
||||
" Git gutter line
|
||||
Plug 'https://github.com/airblade/vim-gitgutter'
|
||||
|
@ -52,16 +66,56 @@ Plug 'https://github.com/junegunn/goyo.vim'
|
|||
Plug 'https://github.com/mgedmin/coverage-highlight.vim'
|
||||
|
||||
"Languages
|
||||
Plug 'https://github.com/rust-lang/rust.vim'
|
||||
Plug 'https://github.com/vim-scripts/nginx.vim'
|
||||
Plug 'https://github.com/plasticboy/vim-markdown'
|
||||
Plug 'https://github.com/cespare/vim-toml'
|
||||
Plug 'https://github.com/bfrg/vim-cpp-modern', {'for': 'cpp'}
|
||||
Plug 'epheien/termdbg', {'for': ['c', 'cpp']}
|
||||
|
||||
Plug 'epheien/termdbg'
|
||||
if executable('cargo')
|
||||
Plug 'https://github.com/rust-lang/rust.vim', {'for': 'rust'}
|
||||
endif
|
||||
Plug 'https://github.com/vim-scripts/nginx.vim', {'for': 'nginx'}
|
||||
Plug 'https://github.com/plasticboy/vim-markdown', {'for': 'markdown'}
|
||||
Plug 'https://github.com/cespare/vim-toml', {'for': 'toml'}
|
||||
Plug 'https://github.com/vim-scripts/iptables', {'for': 'iptables'}
|
||||
if executable('vite')
|
||||
" TODO: check if plugin is still up-to-date
|
||||
Plug 'https://github.com/leafoftree/vim-vue-plugin', {'for': 'vue'}
|
||||
endif
|
||||
if executable('terraform')
|
||||
Plug 'https://github.com/hashivim/vim-terraform', {'for': 'terraform'}
|
||||
endif
|
||||
if executable('go')
|
||||
Plug 'https://github.com/fatih/vim-go', {'for': 'go'}
|
||||
endif
|
||||
|
||||
if executable('adb') && executable('gradle')
|
||||
Plug 'https://github.com/udalov/kotlin-vim', {'for': 'kotlin'}
|
||||
Plug 'https://github.com/hsanson/vim-android', {'for': 'java'}
|
||||
endif
|
||||
|
||||
if executable('qml')
|
||||
Plug 'https://github.com/peterhoeg/vim-qml', {'for': 'qml'}
|
||||
endif
|
||||
|
||||
if executable('pytest')
|
||||
Plug 'https://github.com/alfredodeza/pytest.vim', {'for': 'python'}
|
||||
endif
|
||||
|
||||
" Colorize hex codes and/or color strings
|
||||
Plug 'https://github.com/chrisbra/Colorizer'
|
||||
|
||||
" No RGB, no party
|
||||
let vim_razer = expand('~/projects_razer/vim-razer')
|
||||
if isdirectory(vim_razer)
|
||||
Plug vim_razer
|
||||
endif
|
||||
|
||||
if g:uname ==? 'Linux'
|
||||
Plug 'https://github.com/HiPhish/info.vim'
|
||||
endif
|
||||
|
||||
call plug#end()
|
||||
|
||||
" Install plugins if missing
|
||||
if ! isdirectory(expand('~/.vim/vim-plug'))
|
||||
PlugInstall
|
||||
endif
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
"""" Leader shortcuts
|
||||
|
||||
|
||||
let mapleader = ","
|
||||
let mapleader = ','
|
||||
" also use space as leader
|
||||
nmap <Space> <leader>
|
||||
map <Space> <leader>
|
||||
|
||||
nmap <leader>w :w!<CR>
|
||||
command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
|
||||
|
@ -11,102 +9,158 @@ command! W execute 'w !sudo tee % > /dev/null' <bar> edit!
|
|||
|
||||
"Reload vimrc on config change
|
||||
map <leader>e :e! ~/.vimrc<CR>
|
||||
" FIXME: This results in some weird conflict with lightline
|
||||
autocmd! bufwritepost ~/.vimrc source ~/.vimrc
|
||||
autocmd! bufwritepost $DOTFILES/vim/* source ~/.vimrc
|
||||
map <leader>ef :e! $DOTFILES/vim/functions.vim<CR>
|
||||
map <leader>ec :e! $DOTFILES/vim/plugins_config.vim<CR>
|
||||
map <leader>es :e! $DOTFILES/vim/shortcuts.vim<CR>
|
||||
map <leader>ep :e! $DOTFILES/vim/plugs.vim<CR>
|
||||
|
||||
" Quickly open a markdown buffer for scribble
|
||||
map <leader>x :e ~/buffer.md<CR>
|
||||
map <leader>xx :e ~/projects/work/buffer.md<CR>
|
||||
" Toggle paste mode on and off
|
||||
nmap <leader>pp :setlocal paste!<CR>
|
||||
|
||||
" Re-select the text block just pasted
|
||||
nnoremap <Leader>vv V`]
|
||||
|
||||
" Easy tab navigation with <leader>T
|
||||
nmap <leader>Tn :tabnext<CR>
|
||||
nmap <leader>TN :tabnew<CR>
|
||||
nmap <leader>Tp :tabprev<CR>
|
||||
nmap <leader>Tc :tabclose<CR>
|
||||
nmap <C-W>n :tabnext<CR>
|
||||
nmap <C-W>p :tabprev<CR>
|
||||
nmap <C-W>N :tabnew<CR>
|
||||
|
||||
" move betweween functions/methods/classes definition,
|
||||
" [m moves to the start of the previous method, ]m to the start of the next
|
||||
" zz centers the result
|
||||
map <Leader>] ]mzz
|
||||
map <Leader>[ [mzz
|
||||
|
||||
" open quickfix
|
||||
nmap <leader>cc :botright cope<CR>
|
||||
" open loclist
|
||||
nmap <leader>ll :botright lope<CR>
|
||||
" close quickfix (also see <leader>C below)
|
||||
nmap <leader>cx :hide<CR>
|
||||
nmap <leader>co ggVGy:tabnew<CR>:set syntax=qf<CR>pgg
|
||||
" next cope error
|
||||
map <leader>cn :cn<CR>
|
||||
map <leader>N :cnext<CR>
|
||||
" previous cope error
|
||||
map <leader>cp :cp<CR>
|
||||
map <leader>P :cprevious<CR>
|
||||
|
||||
map <silent> <leader><CR> :noh<CR> "disable highlighting for current word
|
||||
map <leader>ss :setlocal spell!<CR>
|
||||
"disable highlighting for current word
|
||||
map <silent> <leader><CR> :noh<CR>
|
||||
map <leader>S :setlocal spell!<CR>
|
||||
|
||||
nnoremap <leader>mk :bel copen<bar>silent (cargo run) !<bar>redraw!<CR>
|
||||
nnoremap <leader>M :bel copen<bar>silent make <bar>redraw!<CR>
|
||||
nnoremap <leader>wz :call WinZoomToggle()<CR>
|
||||
|
||||
nmap \ :Explore<CR>
|
||||
nnoremap <leader>C :close<CR>
|
||||
nnoremap <leader>q :close<CR>
|
||||
nnoremap <leader>B :Bclose<CR>
|
||||
nnoremap <leader>k :Ack<Space>
|
||||
nnoremap <leader>Q :close!<CR>
|
||||
nnoremap <leader>k :Rg<CR>
|
||||
|
||||
"" Fugitive
|
||||
nnoremap <leader>/ :Git<CR>
|
||||
nnoremap <leader>g :Git<CR>
|
||||
nnoremap <leader>gd :Git diff<CR>
|
||||
nnoremap <leader>/ :vert Git<CR>
|
||||
nnoremap <leader>\ :0Git<CR>
|
||||
nnoremap <leader>d :Gvdiffsplit<CR>
|
||||
nnoremap <leader>b :Git blame<CR>
|
||||
nnoremap <leader>gp :Git push<CR>
|
||||
nnoremap <leader>M :Git commit<CR>
|
||||
nnoremap <leader>gl :Commits<CR>
|
||||
nnoremap <leader>gL :BCommits<CR>
|
||||
nnoremap <leader>gc :Git commit<CR>
|
||||
nnoremap <leader>gpf :Git push --force-with-lease<CR>
|
||||
|
||||
"" Gitutter
|
||||
nnoremap <leader>u :GitGutterBufferToggle<CR>
|
||||
nnoremap <leader>L :GitGutterLineHighlightsToggle<CR>
|
||||
nmap <leader>hn <Plug>(GitGutterNextHunk)
|
||||
nmap <leader>hp <Plug>(GitGutterPrevHunk)
|
||||
nnoremap <leader>gp :GitGutterPrevHunk<CR>
|
||||
nnoremap <leader>gn :GitGutterNextHunk<CR>
|
||||
nnoremap <leader>gs :GitGutterStageHunk<CR>
|
||||
nnoremap <leader>gu :GitGutterUndoHunk<CR>
|
||||
|
||||
"" Ale
|
||||
|
||||
"" Coverage Highlight
|
||||
nnoremap <leader>H :HighlightCoverageForAll<CR>
|
||||
|
||||
" Ale
|
||||
nmap <silent> <C-k> <Plug>(ale_previous_wrap)
|
||||
nmap <silent> <C-j> <Plug>(ale_next_wrap)
|
||||
nmap <leader>R :ALERepeatSelection<CR>
|
||||
nmap <leader>sv :ALEGoToDefinition -vsplit<CR>
|
||||
nmap <leader>sh :ALEGoToDefinition -split<CR>
|
||||
nmap <leader>st :ALEGoToDefinition -tab<CR>
|
||||
nmap <leader>A :ALEGoToDefinition<CR>
|
||||
nmap <leader>n :ALEFindReferences<CR>
|
||||
nmap <leader>n :ALEFindReferences -quickfix <bar> copen<CR>
|
||||
nmap <leader>h :ALEHover<CR>
|
||||
nmap <leader>r :ALERename<CR>
|
||||
map <leader>` :ALELint<CR>
|
||||
|
||||
" call ack when pressing gv in visual
|
||||
vnoremap <silent> gv :call VisualSelection('gv', '')<CR>
|
||||
nmap <leader>` :ALELint<CR>
|
||||
nmap <leader>F :ALEFix<CR>
|
||||
nmap <leader>D :ALEToggle<CR>
|
||||
|
||||
map <leader>nn :NERDTreeToggle<CR>
|
||||
map <leader>o :BufExplorer<CR>
|
||||
|
||||
"" CtrlP
|
||||
"" fzf.vim
|
||||
" Quickly find and open a recently opened file
|
||||
" let g:ctrlp_map = '<C-f>'
|
||||
map <C-b> :CtrlPBuffer<CR>
|
||||
map <leader>j :CtrlP<CR>
|
||||
map <leader>b :CtrlPBuffer<CR>
|
||||
map <leader>f :CtrlPMRUFiles<CR>
|
||||
map <leader>t :CtrlPTag<CR>
|
||||
map <leader>o :Buffers<CR>
|
||||
map <leader>j :GFiles<CR>
|
||||
map <leader>J :Files<CR>
|
||||
|
||||
map <leader>f :History<CR>
|
||||
map <leader>T :BTags<CR>
|
||||
map <leader>t :Tags<CR>
|
||||
map <leader>l :Lines<CR>
|
||||
" FIXME: Not using CtrlP anymore, replace this with fzf
|
||||
""map <leader>c :CtrlPQuickfix<CR>
|
||||
map <leader>s :Snippets<CR>
|
||||
map <leader>; :Commands<CR>
|
||||
map <leader>m :Maps<CR>
|
||||
|
||||
let s:uname=''
|
||||
let s:uname = system('uname | tr -d "\n"') " Get platform name (stripping the trailing newline)
|
||||
if s:uname == "Darwin"
|
||||
"" Mac specific stuff
|
||||
elseif s:uname == "linux"
|
||||
"" Linux specific stuff
|
||||
" Wayland clipboard fix https://github.com/vim/vim/issues/5157
|
||||
xnoremap "+y :call system("wl-copy", @")<CR>
|
||||
nnoremap "+p :let @"=substitute(system("wl-paste --no-newline"), '<C-v><C-m>', '', 'g')<cr>p
|
||||
xnoremap "*y :call system("wl-copy --primary", @")<CR>
|
||||
nnoremap "*p :let @"=substitute(system("wl-paste --no-newline --primary"), '<C-v><C-m>', '', 'g')<cr>p
|
||||
"" Indent Guides
|
||||
map <leader>I :IndentGuidesToggle<CR>
|
||||
map <leader>i :set cursorcolumn!<CR>
|
||||
|
||||
"" Goyo
|
||||
nmap <leader>zz :Goyo<CR>
|
||||
|
||||
""" Tagbar
|
||||
nmap <F8> :TagbarToggle<CR>
|
||||
|
||||
""Misc stuff
|
||||
if g:uname ==? 'Darwin'
|
||||
"" Mac specific stuff
|
||||
elseif g:uname ==? 'Linux'
|
||||
"" Linux specific stuff
|
||||
xnoremap "+y y:call system("wl-copy", @")<cr>
|
||||
map "+p :<C-U>let @"=substitute(system('wl-paste --no-newline'), '<C-v><C-m>', '', 'g') \| exec 'normal! ' . v:count1 . 'p'<cr>
|
||||
else
|
||||
"" Unkown platform
|
||||
"" Unknown platform
|
||||
endif
|
||||
|
||||
" Add shortcuts to yank/paste to unnamed/unnamedplus clipboards
|
||||
noremap <Leader>y "*y
|
||||
noremap <Leader>p "*p
|
||||
noremap <Leader>Y "+y
|
||||
noremap <Leader>P "+p
|
||||
map <Leader>y "+y
|
||||
map <Leader>p "+p
|
||||
map <Leader>yp <Plug>yankstack_substitute_older_paste
|
||||
map <leader>yn <Plug>yankstack_substitute_newer_paste
|
||||
|
||||
" Insert a python breakpoint
|
||||
let @b = 'obreakpoint(€kr€ýa0j'
|
||||
|
||||
" visual mode mappings
|
||||
vnoremap <silent> <leader>k :call VisualSelection('LAck', '')<CR>
|
||||
vnoremap <silent> <leader>gs :call GitShowVisual()<CR>
|
||||
vnoremap <silent> <leader>r :call VisualSelection('replace', '')<CR>
|
||||
|
||||
nnoremap K :exe "Rg " . expand("<cword>")<cr>
|
||||
nnoremap GL :exe "Git log -L:" . expand("<cword>") . ":" . expand("%")<cr>
|
||||
autocmd FileType python nnoremap T :Pytest function --pdb<CR>
|
||||
|
||||
" Ultisnips
|
||||
map <Leader>ue :UltiSnipsEdit<cr>
|
||||
|
||||
|
||||
" A friggin python breakpoint. Invoke with @b "FIXME: make this decent
|
||||
let @b = 'A
breakpoint()ýajkj0'
|
||||
nmap <F5> <ESC>:Gradle assembleDebug<CR>
|
||||
nmap <F6> <ESC>:AndroidInstall debug<CR>
|
||||
nmap <F7> <ESC>:AndroidLaunch debug<CR>
|
||||
|
|
125
vim/vimrc
125
vim/vimrc
|
@ -1,3 +1,5 @@
|
|||
let g:uname = system('uname | tr -d "\n"') " Get platform name (stripping the trailing newline)
|
||||
|
||||
" Install all plugins
|
||||
source $DOTFILES/vim/plugs.vim
|
||||
|
||||
|
@ -5,16 +7,38 @@ source $DOTFILES/vim/plugs.vim
|
|||
set encoding=utf-8
|
||||
scriptencoding utf-8
|
||||
|
||||
" Style
|
||||
set background=dark
|
||||
"" Style
|
||||
" enable truecolor mode
|
||||
if has('termguicolors')
|
||||
set termguicolors
|
||||
else
|
||||
let &t_8f = "\<Esc>[38:2:%lu:%lu:%lum"
|
||||
let &t_8b = "\<Esc>[48:2:%lu:%lu:%lum"
|
||||
endif
|
||||
if !empty($THEME_PREFER_LIGHT)
|
||||
set background=light
|
||||
else
|
||||
set background=dark
|
||||
endif
|
||||
let g:gruvbox_contrast_dark='hard'
|
||||
let g:gruvbox_sign_column='bg0'
|
||||
|
||||
" Show some gui colors in term
|
||||
let g:gruvbox_guisp_fallback='bg'
|
||||
colorscheme gruvbox
|
||||
|
||||
" General stuff
|
||||
set nowrap
|
||||
set mouse=a
|
||||
set mousemodel=popup_setpos " allow for ALE code actions
|
||||
if has('mouse_sgr') " fixes unclickable panes after a specific column (~220?)
|
||||
set ttymouse=sgr
|
||||
else
|
||||
set ttymouse=xterm2
|
||||
end
|
||||
|
||||
set relativenumber number
|
||||
set foldlevelstart=3 foldmethod=syntax nofoldenable "without nofoldenable all folds are closed at startup"
|
||||
set ttymouse=xterm2 " fix mouse when used in tmux/byobu https://unix.stackexchange.com/q/50733
|
||||
set foldlevelstart=3 foldmethod=indent nofoldenable "without foldenable all folds are open at startup"
|
||||
|
||||
set nobackup nowb noswapfile " no need for backups of every file
|
||||
set history=10000
|
||||
|
@ -29,16 +53,87 @@ set lazyredraw
|
|||
set ignorecase smartcase " ignore case on search but be smart about it
|
||||
set hlsearch "highlight search results (using *)
|
||||
|
||||
set shiftwidth=4 tabstop=4
|
||||
set expandtab shiftwidth=4 tabstop=4 "always use spaces
|
||||
|
||||
" Completion menu config (see :h completopt)
|
||||
set completeopt=menu,menuone,noselect,noinsert
|
||||
" Show completion suggestions in popups instead of preview window
|
||||
set completeopt+=popup
|
||||
|
||||
" Highlight the line the cursor is on
|
||||
set cursorline
|
||||
|
||||
" Minimum fold size
|
||||
set foldminlines=3
|
||||
|
||||
" Timeout for combined keymaps (half a sec)
|
||||
set timeoutlen=500
|
||||
|
||||
" keep history the last 1000 opened files, 200 commands and 50 search
|
||||
" patterns. `h` persists bookmarks across sessions
|
||||
set viminfo='1000,<200,s50,h
|
||||
|
||||
autocmd FileType qf,ll setlocal wrap "quickfix,loclist
|
||||
autocmd FileType markdown setlocal wrap spell spelllang=it,en
|
||||
autocmd FileType yaml,yml setlocal shiftwidth=2 softtabstop=2 expandtab
|
||||
au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible
|
||||
autocmd FileType vue setlocal shiftwidth=2 softtabstop=2 expandtab
|
||||
|
||||
autocmd FileType go setlocal noexpandtab makeprg=go\ build
|
||||
autocmd FileType rust set makeprg=cargo\ build
|
||||
autocmd FileType python set keywordprg="pydoc"
|
||||
|
||||
syntax match jsonComment "//.*"
|
||||
syntax match jsonComment "\(/\*\)\|\(\*/\)"
|
||||
hi def link jsonComment Comment
|
||||
|
||||
|
||||
" Return to last edit position when opening files (from amix's vimrc)
|
||||
au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
augroup dotgit_diffs
|
||||
au BufRead .git/*.diff let b:ale_fix_on_save=0
|
||||
augroup END
|
||||
|
||||
" Remap VIM 0 to first non-blank character
|
||||
" map 0 ^
|
||||
augroup dvc
|
||||
au BufRead dvc.yaml let b:ale_fix_on_save=0
|
||||
au BufRead *.dvc let b:ale_fix_on_save=0
|
||||
au BufRead *.dvc set filetype=yaml
|
||||
augroup END
|
||||
|
||||
augroup ansible
|
||||
au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible
|
||||
augroup END
|
||||
|
||||
augroup githubactions
|
||||
au BufRead,BufNewFile */.github/*/*.y{,a}ml
|
||||
\ let b:ale_linters = {'yaml': ['actionlint'] }
|
||||
augroup END
|
||||
|
||||
augroup iptables
|
||||
au BufRead,BufNewFile rules.v[46],*.rules setlocal filetype=iptables
|
||||
augroup END
|
||||
|
||||
augroup vimconfig
|
||||
autocmd! bufwritepost ~/.vimrc source ~/.vimrc
|
||||
autocmd! bufwritepost $DOTFILES/vim/vimrc source ~/.vimrc
|
||||
autocmd! bufwritepost $DOTFILES/vim/shortcuts.vim source ~/.vimrc
|
||||
autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugInstall
|
||||
autocmd! bufwritepost $DOTFILES/vim/plugs.vim PlugUpdate
|
||||
augroup END
|
||||
|
||||
if has('persistent_undo')
|
||||
let undo_dir=$HOME . '/.vim/undo'
|
||||
if !isdirectory(undo_dir)
|
||||
call mkdir(undo_dir , 'p', 0700)
|
||||
endif
|
||||
let &undodir=undo_dir
|
||||
set undofile
|
||||
endif
|
||||
|
||||
augroup dotgit
|
||||
" Return to last edit position when opening files (from amix's vimrc)
|
||||
au BufReadPost * if ! exists('b:dotgitFolder') | if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
|
||||
" set a marker to avoid returning to the previous position in .git folders
|
||||
" (avoids returning to previous position for COMMIT_EDITMSG etc )
|
||||
au BufReadPost */.git/* let b:dotgitFolder = 1
|
||||
augroup END
|
||||
|
||||
" Bash like keys for the command line
|
||||
cnoremap <C-A> <Home>
|
||||
|
@ -48,12 +143,10 @@ cnoremap <C-K> <C-U>
|
|||
cnoremap <C-P> <Up>
|
||||
cnoremap <C-N> <Down>
|
||||
|
||||
try
|
||||
set undodir=~/.vim/temp_dirs/undodir
|
||||
set undofile
|
||||
catch
|
||||
endtry
|
||||
|
||||
source $DOTFILES/vim/plugins_config.vim
|
||||
source $DOTFILES/vim/shortcuts.vim
|
||||
source $DOTFILES/vim/functions.vim
|
||||
|
||||
if filereadable('.vimrc.local')
|
||||
source .vimrc.local
|
||||
endif
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
# vim:ft=zsh
|
||||
djui/alias-tips
|
||||
ohmyzsh/ohmyzsh path:lib
|
||||
ohmyzsh/ohmyzsh path:plugins/ansible
|
||||
ohmyzsh/ohmyzsh path:plugins/bgnotify
|
||||
ohmyzsh/ohmyzsh path:plugins/colored-man-pages
|
||||
ohmyzsh/ohmyzsh path:plugins/common-aliases
|
||||
ohmyzsh/ohmyzsh path:plugins/docker
|
||||
ohmyzsh/ohmyzsh path:plugins/docker-compose
|
||||
ohmyzsh/ohmyzsh path:plugins/fzf
|
||||
ohmyzsh/ohmyzsh path:plugins/git
|
||||
ohmyzsh/ohmyzsh path:plugins/golang
|
||||
ohmyzsh/ohmyzsh path:plugins/grc
|
||||
ohmyzsh/ohmyzsh path:plugins/pip
|
||||
ohmyzsh/ohmyzsh path:plugins/pyenv
|
||||
ohmyzsh/ohmyzsh path:plugins/pylint
|
||||
ohmyzsh/ohmyzsh path:plugins/sudo
|
||||
ohmyzsh/ohmyzsh path:plugins/vagrant
|
||||
ohmyzsh/ohmyzsh path:plugins/vi-mode
|
||||
zsh-users/zsh-autosuggestions
|
||||
zsh-users/zsh-completions
|
||||
zsh-users/zsh-syntax-highlighting
|
||||
joshskidmore/zsh-fzf-history-search
|
||||
ryutok/rust-zsh-completions
|
Loading…
Reference in New Issue