Compare commits

..

No commits in common. "master" and "pre-nix" have entirely different histories.

486 changed files with 4383 additions and 22156 deletions

1
.envrc
View File

@ -1 +0,0 @@
use flake

View File

@ -1,166 +0,0 @@
name: Arrow (AWS)
run-name: Arrow (AWS) - ${{ inputs.rebuild && 'Rebuild and ' || '' }}${{ inputs.action == 'create' && 'Create' || ( inputs.action == 'destroy' && 'Destroy' || 'No Action' ) }}
env:
TERRAFORM_DIRECTORY: hosts/arrow/aws
DEPLOY_IDENTITY_BASE64: ${{ secrets.DEPLOY_IDENTITY_BASE64 }}
ARROW_IDENTITY_BASE64: ${{ secrets.ARROW_IDENTITY_BASE64 }}
ZONE_NAME: masu.rs
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
on:
workflow_dispatch:
inputs:
rebuild:
type: boolean
default: false
action:
type: choice
required: true
default: create
options:
- create
- destroy
- nothing
size:
type: choice
required: false
options:
- t3a.small # 2 GB RAM / $10
permissions:
id-token: write
contents: write
jobs:
build-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Repo Code
uses: actions/checkout@v4
- name: Free Disk Space (Ubuntu)
if: inputs.rebuild && inputs.action != 'destroy'
uses: jlumbroso/free-disk-space@main
with:
tool-cache: true
# Enable access to KVM, required to build an image
- name: Enable KVM group perms
if: inputs.rebuild && inputs.action != 'destroy'
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
# Login to AWS
- name: AWS Assume Role
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::286370965832:role/github_actions_admin
aws-region: us-east-1
# Install Nix
- name: Install Nix
if: inputs.rebuild && inputs.action != 'destroy'
uses: cachix/install-nix-action@v20
# Build the image
- name: Build Image
if: inputs.rebuild && inputs.action != 'destroy'
run: nix build .#arrow-aws
- name: Upload Image to S3
if: inputs.rebuild && inputs.action != 'destroy'
run: |
aws s3 cp \
result/nixos-amazon-image-*.vhd \
s3://${{ secrets.IMAGES_BUCKET }}/arrow.vhd \
# Installs the Terraform binary and some other accessory functions.
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
# Checks whether Terraform is formatted properly. If this fails, you
# should install the pre-commit hook.
- name: Check Formatting
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform fmt -no-color -check -diff -recursive
# Connects to remote state backend and download providers.
- name: Terraform Init
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform init \
-backend-config="bucket=${{ secrets.TERRAFORM_STATE_BUCKET }}" \
-backend-config="key=arrow.tfstate"
# Deploys infrastructure or changes to infrastructure.
- name: Terraform Apply
if: inputs.action == 'create'
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
env:
TF_VAR_ec2_size: ${{ inputs.size }}
TF_VAR_images_bucket: ${{ secrets.IMAGES_BUCKET }}
run: |
terraform apply \
-auto-approve \
-input=false
# Removes infrastructure.
- name: Terraform Destroy
if: inputs.action == 'destroy'
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
env:
TF_VAR_ec2_size: ${{ inputs.size }}
TF_VAR_images_bucket: ${{ secrets.IMAGES_BUCKET }}
run: |
terraform destroy \
-auto-approve \
-input=false
- name: Get Host IP
if: inputs.action == 'create'
id: host
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: terraform output -raw host_ip
- name: Wait on SSH
if: inputs.action == 'create'
run: |
for i in $(seq 1 15); do
if $(nc -z -w 3 ${{ steps.host.outputs.stdout }} 22); then
exit 0
fi
sleep 10
done
- name: Write Identity Keys to Files
if: inputs.action == 'create'
run: |
echo "${{ env.DEPLOY_IDENTITY_BASE64 }}" | base64 -d > deploy_ed25519
chmod 0600 deploy_ed25519
echo "${{ env.ARROW_IDENTITY_BASE64 }}" | base64 -d > arrow_ed25519
chmod 0600 arrow_ed25519
- name: Copy Identity File to Host
if: inputs.action == 'create'
run: |
ssh -i deploy_ed25519 -o StrictHostKeyChecking=accept-new noah@${{ steps.host.outputs.stdout }} 'mkdir -pv .ssh'
scp -i deploy_ed25519 arrow_ed25519 noah@${{ steps.host.outputs.stdout }}:~/.ssh/id_ed25519
- name: Wipe Records
if: ${{ inputs.action == 'destroy' }}
run: |
RECORD_ID=$(curl --request GET \
--url https://api.cloudflare.com/client/v4/zones/${{ env.CLOUDFLARE_ZONE_ID }}/dns_records \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${{ env.CLOUDFLARE_API_TOKEN }}" | jq -r '.result[] | select(.name == "n8n2.${{ env.ZONE_NAME }}") | .id')
curl --request DELETE \
--url https://api.cloudflare.com/client/v4/zones/${{ env.CLOUDFLARE_ZONE_ID }}/dns_records/${RECORD_ID} \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${{ env.CLOUDFLARE_API_TOKEN }}"

View File

@ -1,154 +0,0 @@
name: Arrow
run-name: Arrow - ${{ inputs.rebuild && 'Rebuild and ' || '' }}${{ inputs.action == 'create' && 'Create' || ( inputs.action == 'destroy' && 'Destroy' || 'No Action' ) }}
env:
TERRAFORM_DIRECTORY: hosts/arrow/vultr
DEPLOY_IDENTITY_BASE64: ${{ secrets.DEPLOY_IDENTITY_BASE64 }}
ARROW_IDENTITY_BASE64: ${{ secrets.ARROW_IDENTITY_BASE64 }}
CLOUDFLARE_R2_ENDPOINT: "${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com"
AWS_ACCESS_KEY_ID: ${{ secrets.CLOUDFLARE_R2_ACCESS_KEY }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.CLOUDFLARE_R2_SECRET_KEY }}
AWS_DEFAULT_REGION: auto
AWS_ENDPOINT_URL_S3: "https://${{ secrets.CLOUDFLARE_ACCOUNT_ID }}.r2.cloudflarestorage.com"
TF_VAR_vultr_api_key: ${{ secrets.VULTR_API_KEY }}
ZONE_NAME: masu.rs
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ZONE_ID: ${{ secrets.CLOUDFLARE_ZONE_ID }}
on:
workflow_dispatch:
inputs:
rebuild:
type: boolean
default: false
action:
type: choice
required: true
default: create
options:
- create
- destroy
- nothing
plan:
type: choice
required: false
options:
- vc2-1c-1gb # 25 GB / $5
- vc2-1c-2gb # 55 GB / $10 (default)
- vc2-2c-2gb # 65 GB / $15
- vc2-2c-4gb # 80 GB / $20
- vc2-4c-8gb # 160 GB / $40
- vc2-6c-16gb # 320 GB / $80
jobs:
build-deploy:
name: Build and Deploy
runs-on: ubuntu-latest
steps:
- name: Checkout Repo Code
uses: actions/checkout@v4
# Enable access to KVM, required to build an image
- name: Enable KVM group perms
if: inputs.rebuild && inputs.action != 'destroy'
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm
# Install Nix
- name: Install Nix
if: inputs.rebuild && inputs.action != 'destroy'
uses: cachix/install-nix-action@v17
# Build the image
- name: Build Image
if: inputs.rebuild && inputs.action != 'destroy'
run: nix build .#arrow
- name: Upload Image to S3
if: inputs.rebuild && inputs.action != 'destroy'
run: |
aws s3 cp \
result/iso/nixos.iso \
s3://noahmasur-arrow-images/arrow.iso \
--endpoint-url "https://${{ env.CLOUDFLARE_R2_ENDPOINT }}"
# Installs the Terraform binary and some other accessory functions.
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
# Checks whether Terraform is formatted properly. If this fails, you
# should install the pre-commit hook.
- name: Check Formatting
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform fmt -no-color -check -diff -recursive
# Connects to remote state backend and download providers.
- name: Terraform Init
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: terraform init
# Deploys infrastructure or changes to infrastructure.
- name: Terraform Apply
if: inputs.action == 'create'
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
env:
TF_VAR_vultr_plan: ${{ inputs.plan }}
run: |
terraform apply \
-auto-approve \
-input=false
# Removes infrastructure.
- name: Terraform Destroy
if: inputs.action == 'destroy'
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: |
terraform destroy \
-auto-approve \
-input=false
- name: Get Host IP
if: inputs.action == 'create'
id: host
working-directory: ${{ env.TERRAFORM_DIRECTORY }}
run: terraform output -raw host_ip
- name: Wait on SSH
if: inputs.action == 'create'
run: |
for i in $(seq 1 15); do
if $(nc -z -w 3 ${{ steps.host.outputs.stdout }} 22); then
exit 0
fi
sleep 10
done
- name: Write Identity Keys to Files
if: inputs.action == 'create'
run: |
echo "${{ env.DEPLOY_IDENTITY_BASE64 }}" | base64 -d > deploy_ed25519
chmod 0600 deploy_ed25519
echo "${{ env.ARROW_IDENTITY_BASE64 }}" | base64 -d > arrow_ed25519
chmod 0600 arrow_ed25519
- name: Copy Identity File to Host
if: inputs.action == 'create'
run: |
ssh -i deploy_ed25519 -o StrictHostKeyChecking=accept-new noah@${{ steps.host.outputs.stdout }} 'mkdir -pv .ssh'
scp -i deploy_ed25519 arrow_ed25519 noah@${{ steps.host.outputs.stdout }}:~/.ssh/id_ed25519
- name: Wipe Records
if: ${{ inputs.action == 'destroy' }}
run: |
RECORD_ID=$(curl --request GET \
--url https://api.cloudflare.com/client/v4/zones/${{ env.CLOUDFLARE_ZONE_ID }}/dns_records \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${{ env.CLOUDFLARE_API_TOKEN }}" | jq -r '.result[] | select(.name == "n8n2.${{ env.ZONE_NAME }}") | .id')
curl --request DELETE \
--url https://api.cloudflare.com/client/v4/zones/${{ env.CLOUDFLARE_ZONE_ID }}/dns_records/${RECORD_ID} \
--header 'Content-Type: application/json' \
--header "Authorization: Bearer ${{ env.CLOUDFLARE_API_TOKEN }}"

View File

@ -1,20 +0,0 @@
name: Check Build
on:
workflow_dispatch: # allows manual triggering
jobs:
check:
name: Check
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
- name: Check Nixpkgs Inputs
uses: DeterminateSystems/flake-checker-action@v7
- name: Add Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Check the Flake
run: nix flake check

View File

@ -1,71 +0,0 @@
name: Update Flake
on:
workflow_dispatch: # allows manual triggering
schedule:
- cron: '33 3 * * 6' # runs weekly on Saturday at 03:33
permissions:
contents: write
pull-requests: write
checks: write
jobs:
lockfile:
name: Lockfile
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v11
with:
nix-package-url: https://releases.nixos.org/nix/nix-2.18.4/nix-2.18.4-x86_64-linux.tar.xz
- name: Check Nixpkgs Inputs
uses: DeterminateSystems/flake-checker-action@v7
- name: Add Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@v6
- name: Update flake.lock
uses: DeterminateSystems/update-flake-lock@v23
id: update
with:
pr-title: "Update flake.lock" # Title of PR to be created
pr-labels: | # Labels to be set on the PR
dependencies
automated
pr-body: |
Automated changes by the [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock) GitHub Action.
```
{{ env.GIT_COMMIT_MESSAGE }}
```
- name: Check the Flake
id: check
run: nix flake check
- name: Update Check Status
uses: LouisBrunner/checks-action@v1.6.1
if: always()
with:
token: ${{ secrets.GITHUB_TOKEN }}
name: Update Flake
conclusion: ${{ job.status }}
output: |
{"summary":"${{ steps.check.outputs.stdout }}"}
- name: Enable Pull Request Automerge
if: success()
run: |
gh pr merge \
--rebase \
--auto \
${{ steps.update.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ github.token }}
- name: Close Pull Request If Failed
if: failure()
run: |
gh pr close \
--comment "Auto-closing pull request" \
--delete-branch \
${{ steps.update.outputs.pull-request-number }}
env:
GH_TOKEN: ${{ github.token }}

17
.gitignore vendored
View File

@ -1,9 +1,14 @@
.DS_Store
newsboat.configlink/history.search
newsboat.configlink/urls
nvim.configlink/dirs/*
nvim.configlink/.netrwhist
nvim.configlink/plugin/**
nvim.configlink/plugged/**
nvim.configlink/autoload/**
fish.configlink/config.fish.bac
fish.configlink/functions/vim.fish
fish_variables
homebrew/*.lock.json
*.bak
*.db
*.qcow2
**/.direnv/**
result
private/**
templates/**/flake.lock
!private/**.age

21
LICENSE
View File

@ -1,21 +0,0 @@
MIT License
Copyright (c) 2022 Noah Masur
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40
Makefile Normal file
View File

@ -0,0 +1,40 @@
bootstrap:
./scripts/bootstrap
./scripts/setup_symlinks
all:
./scripts/bootstrap
./scripts/setup_symlinks
./scripts/setup_fish
./scripts/brews
./scripts/update_rust_analyzer
./scripts/rust
./scripts/cargos
./scripts/setup_cheatsheet
./scripts/setup_ytfzf
fish: bootstrap
./scripts/setup_fish
macos: bootstrap
./scripts/configure_macos
brews: bootstrap
./scripts/brews
casks: bootstrap
./scripts/casks
rust:
./scripts/update_rust_analyzer
./scripts/rust
cargos: rust
./scripts/rust
programs:
./scripts/setup_cheatsheet
./scripts/setup_ytfzf
python: brews
npm install -g pyright

View File

@ -1,96 +0,0 @@
# System Configurations
This repository contains configuration files for my NixOS, macOS, and WSL
hosts.
They are organized and managed by [Nix](https://nixos.org), so some of the
configuration may be difficult to translate to a non-Nix system.
## System Features
| Feature | Program | Configuration |
|----------------|-----------------------------------------------------|-----------------------------------------------------------------------------------|
| OS | [NixOS](https://nixos.org) | [Link](./platforms/nixos) |
| Display Server | [X11](https://www.x.org/wiki/) | [Link](./platforms/nixos/modules/nmasur/profiles/gui.nix) |
| Compositor | [Picom](https://github.com/yshui/picom) | [Link](./platforms/home-manager/modules/nmasur/presets/services/picom.nix) |
| Window Manager | [i3](https://i3wm.org/) | [Link](./platforms/home-manager/modules/nmasur/presets/services/i3.nix) |
| Panel | [Polybar](https://polybar.github.io/) | [Link](./platforms/home-manager/modules/nmasur/presets/services/polybar.nix) |
| Font | [Victor Mono](https://rubjo.github.io/victor-mono/) | [Link](./platforms/home-manager/modules/nmasur/presets/fonts.nix) |
| Launcher | [Rofi](https://github.com/davatorium/rofi) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/rofi/default.nix) |
## User Features
| Feature | Program | Configuration |
|--------------|----------------------------------------------------------------------------------|-------------------------------------------------------------------------------|
| Dotfiles | [Home-Manager](https://github.com/nix-community/home-manager) | [Link](./platforms/home-manager) |
| Terminal | [Ghostty](https://sw.kovidgoyal.net/kitty/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/ghostty.nix) |
| Shell | [Fish](https://fishshell.com/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/fish.nix) |
| Shell Prompt | [Starship](https://starship.rs/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/starship.nix) |
| Colorscheme | [Gruvbox](https://github.com/morhetz/gruvbox) | [Link](./colorscheme/gruvbox/default.nix) |
| Wallpaper | [Road](https://gitlab.com/exorcist365/wallpapers/-/blob/master/gruvbox/road.jpg) | [Link](./hosts/x86_64-linux/tempest/default.nix) |
| Text Editor | [Neovim](https://neovim.io/) | [Link](./pkgs/applications/editors/neovim/nmasur/neovim/package.nix) |
| Browser | [Firefox](https://www.mozilla.org/en-US/firefox/new/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/firefox.nix) |
| E-Mail | [Aerc](https://aerc-mail.org/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/aerc.nix) |
| File Manager | [Nautilus](https://wiki.gnome.org/action/show/Apps/Files) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/nautilus.nix) |
| PDF Reader | [Zathura](https://pwmt.org/projects/zathura/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/zathura.nix) |
| Video Player | [mpv](https://mpv.io/) | [Link](./platforms/home-manager/modules/nmasur/presets/programs/mpv.nix) |
## macOS Features
| Feature | Program | Configuration |
|----------|---------------------------------------------|--------------------------------------|
| Keybinds | [Hammerspoon](https://www.hammerspoon.org/) | [Link](./platforms/home-manager/modules/nmasur/presets/services/hammerspoon/) |
# Diagram
![Diagram](https://github.com/nmasur/dotfiles/assets/7386960/4cc22285-cea1-4831-b387-a82241184381)
---
# Unique Configurations
This repo contains a few more elaborate elements of configuration.
- [Neovim config](./pkgs/applications/editors/neovim/nmasur/neovim/package.nix)
generated with Nix2Vim and source-controlled plugins,
differing based on installed LSPs, for example. - [Caddy
JSON](./platforms/nixos/modules/nmasur/presets/services/caddy.nix) file (routes,
etc.) based dynamically on enabled services rendered with Nix. - [Grafana
config](./platforms/nixos/modules/nmasur/presets/services/grafana/grafana.nix)
rendered with Nix. - Custom [secrets
deployment](./platforms/nixos/modules/secrets.nix) similar to agenix. - Base16
[colorschemes](./colorscheme/) applied to multiple applications, including
Firefox userChrome.
---
# Installation
Click [here](./docs/installation.md) for detailed installation instructions.
# Neovim
Try out my Neovim config with nix:
```bash
nix run github:nmasur/dotfiles#neovim
```
Or build it as a package:
```bash
nix build github:nmasur/dotfiles#neovim
```
If you already have a Neovim configuration, you may need to move it out of
`~/.config/nvim` or set `XDG_CONFIG_HOME` to another value; otherwise both
configs might conflict with each other.
# Flake Templates
You can also use the [templates](./templates/) as flakes for starting new
projects:
```bash
nix flake init --template github:nmasur/dotfiles#poetry
```

View File

@ -0,0 +1,840 @@
# Configuration for Alacritty, the GPU enhanced terminal emulator.
# Any items in the `env` entry below will be added as
# environment variables. Some entries may override variables
# set by alacritty itself.
#env:
# TERM variable
#
# This value is used to set the `$TERM` environment variable for
# each instance of Alacritty. If it is not present, alacritty will
# check the local terminfo database and use `alacritty` if it is
# available, otherwise `xterm-256color` is used.
#TERM: alacritty
#TERM: xterm-256color
window:
# Window dimensions (changes require restart)
#
# Specified in number of columns/lines, not pixels.
# If both are `0`, this setting is ignored.
dimensions:
columns: 130
lines: 50
# Window position (changes require restart)
#
# Specified in number of pixels.
# If the position is not set, the window manager will handle the placement.
#position:
# x: 0
# y: 0
# Window padding (changes require restart)
#
# Blank space added around the window in pixels. This padding is scaled
# by DPI and the specified value is always added at both opposing sides.
padding:
x: 20
y: 20
# Spread additional padding evenly around the terminal content.
#dynamic_padding: false
# Window decorations
#
# Values for `decorations`:
# - full: Borders and title bar
# - none: Neither borders nor title bar
#
# Values for `decorations` (macOS only):
# - transparent: Title bar, transparent background and title bar buttons
# - buttonless: Title bar, transparent background, but no title bar buttons
decorations: full
# Startup Mode (changes require restart)
#
# Values for `startup_mode`:
# - Windowed
# - Maximized
# - Fullscreen
#
# Values for `startup_mode` (macOS only):
# - SimpleFullscreen
startup_mode: SimpleFullscreen
# Window title
#title: Alacritty
# Window class (Linux/BSD only):
#class:
# Application instance name
#instance: Alacritty
# General application class
#general: Alacritty
# GTK theme variant (Linux/BSD only)
#
# Override the variant of the GTK theme. Commonly supported values are `dark` and `light`.
# Set this to `None` to use the default theme variant.
#gtk_theme_variant: None
scrolling:
# Maximum number of lines in the scrollback buffer.
# Specifying '0' will disable scrolling.
history: 10000
# Scrolling distance multiplier.
#multiplier: 3
# Font configuration
font:
# Normal (roman) font face
normal:
# Font family
#
# Default:
# - (macOS) Menlo
# - (Linux/BSD) monospace
# - (Windows) Consolas
#family: Fira Code
#family: Noto Sans Mono
# family: Fira Mono for Powerline
family: FiraMono Nerd Font
# The `style` can be specified to pick a specific face.
#style: Regular
# Bold font face
#bold:
# Font family
#
# If the bold family is not specified, it will fall back to the
# value specified for the normal font.
#family: monospace
# The `style` can be specified to pick a specific face.
#style: Bold
# Italic font face
#italic:
# Font family
#
# If the italic family is not specified, it will fall back to the
# value specified for the normal font.
#family: monospace
# The `style` can be specified to pick a specific face.
#style: Italic
# Bold italic font face
#bold_italic:
# Font family
#
# If the bold italic family is not specified, it will fall back to the
# value specified for the normal font.
#family: monospace
# The `style` can be specified to pick a specific face.
#style: Bold Italic
# Point size
size: 17.0
# Offset is the extra space around each character. `offset.y` can be thought of
# as modifying the line spacing, and `offset.x` as modifying the letter spacing.
#offset:
# x: 0
# y: 0
# Glyph offset determines the locations of the glyphs within their cells with
# the default being at the bottom. Increasing `x` moves the glyph to the right,
# increasing `y` moves the glyph upward.
#glyph_offset:
# x: 0
# y: 0
# Thin stroke font rendering (macOS only)
#
# Thin strokes are suitable for retina displays, but for non-retina screens
# it is recommended to set `use_thin_strokes` to `false`.
#use_thin_strokes: true
# If `true`, bold text is drawn using the bright color variants.
#draw_bold_text_with_bright_colors: false
# Colors (Tomorrow Night)
#colors:
# Default colors
#primary:
# background: '#1d1f21'
# foreground: '#c5c8c6'
# Bright and dim foreground colors
#
# The dimmed foreground color is calculated automatically if it is not present.
# If the bright foreground color is not set, or `draw_bold_text_with_bright_colors`
# is `false`, the normal foreground color will be used.
#dim_foreground: '#828482'
#bright_foreground: '#eaeaea'
# Cursor colors
#
# Colors which should be used to draw the terminal cursor.
#
# Allowed values are CellForeground and CellBackground, which reference the
# affected cell, or hexadecimal colors like #ff00ff.
#cursor:
# text: CellBackground
# cursor: CellForeground
# Vi mode cursor colors
#
# Colors for the cursor when the vi mode is active.
#
# Allowed values are CellForeground and CellBackground, which reference the
# affected cell, or hexadecimal colors like #ff00ff.
#vi_mode_cursor:
# text: CellBackground
# cursor: CellForeground
# Selection colors
#
# Colors which should be used to draw the selection area.
#
# Allowed values are CellForeground and CellBackground, which reference the
# affected cell, or hexadecimal colors like #ff00ff.
#selection:
# text: CellBackground
# background: CellForeground
# Search colors
#
# Colors used for the search bar and match highlighting.
#
# Allowed values are CellForeground and CellBackground, which reference the
# affected cell, or hexadecimal colors like #ff00ff.
#search:
# matches:
# foreground: '#000000'
# background: '#ffffff'
#
# bar:
# background: CellForeground
# foreground: CellBackground
# Normal colors
#normal:
# black: '#1d1f21'
# red: '#cc6666'
# green: '#b5bd68'
# yellow: '#f0c674'
# blue: '#81a2be'
# magenta: '#b294bb'
# cyan: '#8abeb7'
# white: '#c5c8c6'
# Bright colors
#bright:
# black: '#666666'
# red: '#d54e53'
# green: '#b9ca4a'
# yellow: '#e7c547'
# blue: '#7aa6da'
# magenta: '#c397d8'
# cyan: '#70c0b1'
# white: '#eaeaea'
# Dim colors
#
# If the dim colors are not set, they will be calculated automatically based
# on the `normal` colors.
#dim:
# black: '#131415'
# red: '#864343'
# green: '#777c44'
# yellow: '#9e824c'
# blue: '#556a7d'
# magenta: '#75617b'
# cyan: '#5b7d78'
# white: '#828482'
# Indexed Colors
#
# The indexed colors include all colors from 16 to 256.
# When these are not set, they're filled with sensible defaults.
#
# Example:
# `- { index: 16, color: '#ff00ff' }`
#
#indexed_colors: []
# Bell
#
# The bell is rung every time the BEL control character is received.
#bell:
# Visual Bell Animation
#
# Animation effect for flashing the screen when the visual bell is rung.
#
# Values for `animation`:
# - Ease
# - EaseOut
# - EaseOutSine
# - EaseOutQuad
# - EaseOutCubic
# - EaseOutQuart
# - EaseOutQuint
# - EaseOutExpo
# - EaseOutCirc
# - Linear
#animation: EaseOutExpo
# Duration of the visual bell flash. A `duration` of `0` will disable the
# visual bell animation.
#duration: 0
# Visual bell animation color.
#color: '#ffffff'
# Bell Command
#
# This program is executed whenever the bell is rung.
#
# When set to `command: None`, no command will be executed.
#
# Example:
# command:
# program: notify-send
# args: ["Hello, World!"]
#
#command: None
# Background opacity
#
# Window opacity as a floating point number from `0.0` to `1.0`.
# The value `0.0` is completely transparent and `1.0` is opaque.
#background_opacity: 1.0
#selection:
#semantic_escape_chars: ",│`|:\"' ()[]{}<>\t"
# When set to `true`, selected text will be copied to the primary clipboard.
#save_to_clipboard: false
# Allow terminal applications to change Alacritty's window title.
#dynamic_title: true
#cursor:
# Cursor style
#
# Values for `style`:
# - ▇ Block
# - _ Underline
# - | Beam
#style: Block
# Vi mode cursor style
#
# If the vi mode cursor style is `None` or not specified, it will fall back to
# the style of the active value of the normal cursor.
#
# See `cursor.style` for available options.
#vi_mode_style: Block
# If this is `true`, the cursor will be rendered as a hollow box when the
# window is not focused.
#unfocused_hollow: true
# Thickness of the cursor relative to the cell width as floating point number
# from `0.0` to `1.0`.
#thickness: 0.15
# Live config reload (changes require restart)
#live_config_reload: true
# Shell
#
# You can set `shell.program` to the path of your favorite shell, e.g. `/bin/fish`.
# Entries in `shell.args` are passed unmodified as arguments to the shell.
#
# Default:
# - (macOS) /bin/bash --login
# - (Linux/BSD) user login shell
# - (Windows) powershell
shell:
program: /usr/local/bin/fish
args:
- --login
- --init-command
- tmux a -t noah || tmux new -s noah
# Startup directory
#
# Directory the shell is started in. If this is unset, or `None`, the working
# directory of the parent process will be used.
#working_directory: None
# WinPTY backend (Windows only)
#
# Alacritty defaults to using the newer ConPTY backend if it is available,
# since it resolves a lot of bugs and is quite a bit faster. If it is not
# available, the WinPTY backend will be used instead.
#
# Setting this option to `true` makes Alacritty use the legacy WinPTY backend,
# even if the ConPTY backend is available.
#winpty_backend: false
# Send ESC (\x1b) before characters when alt is pressed.
#alt_send_esc: true
#mouse:
# Click settings
#
# The `double_click` and `triple_click` settings control the time
# alacritty should wait for accepting multiple clicks as one double
# or triple click.
#double_click: { threshold: 300 }
#triple_click: { threshold: 300 }
# If this is `true`, the cursor is temporarily hidden when typing.
#hide_when_typing: false
#url:
# URL launcher
#
# This program is executed when clicking on a text which is recognized as a URL.
# The URL is always added to the command as the last parameter.
#
# When set to `launcher: None`, URL launching will be disabled completely.
#
# Default:
# - (macOS) open
# - (Linux/BSD) xdg-open
# - (Windows) explorer
#launcher:
# program: xdg-open
# args: []
# URL modifiers
#
# These are the modifiers that need to be held down for opening URLs when clicking
# on them. The available modifiers are documented in the key binding section.
#modifiers: None
# Mouse bindings
#
# Mouse bindings are specified as a list of objects, much like the key
# bindings further below.
#
# To trigger mouse bindings when an application running within Alacritty captures the mouse, the
# `Shift` modifier is automatically added as a requirement.
#
# Each mouse binding will specify a:
#
# - `mouse`:
#
# - Middle
# - Left
# - Right
# - Numeric identifier such as `5`
#
# - `action` (see key bindings)
#
# And optionally:
#
# - `mods` (see key bindings)
#mouse_bindings:
# - { mouse: Middle, action: PasteSelection }
# Key bindings
#
# Key bindings are specified as a list of objects. For example, this is the
# default paste binding:
#
# `- { key: V, mods: Control|Shift, action: Paste }`
#
# Each key binding will specify a:
#
# - `key`: Identifier of the key pressed
#
# - A-Z
# - F1-F24
# - Key0-Key9
#
# A full list with available key codes can be found here:
# https://docs.rs/glutin/*/glutin/event/enum.VirtualKeyCode.html#variants
#
# Instead of using the name of the keys, the `key` field also supports using
# the scancode of the desired key. Scancodes have to be specified as a
# decimal number. This command will allow you to display the hex scancodes
# for certain keys:
#
# `showkey --scancodes`.
#
# Then exactly one of:
#
# - `chars`: Send a byte sequence to the running application
#
# The `chars` field writes the specified string to the terminal. This makes
# it possible to pass escape sequences. To find escape codes for bindings
# like `PageUp` (`"\x1b[5~"`), you can run the command `showkey -a` outside
# of tmux. Note that applications use terminfo to map escape sequences back
# to keys. It is therefore required to update the terminfo when changing an
# escape sequence.
#
# - `action`: Execute a predefined action
#
# - ToggleViMode
# - SearchForward
# - SearchBackward
# - Copy
# - Paste
# - PasteSelection
# - IncreaseFontSize
# - DecreaseFontSize
# - ResetFontSize
# - ScrollPageUp
# - ScrollPageDown
# - ScrollHalfPageUp
# - ScrollHalfPageDown
# - ScrollLineUp
# - ScrollLineDown
# - ScrollToTop
# - ScrollToBottom
# - ClearHistory
# - Hide
# - Minimize
# - Quit
# - ToggleFullscreen
# - SpawnNewInstance
# - ClearLogNotice
# - ClearSelection
# - ReceiveChar
# - None
#
# (`mode: Vi` only):
# - Open
# - Up
# - Down
# - Left
# - Right
# - First
# - Last
# - FirstOccupied
# - High
# - Middle
# - Low
# - SemanticLeft
# - SemanticRight
# - SemanticLeftEnd
# - SemanticRightEnd
# - WordRight
# - WordLeft
# - WordRightEnd
# - WordLeftEnd
# - Bracket
# - ToggleNormalSelection
# - ToggleLineSelection
# - ToggleBlockSelection
# - ToggleSemanticSelection
# - SearchNext
# - SearchPrevious
# - SearchStart
# - SearchEnd
#
# (macOS only):
# - ToggleSimpleFullscreen: Enters fullscreen without occupying another space
#
# (Linux/BSD only):
# - CopySelection: Copies into selection buffer
#
# - `command`: Fork and execute a specified command plus arguments
#
# The `command` field must be a map containing a `program` string and an
# `args` array of command line parameter strings. For example:
# `{ program: "alacritty", args: ["-e", "vttest"] }`
#
# And optionally:
#
# - `mods`: Key modifiers to filter binding actions
#
# - Command
# - Control
# - Option
# - Super
# - Shift
# - Alt
#
# Multiple `mods` can be combined using `|` like this:
# `mods: Control|Shift`.
# Whitespace and capitalization are relevant and must match the example.
#
# - `mode`: Indicate a binding for only specific terminal reported modes
#
# This is mainly used to send applications the correct escape sequences
# when in different modes.
#
# - AppCursor
# - AppKeypad
# - Alt
#
# A `~` operator can be used before a mode to apply the binding whenever
# the mode is *not* active, e.g. `~Alt`.
#
# Bindings are always filled by default, but will be replaced when a new
# binding with the same triggers is defined. To unset a default binding, it can
# be mapped to the `ReceiveChar` action. Alternatively, you can use `None` for
# a no-op if you do not wish to receive input characters for that binding.
#
# If the same trigger is assigned to multiple actions, all of them are executed
# in the order they were defined in.
key_bindings:
- { key: F, mods: Super, action: ToggleSimpleFullscreen }
# Reference for escape codes: https://www.gaijin.at/en/infos/ascii-ansi-character-table
- { key: L, mods : Super, chars: "\x1F" } # CMD-L sends null key for fish
- { key: H, mods : Super|Shift, chars: "\x02p" } # CMD-SHIFT-H previous tmux window
- { key: L, mods : Super|Shift, chars: "\x02n" } # CMD-SHIFT-L next tmux window
- { key: Return, mods : Shift, chars: "\x1b[13;2u" }
- { key: Return, mods : Control, chars: "\x1b[13;5u" }
- { key: Return, mods : Control|Shift, chars: "\x1b[13;6u" }
- { key: N, mods: Command, action: SpawnNewInstance }
- { key: PageUp, action: ScrollPageUp }
- { key: PageUp, mode: Alt, chars: "\x1B[5~" }
- { key: PageUp, mods: Shift, chars: "\x1B[5~" }
- { key: PageDown, action: ScrollPageDown }
- { key: PageDown, mode: Alt, chars: "\x1B[6~" }
- { key: PageDown, mods: Shift, chars: "\x1B[6~" }
- { key: Home, action: ScrollToTop }
- { key: Home, mode: Alt, chars: "\x1BOH" }
- { key: Home, mods: Shift, chars: "\x1B[H" }
- { key: End, action: ScrollToBottom }
- { key: End, mode: Alt, chars: "\x1BOF" }
- { key: End, mods: Shift, chars: "\x1B[F" }
- { key: Tab, mods: Alt, chars: "\x1B\t" }
- { key: Tab, mods: Alt|Shift, chars: "\x1B\x1B[Z" }
- { key: Back, chars: "\x7F" }
- { key: Back, mods: Alt, chars: "\x1B\x7F" }
- { key: Back, mods: Alt|Shift, chars: "\x1B\x08" }
- { key: Space, mods: Control, chars: "\x00" }
- { key: Space, mods: Alt, chars: "\x20" }
- { key: Left, mods: Alt, chars: "\x1Bb" }
- { key: Left, mods: Alt|Shift, chars: "\x1B\x1B[D" }
- { key: Right, mods: Alt, chars: "\x1Bf" }
- { key: Right, mods: Alt|Shift, chars: "\x1B\x1B[C" }
- { key: Down, mods: Alt, chars: "\x1B\x1B[B" }
- { key: Down, mods: Alt|Shift, chars: "\x1B\x1B[B" }
- { key: Up, mods: Alt, chars: "\x1B\x1B[A" }
- { key: Up, mods: Alt|Shift, chars: "\x1B\x1B[A" }
- { key: A, mods: Alt, chars: "\x1Ba" }
- { key: A, mods: Alt|Shift, chars: "\x1BA" }
- { key: B, mods: Alt, chars: "\x1Bb" }
- { key: B, mods: Alt|Shift, chars: "\x1BB" }
- { key: C, mods: Alt, chars: "\x1Bc" }
- { key: C, mods: Alt|Shift, chars: "\x1BC" }
- { key: D, mods: Alt, chars: "\x1Bd" }
- { key: D, mods: Alt|Shift, chars: "\x1BD" }
- { key: E, mods: Alt, chars: "\x1Be" }
- { key: E, mods: Alt|Shift, chars: "\x1BE" }
- { key: F, mods: Alt, chars: "\x1Bf" }
- { key: F, mods: Alt|Shift, chars: "\x1BF" }
- { key: G, mods: Alt, chars: "\x1Bg" }
- { key: G, mods: Alt|Shift, chars: "\x1BG" }
- { key: H, mods: Alt, chars: "\x1Bh" }
- { key: H, mods: Alt|Shift, chars: "\x1BH" }
- { key: I, mods: Alt, chars: "\x1Bi" }
- { key: I, mods: Alt|Shift, chars: "\x1BI" }
- { key: J, mods: Alt, chars: "\x1Bj" }
- { key: J, mods: Alt|Shift, chars: "\x1BJ" }
- { key: K, mods: Alt, chars: "\x1Bk" }
- { key: K, mods: Alt|Shift, chars: "\x1BK" }
- { key: L, mods: Alt, chars: "\x1Bl" }
- { key: L, mods: Alt|Shift, chars: "\x1BL" }
- { key: M, mods: Alt, chars: "\x1Bm" }
- { key: M, mods: Alt|Shift, chars: "\x1BM" }
- { key: N, mods: Alt, chars: "\x1Bn" }
- { key: N, mods: Alt|Shift, chars: "\x1BN" }
- { key: O, mods: Alt, chars: "\x1Bo" }
- { key: O, mods: Alt|Shift, chars: "\x1BO" }
- { key: P, mods: Alt, chars: "\x1Bp" }
- { key: P, mods: Alt|Shift, chars: "\x1BP" }
- { key: Q, mods: Alt, chars: "\x1Bq" }
- { key: Q, mods: Alt|Shift, chars: "\x1BQ" }
- { key: R, mods: Alt, chars: "\x1Br" }
- { key: R, mods: Alt|Shift, chars: "\x1BR" }
- { key: S, mods: Alt, chars: "\x1Bs" }
- { key: S, mods: Alt|Shift, chars: "\x1BS" }
- { key: T, mods: Alt, chars: "\x1Bt" }
- { key: T, mods: Alt|Shift, chars: "\x1BT" }
- { key: U, mods: Alt, chars: "\x1Bu" }
- { key: U, mods: Alt|Shift, chars: "\x1BU" }
- { key: V, mods: Alt, chars: "\x1Bv" }
- { key: V, mods: Alt|Shift, chars: "\x1BV" }
- { key: W, mods: Alt, chars: "\x1Bw" }
- { key: W, mods: Alt|Shift, chars: "\x1BW" }
- { key: X, mods: Alt, chars: "\x1Bx" }
- { key: X, mods: Alt|Shift, chars: "\x1BX" }
- { key: Y, mods: Alt, chars: "\x1By" }
- { key: Y, mods: Alt|Shift, chars: "\x1BY" }
- { key: Z, mods: Alt, chars: "\x1Bz" }
- { key: Z, mods: Alt|Shift, chars: "\x1BZ" }
- { key: Key1, mods: Alt, chars: "\x1B1" }
- { key: Key1, mods: Alt|Shift, chars: "\x1B!" }
- { key: Key2, mods: Alt, chars: "\x1B2" }
- { key: Key2, mods: Alt|Shift, chars: "\x1B#" }
- { key: Key3, mods: Alt, chars: "\x1B3" }
- { key: Key3, mods: Alt|Shift, chars: "\x1B#" }
- { key: Key4, mods: Alt, chars: "\x1B4" }
- { key: Key4, mods: Alt|Shift, chars: "\x1B$" }
- { key: Key5, mods: Alt, chars: "\x1B5" }
- { key: Key5, mods: Alt|Shift, chars: "\x1B%" }
- { key: Key6, mods: Alt, chars: "\x1B6" }
- { key: Key6, mods: Alt|Shift, chars: "\x1B^" }
- { key: Key7, mods: Alt, chars: "\x1B7" }
- { key: Key7, mods: Alt|Shift, chars: "\x1B&" }
- { key: Key8, mods: Alt, chars: "\x1B8" }
- { key: Key8, mods: Alt|Shift, chars: "\x1B*" }
- { key: Key9, mods: Alt, chars: "\x1B9" }
- { key: Key9, mods: Alt|Shift, chars: "\x1B(" }
- { key: Key0, mods: Alt, chars: "\x1B0" }
- { key: Key0, mods: Alt|Shift, chars: "\x1B)" }
- { key: Minus, mods: Alt, chars: "\x1B-" }
- { key: Minus, mods: Alt|Shift, chars: "\x1B_" }
- { key: Equals, mods: Alt, chars: "\x1B=" }
- { key: Equals, mods: Alt|Shift, chars: "\x1B+" }
- { key: LBracket, mods: Alt, chars: "\x1B[" }
- { key: LBracket, mods: Alt|Shift, chars: "\x1B{" }
- { key: RBracket, mods: Alt, chars: "\x1B]" }
- { key: RBracket, mods: Alt|Shift, chars: "\x1B}" }
- { key: Backslash, mods: Alt, chars: "\x1B\\" }
- { key: Backslash, mods: Alt|Shift, chars: "\x1B|" }
- { key: Semicolon, mods: Alt, chars: "\x1B;" }
- { key: Semicolon, mods: Alt|Shift, chars: "\x1B:" }
- { key: Apostrophe, mods: Alt, chars: "\x1B'" }
- { key: Apostrophe, mods: Alt|Shift, chars: "\x1B\"" }
- { key: Comma, mods: Alt, chars: "\x1B," }
- { key: Comma, mods: Alt|Shift, chars: "\x1B<" }
- { key: Period, mods: Alt, chars: "\x1B." }
- { key: Period, mods: Alt|Shift, chars: "\x1B>" }
- { key: Slash, mods: Alt, chars: "\x1B/" }
- { key: Slash, mods: Alt|Shift, chars: "\x1B?" }
- { key: Grave, mods: Alt, chars: "\x1B`" }
- { key: Grave, mods: Alt|Shift, chars: "\x1B~" }
# - { key: E, mods: Alt, chars: "\x1be" } # Send ALT-E for fish
#- { key: Paste, action: Paste }
#- { key: Copy, action: Copy }
#- { key: L, mods: Control, action: ClearLogNotice }
#- { key: L, mods: Control, mode: ~Vi, chars: "\x0c" }
#- { key: PageUp, mods: Shift, mode: ~Alt, action: ScrollPageUp, }
#- { key: PageDown, mods: Shift, mode: ~Alt, action: ScrollPageDown }
#- { key: Home, mods: Shift, mode: ~Alt, action: ScrollToTop, }
#- { key: End, mods: Shift, mode: ~Alt, action: ScrollToBottom }
# Vi Mode
#- { key: Space, mods: Shift|Control, mode: Vi, action: ScrollToBottom }
#- { key: Space, mods: Shift|Control, action: ToggleViMode }
#- { key: Escape, mode: Vi, action: ClearSelection }
#- { key: I, mode: Vi, action: ScrollToBottom }
#- { key: I, mode: Vi, action: ToggleViMode }
#- { key: Y, mods: Control, mode: Vi, action: ScrollLineUp }
#- { key: E, mods: Control, mode: Vi, action: ScrollLineDown }
#- { key: G, mode: Vi, action: ScrollToTop }
#- { key: G, mods: Shift, mode: Vi, action: ScrollToBottom }
#- { key: B, mods: Control, mode: Vi, action: ScrollPageUp }
#- { key: F, mods: Control, mode: Vi, action: ScrollPageDown }
#- { key: U, mods: Control, mode: Vi, action: ScrollHalfPageUp }
#- { key: D, mods: Control, mode: Vi, action: ScrollHalfPageDown }
#- { key: Y, mode: Vi, action: Copy }
#- { key: Y, mode: Vi, action: ClearSelection }
#- { key: Copy, mode: Vi, action: ClearSelection }
#- { key: V, mode: Vi, action: ToggleNormalSelection }
#- { key: V, mods: Shift, mode: Vi, action: ToggleLineSelection }
#- { key: V, mods: Control, mode: Vi, action: ToggleBlockSelection }
#- { key: V, mods: Alt, mode: Vi, action: ToggleSemanticSelection }
#- { key: Return, mode: Vi, action: Open }
#- { key: K, mode: Vi, action: Up }
#- { key: J, mode: Vi, action: Down }
#- { key: H, mode: Vi, action: Left }
#- { key: L, mode: Vi, action: Right }
#- { key: Up, mode: Vi, action: Up }
#- { key: Down, mode: Vi, action: Down }
#- { key: Left, mode: Vi, action: Left }
#- { key: Right, mode: Vi, action: Right }
#- { key: Key0, mode: Vi, action: First }
#- { key: Key4, mods: Shift, mode: Vi, action: Last }
#- { key: Key6, mods: Shift, mode: Vi, action: FirstOccupied }
#- { key: H, mods: Shift, mode: Vi, action: High }
#- { key: M, mods: Shift, mode: Vi, action: Middle }
#- { key: L, mods: Shift, mode: Vi, action: Low }
#- { key: B, mode: Vi, action: SemanticLeft }
#- { key: W, mode: Vi, action: SemanticRight }
#- { key: E, mode: Vi, action: SemanticRightEnd }
#- { key: B, mods: Shift, mode: Vi, action: WordLeft }
#- { key: W, mods: Shift, mode: Vi, action: WordRight }
#- { key: E, mods: Shift, mode: Vi, action: WordRightEnd }
#- { key: Key5, mods: Shift, mode: Vi, action: Bracket }
#- { key: Slash, mode: Vi, action: SearchForward }
#- { key: Slash, mods: Shift, mode: Vi, action: SearchBackward }
#- { key: N, mode: Vi, action: SearchNext }
#- { key: N, mods: Shift, mode: Vi, action: SearchPrevious }
# (Windows, Linux, and BSD only)
#- { key: V, mods: Control|Shift, action: Paste }
#- { key: C, mods: Control|Shift, action: Copy }
#- { key: F, mods: Control|Shift, action: SearchForward }
#- { key: B, mods: Control|Shift, action: SearchBackward }
#- { key: C, mods: Control|Shift, mode: Vi, action: ClearSelection }
#- { key: Insert, mods: Shift, action: PasteSelection }
#- { key: Key0, mods: Control, action: ResetFontSize }
#- { key: Equals, mods: Control, action: IncreaseFontSize }
#- { key: Add, mods: Control, action: IncreaseFontSize }
#- { key: Subtract, mods: Control, action: DecreaseFontSize }
#- { key: Minus, mods: Control, action: DecreaseFontSize }
# (Windows only)
#- { key: Return, mods: Alt, action: ToggleFullscreen }
# (macOS only)
#- { key: K, mods: Command, mode: ~Vi, chars: "\x0c" }
#- { key: Key0, mods: Command, action: ResetFontSize }
#- { key: Equals, mods: Command, action: IncreaseFontSize }
#- { key: Add, mods: Command, action: IncreaseFontSize }
#- { key: Minus, mods: Command, action: DecreaseFontSize }
#- { key: K, mods: Command, action: ClearHistory }
#- { key: V, mods: Command, action: Paste }
#- { key: C, mods: Command, action: Copy }
#- { key: C, mods: Command, mode: Vi, action: ClearSelection }
#- { key: H, mods: Command, action: Hide }
#- { key: M, mods: Command, action: Minimize }
#- { key: Q, mods: Command, action: Quit }
#- { key: W, mods: Command, action: Quit }
#- { key: N, mods: Command, action: SpawnNewInstance }
#- { key: F, mods: Command|Control, action: ToggleFullscreen }
#- { key: F, mods: Command, action: SearchForward }
#- { key: B, mods: Command, action: SearchBackward }
#debug:
# Display the time it takes to redraw each frame.
#render_timer: false
# Keep the log file after quitting Alacritty.
#persistent_logging: false
# Log level
#
# Values for `log_level`:
# - None
# - Error
# - Warn
# - Info
# - Debug
# - Trace
#log_level: Warn
# Print all received window events.
#print_events: false

4
bin/biggest Executable file
View File

@ -0,0 +1,4 @@
#!/usr/local/bin/nu
ls | sort-by size | reverse | keep 10

3
bin/biggest-files Executable file
View File

@ -0,0 +1,3 @@
#!/usr/local/bin/nu
ls **/* | where type == File | sort-by size | reverse | keep 10

15
bin/bookmark Executable file
View File

@ -0,0 +1,15 @@
#!/bin/sh
URL=$1
TITLE=$2
DESCRIPTION=$3
FEED=$4
printf "\n\n## [%s](%s)\n%s\nFrom %s: added on [%s](%s.md).\n\n---\n" \
"$TITLE" \
"$URL" \
"$DESCRIPTION" \
"$FEED" \
"$TODAY_NOTE" \
"$TODAY_NOTE" \
>>"$NOTES_PATH/bookmarks.md"

13
bin/calc Executable file
View File

@ -0,0 +1,13 @@
#!/usr/bin/env ruby
#
# Run a quick calculation with Ruby
#
# Usage: calc "1/2"
class Integer
def /(other)
fdiv(other)
end
end
puts eval(ARGV.join(""))

View File

@ -0,0 +1,16 @@
FROM alpine:latest
COPY requirements.txt /
RUN apk update && \
apk add \
openssh \
python \
py-pip \
&& \
pip install -r requirements.txt
COPY connect_cloud.sh /
COPY connect_cloud.py /
ENTRYPOINT ["/connect_cloud.sh"]

View File

@ -0,0 +1,85 @@
#!/usr/bin/env python
"""Connect to Cloud instances"""
import os
import sys
import argparse
import boto3
# Initiate the parser
parser = argparse.ArgumentParser("Type the name of the connection you want")
parser.add_argument('profile', metavar='P', nargs='?',
help='an account to use')
parser.add_argument('environment', metavar='E', nargs='?',
help='an environment to specify')
args = parser.parse_args()
# Get AWS credentials profile
profile_map = {
'gs' : {
'profile': 'ghoststory',
'prod': 'id_rsa_gstory_prod.pem',
'dev': 'id_rsa_gstory_prod.pem',
'username': 'centos',
},
'di' : {
'profile': 't2indies',
'prod': 'disintegration-prod.pem',
'dev': 'disintegration-dev.pem',
'username': 'centos',
},
'pd' : {
'profile': 't2indies',
'prod': 't2indies-prod.pem',
'dev': 't2indies-dev.pem',
'username': 'centos',
},
'corp' : {
'profile': 't2corp',
'prod': 'take2games-corp.pem',
'dev': 'take2games-corp.pem',
'username': 'ec2-user',
},
'ksp' : {
'profile': 'kerbal',
'prod': 'kerbal_prod_key.pem',
'dev': 'kerbal_dev_key.pem',
'username': 'centos',
},
}
profile_dict = profile_map.get(args.profile)
profile = profile_dict['profile']
# Connect to AWS
session = boto3.Session(profile_name=profile)
client = session.client('ec2', verify=False)
response = client.describe_instances()
print(len(response['Reservations']), "total instances\n")
matched_instances = []
for instance_wrapper in response['Reservations']:
instance = instance_wrapper['Instances'][0]
is_matched_env = False
is_matched_role = False
for tag in instance.get('Tags', []):
if tag['Key'] == "site_env" and args.environment in tag['Value']:
is_matched_env = True
if tag['Key'] == "role" and tag['Value'] == 'host':
is_matched_role = True
if tag['Key'] == "Name":
instance['Name'] = tag['Value']
if is_matched_env and is_matched_role:
matched_instances.append(instance)
for instance in matched_instances:
print(instance['Name'])
print(instance['PublicIpAddress'])
print("")
with open("aws_connect", 'w') as outfile:
outfile.write("ssh-keyscan {} >> ~/.ssh/known_hosts\n".format(matched_instances[0]['PublicIpAddress']))
outfile.write("ssh -i ~/.ssh/{} {}@{}".format(profile_dict[args.environment], profile_dict['username'], matched_instances[0]['PublicIpAddress']))
os.chmod("aws_connect", 0o755)

View File

@ -0,0 +1,5 @@
#!/bin/sh
python connect_cloud.py "$@"
/aws_connect

View File

@ -0,0 +1,8 @@
boto3==1.9.239
botocore==1.12.239
docutils==0.15.2
jmespath==0.9.4
python-dateutil==2.8.0
s3transfer==0.2.1
six==1.12.0
urllib3==1.26.5

View File

@ -3,7 +3,7 @@
# Stop all containers
if [ "$(docker ps -a -q)" ]; then
echo "Stopping docker containers..."
docker stop "$(docker ps -a -q)"
docker stop $(docker ps -a -q)
else
echo "No running docker containers."
fi
@ -11,14 +11,14 @@ fi
# Remove all stopped containers
if [ "$(docker ps -a -q)" ]; then
echo "Removing docker containers..."
docker rm "$(docker ps -a -q)"
docker rm $(docker ps -a -q)
else
echo "No stopped docker containers."
fi
# Remove all untagged images
if docker images | grep -q "^<none>"; then
docker rmi "$(docker images | grep "^<none>" | awk '{print $3}')"
if [[ $(docker images | grep "^<none>") ]]; then
docker rmi $(docker images | rg "^<none>" | awk '{print $3}')
else
echo "No untagged docker images."
fi

37
bin/gh-repos Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
case $1 in
t2) organization="take-two" ;;
d2c) organization="take-two-t2gp" ;;
t2gp) organization="take-two-t2gp" ;;
pd) organization="private-division" ;;
dots) organization="playdots" ;;
*) organization="nmasur" ;;
esac
selected=$(gh repo list "$organization" \
--limit 50 \
--no-archived \
--json=name,description,isPrivate,updatedAt,primaryLanguage \
| jq -r '.[] | .name + "," + if .description == "" then "-" else .description |= gsub(","; " ") | .description end + "," + .updatedAt + "," + .primaryLanguage.name' \
| (echo "REPO,DESCRIPTION,UPDATED,LANGUAGE"; cat -) \
| column -s , -t \
| fzf \
--header-lines=1 \
--layout=reverse \
--bind "ctrl-o:execute:gh repo view -w ${organization}/{1}" \
--bind "shift-up:preview-half-page-up" \
--bind "shift-down:preview-half-page-down" \
--preview "GH_FORCE_TTY=49% gh repo view ${organization}/{1} | glow -" \
--preview-window up
)
[ -n "${selected}" ] && {
directory="$HOME/dev/work"
if [ $organization = "nmasur" ]; then directory="$HOME/dev/personal"; fi
repo=$(echo "${selected}" | awk '{print $1}')
repo_full="${organization}/${repo}"
if [ ! -d "${directory}/${repo}" ]; then
gh repo clone "$repo_full" "${directory}/${repo}"
fi
echo "${directory}/${repo}"
}

37
bin/jira-checkout Executable file
View File

@ -0,0 +1,37 @@
#!/bin/sh
# Adapted from: https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/
# Requires the following variables to be set:
# - ATLASSIAN_EMAIL
# - ATLASSIAN_API_TOKEN
# - JIRA_HOSTNAME
# - JIRA_PROJECT
choose_issue() {
jq_template='"\(.key): \(.fields.summary)"'
query="project=$JIRA_PROJECT AND status not in (\"Done\") AND assignee=currentUser()"
branch_name=$(
curl \
--data-urlencode "jql=$query" \
--get \
--user "$ATLASSIAN_EMAIL:$ATLASSIAN_API_TOKEN" \
--silent \
--compressed \
"https://$JIRA_HOSTNAME/rest/api/2/search" |
jq ".issues[] | $jq_template" |
sed -e 's/"\(.*\)"/\1/' |
fzf \
--preview='jira-details {1}' \
--preview-window=top:wrap |
sed -e 's/: /:/' -e 's/[^a-zA-Z0-9:]/-/g' |
awk -F ":" '{printf "%s/%s", $1, tolower($2)}'
)
echo "$branch_name"
}
issue_branch=$(choose_issue)
if [ -n "$issue_branch" ]; then
echo "git checkout -b \"$issue_branch\""
fi

38
bin/jira-details Executable file
View File

@ -0,0 +1,38 @@
#!/bin/sh
# Adapted from: https://seb.jambor.dev/posts/improving-shell-workflows-with-fzf/
# Requires the following variables to be set:
# - ATLASSIAN_EMAIL
# - ATLASSIAN_API_TOKEN
# - JIRA_HOSTNAME
# - JIRA_PROJECT (for other script)
issue_details() {
jira_key=$(echo "$1" | cut -d":" -f1)
jq_template='"'\
'# \(.key): \(.fields.summary)\n'\
'\n'\
'*Created*: \(.fields.created)\n'\
'*Status*: \(.fields.status.statusCategory.name)\n'\
'*Reporter*: \(.fields.reporter.displayName)\n'\
'*Priority*: \(.fields.priority.name)\n'\
"*Epic*: https://$JIRA_HOSTNAME/browse/\(.fields.customfield_10014)\n"\
'\n'\
'## Link\n\n'\
"https://$JIRA_HOSTNAME/browse/\(.key)\n"\
'\n'\
'## Description\n\n'\
'\(.fields.description)'\
'"'
curl \
--get \
--user "$ATLASSIAN_EMAIL:$ATLASSIAN_API_TOKEN" \
--silent \
--compressed \
"https://$JIRA_HOSTNAME/rest/api/2/issue/$jira_key" |
jq "$jq_template" |
xargs printf |
bat -l md --color always --style plain
}
issue_details "$1"

7
bin/kube-dashboard Executable file
View File

@ -0,0 +1,7 @@
#!/bin/sh
kubectl -n kube-system get secret $(kubectl -n kube-system get secret | grep dashboard-admin | awk '{print $1}') -o json | jq -j --raw-output '.data.token' | base64 --decode | pbcopy
open http://localhost:8001/api/v1/namespaces/default/services/https:kubernetes-dashboard:https/proxy/#!/login
kubectl proxy

3
bin/newest Executable file
View File

@ -0,0 +1,3 @@
#!/usr/local/bin/nu
ls | sort-by modified | reverse | keep 5

13
bin/nuke Executable file
View File

@ -0,0 +1,13 @@
#!/bin/sh
nuke() {
local pid
pid=$(ps -ef | grep -v ^root | sed 1d | fzf -m | awk '{print $2}')
if [ "x$pid" != "x" ]
then
echo $pid | xargs kill -${1:-9}
fi
}
nuke

View File

@ -8,13 +8,25 @@ TEXT_FILE="/tmp/ocr.txt"
IMAGE_FILE="/tmp/ocr.png"
function notify-send() {
/usr/bin/osascript -e "display notification \"$2\" with title \"OCR\""
osascript -e "display notification \"$2\" with title \"OCR\""
}
PATH="/usr/local/bin/:$PATH"
# Check if the needed dependencies are installed
dependencies=(tesseract)
for dependency in "${dependencies[@]}"; do
type -p "$dependency" &>/dev/null || {
# The reason why we are sending the error as a notification is because
# user is most likely going to run this script by binding it to their
# keyboard, therefor they cant see any text that is outputed using echo
notify-send "ocr" "Could not find '${dependency}', is it installed?"
exit 1
}
done
# Take screenshot by selecting the area
/usr/sbin/screencapture -i "$IMAGE_FILE"
screencapture -i "$IMAGE_FILE"
# Get the exit code of the previous command.
# So in this case, it is the screenshot command. If it did not exit with an
@ -31,26 +43,22 @@ STATUS=$?
# because tesseract adds .txt to the given file path anyways. So if we were to
# specify /tmp/ocr.txt as the file path, tesseract would out the text to
# /tmp/ocr.txt.txt
cd /tmp || {
echo "Failed to jump to directory."
exit 1
}
tesseract "$IMAGE_FILE" "${TEXT_FILE//\.txt/}"
# Check if the text was detected by checking number
# of lines in the file
LINES=$(wc -l <$TEXT_FILE)
LINES=$(wc -l < $TEXT_FILE)
if [ "$LINES" -eq 0 ]; then
notify-send "ocr" "no text was detected"
exit 1
notify-send "ocr" "no text was detected"
exit 1
fi
# Copy text to clipboard
# xclip -selection clip < "$TEXT_FILE"
/usr/bin/pbcopy <"$TEXT_FILE"
pbcopy < "$TEXT_FILE"
# Send a notification with the text that was grabbed using OCR
notify-send "ocr" "$(cat $TEXT_FILE)"
# notify-send "ocr" "$(cat $TEXT_FILE)"
# Clean up
# "Always leave the area better than you found it"

3
bin/oldest Executable file
View File

@ -0,0 +1,3 @@
#!/usr/local/bin/nu
ls | sort-by modified | keep 5

16
bin/pod Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
# Credit: https://github.com/junegunn/fzf/blob/master/ADVANCED.md
read -ra tokens < <(
kubectl get pods --all-namespaces |
fzf --info=inline --layout=reverse --header-lines=1 --border \
--prompt "$(kubectl config current-context | sed 's/-context$//')> " \
--header $'Press CTRL-O to open log in editor\n\n' \
--bind ctrl-/:toggle-preview \
--bind "ctrl-o:execute:${EDITOR:-vim} <(kubectl logs --namespace {1} {2}) > /dev/tty" \
--preview-window up,follow \
--preview 'kubectl logs --follow --tail=100000 --namespace {1} {2}' "$@"
)
[ ${#tokens} -gt 1 ] &&
kubectl exec -it --namespace "${tokens[0]}" "${tokens[1]}" -- /bin/sh

25
bin/quick-edit Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env bash
# Credit: https://github.com/junegunn/fzf/blob/master/ADVANCED.md
# Requires bash.
# 1. Search for text in files using Ripgrep
# 2. Interactively narrow down the list using fzf
# 3. Open the file in Vim
IFS=: read -ra selected < <(
rg \
--color=always \
--line-number \
--no-heading \
--smart-case \
--iglob !/Library/** \
--iglob !/System/** \
--iglob "!Users/$HOME/Library/*" \
"${*:-}" |
fzf --ansi \
--color "hl:-1:underline,hl+:-1:underline:reverse" \
--delimiter : \
--preview 'bat --color=always {1} --highlight-line {2}' \
--preview-window 'up,60%,border-bottom,+{2}+3/3,~3'
)
[ -n "${selected[0]}" ] && nvim "${selected[0]}" "+${selected[1]}"

4
bin/reset_1p Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
security find-generic-password -s 1Password -w | op signin enterprise_console --output=raw > $HOME/.op_tmux_token_tmp

3
bin/symlinks Executable file
View File

@ -0,0 +1,3 @@
#!/usr/local/bin/nu
ls -al | where type == Symlink | select name target

5
bin/uplink-delete-bucket Executable file
View File

@ -0,0 +1,5 @@
#!/bin/sh
bucket="$1"
access="$2"
uplink ls ${access:+--access "$access"} "sj://$bucket/" | awk '{print $NF}' | xargs -I {} uplink rm ${access:+--access "$access"} "sj://$bucket/{}"

5
bin/url-decode Executable file
View File

@ -0,0 +1,5 @@
#!/bin/bash
function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }
urldecode "$@"

44
bin/vimv Executable file
View File

@ -0,0 +1,44 @@
#!/usr/bin/env bash
set -eu
# Lists the current directory's files in Vim, so you can edit it and save to rename them
# USAGE: vimv [file1 file2]
# https://github.com/thameera/vimv
declare -r FILENAMES_FILE=$(mktemp "${TMPDIR:-/tmp}/vimv.XXX")
trap '{ rm -f "${FILENAMES_FILE}" ; }' EXIT
if [ $# -ne 0 ]; then
src=( "$@" )
else
IFS=$'\r\n' GLOBIGNORE='*' command eval 'src=($(ls))'
fi
for ((i=0;i<${#src[@]};++i)); do
echo "${src[i]}" >> "${FILENAMES_FILE}"
done
${EDITOR:-vi} "${FILENAMES_FILE}"
IFS=$'\r\n' GLOBIGNORE='*' command eval 'dest=($(cat "${FILENAMES_FILE}"))'
if (( ${#src[@]} != ${#dest[@]} )); then
echo "WARN: Number of files changed. Did you delete a line by accident? Aborting.." >&2
exit 1
fi
declare -i count=0
for ((i=0;i<${#src[@]};++i)); do
if [ "${src[i]}" != "${dest[i]}" ]; then
mkdir -p "$(dirname "${dest[i]}")"
if git ls-files --error-unmatch "${src[i]}" > /dev/null 2>&1; then
git mv "${src[i]}" "${dest[i]}"
else
mv "${src[i]}" "${dest[i]}"
fi
((++count))
fi
done
echo "$count" files renamed.

16
bin/weather_cached Executable file
View File

@ -0,0 +1,16 @@
#!/bin/sh
CACHE_FILE="$HOME/.cache/weather_cache"
if [ "$1" = "clear" ]; then
rm -f "$CACHE_FILE"
fi
CACHE_TIME="$(stat -f %m "$CACHE_FILE" 2>/dev/null)"
NOW_TIME=$(date +%s)
TIME_PASSED=$((NOW_TIME-CACHE_TIME))
if [ "$TIME_PASSED" -gt "1200" ]
then
curl -m 2 -s "wttr.in/$WEATHER_CITY?format=%c%t" > "$CACHE_FILE"
fi
cat "$CACHE_FILE"

6
cargo/Cargofile Normal file
View File

@ -0,0 +1,6 @@
# Packages to install with Cargo
toml-cli # Parse TOML from the command line
rates # See exchange rates
wrangler # Cloudflare Workers CLI
csview # Quick display CSV as tables

View File

@ -1,5 +0,0 @@
# Colorschemes
Color information for different themes is found here. The colors are sourced
and used with [base16](https://github.com/chriskempson/base16) format
consistently across the system.

View File

@ -1,22 +0,0 @@
{
name = "everforest"; # dark, hard
author = "Sainnhe Park";
dark = {
base00 = "#2b3339"; # Default Background
base01 = "#323c41"; # Lighter Background
base02 = "#503946"; # Selection Background
base03 = "#868d80"; # Comments, Invisibles, Line Highlighting
base04 = "#d3c6aa"; # Dark Foreground (Used for status bars)
base05 = "#d3c6aa"; # Default Foreground, Caret, Delimiters, Operators
base06 = "#e9e8d2"; # Light Foreground (Not often used)
base07 = "#fff9e8"; # Light Background (Not often used)
base08 = "#7fbbb3"; # Variables, XML Tags, Markup Link Text, ...
base09 = "#d699b6"; # Integers, Boolean, Constants, ...
base0A = "#83c092"; # Classes, Markup Bold, Search Text Background
base0B = "#dbbc7f"; # Strings, Inherited Class, Markup Code, Diff Inserted
base0C = "#e69875"; # Support, Regular Expressions, Escape Characters, ...
base0D = "#a7c080"; # Functions, Methods, Attribute IDs, Headings
base0E = "#e67e80"; # Keywords, Storage, Selector, Markup Italic, Diff Changed
base0F = "#d699b6"; # Deprecated, Opening/Closing Embedded Language Tags, ...
};
}

View File

@ -1,44 +0,0 @@
# Gruvbox with a darker background for greater contrast
{
name = "gruvbox-dark"; # Dark, Medium
author = "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox), ElRastaOk (https://www.reddit.com/user/ElRastaOk)";
dark = {
base00 = "#1D2122"; # ---- This is the change from normal gruvbox
base01 = "#3c3836"; # ---
base02 = "#504945"; # --
base03 = "#665c54"; # -
base04 = "#bdae93"; # +
base05 = "#d5c4a1"; # ++
base06 = "#ebdbb2"; # +++
base07 = "#fbf1c7"; # ++++
base08 = "#fb4934"; # red
base09 = "#fe8019"; # orange
base0A = "#fabd2f"; # yellow
base0B = "#b8bb26"; # green
base0C = "#8ec07c"; # aqua/cyan
base0D = "#83a598"; # blue
base0E = "#d3869b"; # purple
base0F = "#d65d0e"; # brown
batTheme = "gruvbox-dark";
};
light = {
base00 = "#fbf1c7"; # ----
base01 = "#ebdbb2"; # ---
base02 = "#d5c4a1"; # --
base03 = "#bdae93"; # -
base04 = "#665c54"; # +
base05 = "#504945"; # ++
base06 = "#3c3836"; # +++
base07 = "#1D2122"; # ++++ Adjusted darker here
base08 = "#9d0006"; # red
base09 = "#af3a03"; # orange
base0A = "#b57614"; # yellow
base0B = "#79740e"; # green
base0C = "#427b58"; # aqua/cyan
base0D = "#076678"; # blue
base0E = "#8f3f71"; # purple
base0F = "#d65d0e"; # brown
batTheme = "gruvbox-light";
};
}

View File

@ -1,42 +0,0 @@
{
name = "gruvbox"; # Dark, Medium
author = "Dawid Kurek (dawikur@gmail.com), morhetz (https://github.com/morhetz/gruvbox)";
dark = {
base00 = "#282828"; # ----
base01 = "#3c3836"; # ---
base02 = "#504945"; # --
base03 = "#665c54"; # -
base04 = "#bdae93"; # +
base05 = "#d5c4a1"; # ++
base06 = "#ebdbb2"; # +++
base07 = "#fbf1c7"; # ++++
base08 = "#fb4934"; # red
base09 = "#fe8019"; # orange
base0A = "#fabd2f"; # yellow
base0B = "#b8bb26"; # green
base0C = "#8ec07c"; # aqua/cyan
base0D = "#83a598"; # blue
base0E = "#d3869b"; # purple
base0F = "#d65d0e"; # brown
batTheme = "gruvbox-dark";
};
light = {
base00 = "#fbf1c7"; # ----
base01 = "#ebdbb2"; # ---
base02 = "#d5c4a1"; # --
base03 = "#bdae93"; # -
base04 = "#665c54"; # +
base05 = "#504945"; # ++
base06 = "#3c3836"; # +++
base07 = "#282828"; # ++++
base08 = "#9d0006"; # red
base09 = "#af3a03"; # orange
base0A = "#b57614"; # yellow
base0B = "#79740e"; # green
base0C = "#427b58"; # aqua/cyan
base0D = "#076678"; # blue
base0E = "#8f3f71"; # purple
base0F = "#d65d0e"; # brown
batTheme = "gruvbox-light";
};
}

View File

@ -1,23 +0,0 @@
{
name = "nord";
author = "arcticicestudio";
dark = {
base00 = "#2E3440";
base01 = "#3B4252";
base02 = "#434C5E";
base03 = "#4C566A";
base04 = "#D8DEE9";
base05 = "#E5E9F0";
base06 = "#ECEFF4";
base07 = "#8FBCBB";
base08 = "#88C0D0";
base09 = "#81A1C1";
base0A = "#5E81AC";
base0B = "#BF616A";
base0C = "#D08770";
base0D = "#EBCB8B";
base0E = "#A3BE8C";
base0F = "#B48EAD";
batTheme = "nord";
};
}

View File

@ -1,98 +0,0 @@
resource "aws_instance" "instance" {
ami = aws_ami.image.id
iam_instance_profile = aws_iam_instance_profile.instance.name
instance_type = var.ec2_size
vpc_security_group_ids = [aws_security_group.instance.id]
tags = {
Name = "aws-nixos"
}
lifecycle {
create_before_destroy = true
}
}
resource "aws_ec2_instance_state" "instance" {
instance_id = aws_instance.instance.id
state = "running"
}
data "aws_vpc" "vpc" {
default = true
}
resource "aws_security_group" "instance" {
name = "aws-nixos"
description = "Allow SSH and HTTPS"
vpc_id = data.aws_vpc.vpc.id
ingress {
description = "Ping"
from_port = -1
to_port = -1
protocol = "icmp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
description = "SSH"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
description = "HTTPS"
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
ipv6_cidr_blocks = ["::/0"]
}
}
# Setup IAM for the instance to use SSM
data "aws_iam_policy_document" "ec2_assume_role" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["ec2.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "instance_profile" {
statement {
actions = [
"s3:ListAllMyBuckets",
]
resources = ["*"]
}
}
resource "aws_iam_role" "instance_profile" {
name = "nixos"
assume_role_policy = data.aws_iam_policy_document.ec2_assume_role.json
inline_policy {
name = "instance-profile"
policy = data.aws_iam_policy_document.instance_profile.json
}
}
resource "aws_iam_role_policy_attachment" "instance_ssm" {
role = aws_iam_role.instance_profile.name
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
}
resource "aws_iam_instance_profile" "instance" {
name = "nixos"
role = aws_iam_role.instance_profile.name
}

View File

@ -1,95 +0,0 @@
# locals {
# image_file = one(fileset(path.root, "../../../result/nixos-amazon-image-*.vhd"))
# }
#
# # Upload image to S3
# resource "aws_s3_object" "image" {
# bucket = var.images_bucket
# key = basename(local.image_file)
# source = local.image_file
# etag = filemd5(local.image_file)
# }
# Use existing image in S3
data "aws_s3_object" "image" {
bucket = var.images_bucket
key = "arrow.vhd"
}
resource "terraform_data" "image_replacement" {
input = data.aws_s3_object.image.etag
}
# Setup IAM access for the VM Importer
data "aws_iam_policy_document" "vmimport_trust_policy" {
statement {
actions = ["sts:AssumeRole"]
principals {
type = "Service"
identifiers = ["vmie.amazonaws.com"]
}
}
}
data "aws_iam_policy_document" "vmimport" {
statement {
actions = [
"s3:GetBucketLocation",
"s3:GetObject",
"s3:ListBucket",
]
resources = [
"arn:aws:s3:::${data.aws_s3_object.image.bucket}",
"arn:aws:s3:::${data.aws_s3_object.image.bucket}/*",
]
}
statement {
actions = [
"ec2:ModifySnapshotAttribute",
"ec2:CopySnapshot",
"ec2:RegisterImage",
"ec2:Describe*",
]
resources = ["*"]
}
}
resource "aws_iam_role" "vmimport" {
name = "vmimport"
assume_role_policy = data.aws_iam_policy_document.vmimport_trust_policy.json
inline_policy {
name = "vmimport"
policy = data.aws_iam_policy_document.vmimport.json
}
}
# Import to EBS
resource "aws_ebs_snapshot_import" "image" {
disk_container {
format = "VHD"
user_bucket {
s3_bucket = data.aws_s3_object.image.bucket
s3_key = data.aws_s3_object.image.key
}
}
role_name = aws_iam_role.vmimport.name
lifecycle {
replace_triggered_by = [terraform_data.image_replacement]
}
}
# Convert to AMI
resource "aws_ami" "image" {
description = "Created with NixOS."
name = replace(basename(data.aws_s3_object.image.key), "/\\.vhd$/", "")
virtualization_type = "hvm"
root_device_name = "/dev/xvda"
ena_support = true
ebs_block_device {
device_name = "/dev/xvda"
snapshot_id = aws_ebs_snapshot_import.image.id
volume_size = 17
}
}

View File

@ -1,13 +0,0 @@
terraform {
backend "s3" {
region = "us-east-1"
dynamodb_table = "terraform-state-lock"
}
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.42.0"
}
}
}

View File

@ -1,3 +0,0 @@
output "host_ip" {
value = aws_instance.instance.public_ip
}

View File

@ -1,10 +0,0 @@
variable "ec2_size" {
type = string
description = "Size of instance to launch"
default = "t3a.small" # 2 GB RAM ($14/mo)
}
variable "images_bucket" {
description = "Name of the bucket in which to store the NixOS VM images."
type = string
}

View File

@ -1,78 +0,0 @@
terraform {
backend "s3" {
bucket = "noahmasur-terraform"
key = "arrow.tfstate"
region = "auto"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_region_validation = true
skip_requesting_account_id = true
skip_s3_checksum = true
use_path_style = true
/*
ENVIRONMENT VARIABLES
---------------------
AWS_ACCESS_KEY_ID - R2 token
AWS_SECRET_ACCESS_KEY - R2 secret
AWS_ENDPOINT_URL_S3 - R2 location: https://ACCOUNT_ID.r2.cloudflarestorage.com
*/
}
required_version = ">= 1.0.0"
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.42.0"
}
vultr = {
source = "vultr/vultr"
version = "2.19.0"
}
}
}
variable "vultr_api_key" {
type = string
description = "API key for Vultr management"
sensitive = true
}
# https://api.vultr.com/v2/plans
variable "vultr_plan" {
type = string
description = "Size of instance to launch"
default = "vc2-1c-2gb" # 55 GB SSD ($10/mo)
}
provider "aws" {
region = "auto"
skip_credentials_validation = true
skip_metadata_api_check = true
skip_region_validation = true
skip_requesting_account_id = true
}
provider "vultr" {
api_key = var.vultr_api_key
}
resource "vultr_iso_private" "image" {
# url = "https://${var.cloudflare_account_id}.r2.cloudflarestorage.com/${data.aws_s3_bucket.images.id}/${aws_s3_object.image.key}"
url = "https://arrow-images.masu.rs/arrow.iso"
}
resource "vultr_instance" "arrow" {
plan = var.vultr_plan
region = "ewr"
iso_id = vultr_iso_private.image.id
label = "arrow"
tags = ["arrow"]
enable_ipv6 = false
disable_public_ipv4 = false
backups = "disabled"
ddos_protection = false
activation_email = false
}
output "host_ip" {
value = vultr_instance.arrow.main_ip
}

1
digrc.symlink Normal file
View File

@ -0,0 +1 @@
+noall +answer

View File

@ -1,4 +0,0 @@
# Documentation
Reference documents for some of the more complicated services and maintenance
tasks.

View File

@ -1,73 +0,0 @@
[Back to README](../README.md)
---
# Installation
## NixOS - From Live Disk
Format drives and build system from any NixOS host, including the live
installer disk:
**This will erase your drives; use at your own risk!**
```bash
lsblk # Choose the disk you want to wipe
nix-shell -p nixVersions.stable
nix run github:nmasur/dotfiles#installer -- nvme0n1 tempest
```
## NixOS - From Existing System
If you're already running NixOS, you can switch to this configuration with the
following command:
```bash
nix-shell -p nixVersions.stable
sudo nixos-rebuild switch --flake github:nmasur/dotfiles#tempest
```
## Windows - From NixOS WSL
After [installing NixOS on
WSL](https://xeiaso.net/blog/nix-flakes-4-wsl-2022-05-01), you can switch to
the WSL configuration:
```
nix-shell -p nixVersions.stable
sudo nixos-rebuild switch --flake github:nmasur/dotfiles#hydra
```
You should also download the
[FiraCode](https://github.com/ryanoasis/nerd-fonts/releases/download/v2.2.2/FiraCode.zip)
font and install it on Windows. Install [Alacritty](https://alacritty.org/) and
move the `windows/alacritty.yml` file to
`C:\Users\<user>\AppData\Roaming\alacritty`.
## macOS
To get started on a bare macOS installation, first install Nix:
```bash
curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix | sh -s -- install
```
Launch a new shell. Then use Nix to switch to the macOS configuration:
```bash
sudo rm /etc/bashrc
sudo rm /etc/nix/nix.conf
export NIX_SSL_CERT_FILE="$HOME/Documents/t2-ca-bundle.pem"
nix \
--extra-experimental-features flakes \
--extra-experimental-features nix-command \
run nix-darwin -- switch \
--flake github:nmasur/dotfiles#lookingglass
```
Once installed, you can continue to update the macOS configuration:
```bash
darwin-rebuild switch --flake ~/dev/personal/dotfiles
```

View File

@ -1,82 +0,0 @@
# Repairing Nextcloud
You can run the maintenance commands like this:
```
sudo -u nextcloud nextcloud-occ maintenance:mode --on
sudo -u nextcloud nextcloud-occ maintenance:repair
sudo -u nextcloud nextcloud-occ maintenance:mode --off
```
## Rescan Files
```
sudo -u nextcloud nextcloud-occ files:scan --all
```
## Converting from SQLite to MySQL (mariadb)
First: keep Nextcloud set to SQLite as its dbtype, and separately launch MySQL
as a service by copying the configuration found
[here](https://github.com/NixOS/nixpkgs/blob/nixos-unstable/nixos/modules/services/web-apps/nextcloud.nix).
No password is necessary, since the user-based auth works with UNIX sockets.
You can connect to the MySQL instance like this:
```
sudo -u nextcloud mysql -S /run/mysqld/mysqld.sock
```
Create a blank database for Nextcloud:
```sql
create database nextcloud;
```
Now setup the [conversion](https://docs.nextcloud.com/server/17/admin_manual/configuration_database/db_conversion.html):
```
sudo -u nextcloud nextcloud-occ db:convert-type mysql nextcloud localhost nextcloud
```
Ignore the password prompt. Proceed with the conversion.
Now `config.php` will be updated but the override config from NixOS will not
be. Now update your NixOS configuration:
- Remove the `mysql` service you created.
- Set `dbtype` to `mysql`.
- Set `database.createLocally` to `true`.
Rebuild your configuration.
Now, make sure to enable [4-byte
support](https://docs.nextcloud.com/server/latest/admin_manual/configuration_database/mysql_4byte_support.html)
in the database.
## Backing Up MySQL Database
Use this mysqldump command:
```
sudo -u nextcloud mysqldump -S /run/mysqld/mysqld.sock --default-character-set=utf8mb4 nextcloud > backup.sql
```
## Converting to Postgres
Same as MySQL, but run this command instead:
```
sudo -u nextcloud nextcloud-occ db:convert-type pgsql nextcloud /run/postgresql/ nextcloud
```
Then set the `dbtype` to `pgsql`.
## Backing Up Postgres Database
Use this pg_dump command:
```
sudo -u nextcloud pg_dump nextcloud > backup.sql
```

View File

@ -1,23 +0,0 @@
# Restoring Calibre From Backup
The `metadata.db` holds the library and `app.db` and `gdrive.db` contain the
web/account information.
Place books directories in `/data/books/`.
Place `metadata.db` in `/var/lib/calibre-web-db/`.
Symlink `metadata.db` to the library:
```
sudo ln -s /var/lib/calibre-web-db/metadata.db /data/books/metadata.db
```
Place `app.db` and `gdrive.db` in `/var/lib/calibre-web/`.
Restart Calibre:
```
sudo systemctl restart calibre-web.service
```

View File

@ -1,45 +0,0 @@
# ZFS
Swan runs its root on ext4. The ZFS drives are managed imperatively (this
[disko configuration](../disks/zfs.nix) is an unused work-in-progress).
The basic ZFS settings are managed [here](../modules/nixos/hardware/zfs.nix).
## Creating a New Dataset
```
sudo zfs create tank/mydataset
sudo zfs set compression=zstd tank/myzstddataset
sudo zfs set mountpoint=/data/mydataset tank/mydataset
```
## Maintenance
### Get Status
```
sudo zpool status
```
### Replace Disk
```
sudo zdb
sudo zpool status -g # Show by GUID
sudo zpool offline tank <GUID>
sudo zpool status
# Remove old disk, insert new disk
sudo zdb
sudo zpool replace tank <OLD GUID> /dev/disk/by-id/<NEW PATH>
sudo zpool status
```
## Initial Setup
```
sudo zpool create tank raidz1 sda sdb sdc
sudo zpool set ashift=12 tank
sudo zpool set autoexpand=on tank
sudo zpool set compression=on tank
```

8
fd/fdignore.symlink Normal file
View File

@ -0,0 +1,8 @@
!.env*
!.github/
!.gitignore
!*.tfvars
.terraform/
.target/
/Library/
target

View File

@ -0,0 +1,9 @@
function __complete_nomad
set -lx COMP_LINE (commandline -cp)
test -z (commandline -ct)
and set COMP_LINE "$COMP_LINE "
/usr/local/bin/nomad
end
complete -f -c nomad -a "(__complete_nomad)"

View File

@ -0,0 +1,44 @@
#!/usr/local/bin/fish
if status --is-interactive
# Add directories to path
set PATH $PATH \
/usr/local/bin \
~/.local/bin \
$DOTS/bin \
~/.cargo/bin
# Use `vi` in the shell with cursor shapes
fish_vi_key_bindings
bind yy fish_clipboard_copy
bind Y fish_clipboard_copy
bind -M visual y fish_clipboard_copy
bind p fish_clipboard_paste
set -g fish_vi_force_cursor
set -g fish_cursor_default block
set -g fish_cursor_insert line
set -g fish_cursor_visual block
set -g fish_cursor_replace_one underscore
fish_vi_cursor
# Autojump
zoxide init fish | source
# Colors
if test -e $DOTS/fish.configlink/fish_colors
command cat $DOTS/fish.configlink/fish_colors
end
# Fuzzy finder
fzf_key_bindings
set -gx FZF_DEFAULT_COMMAND 'fd --type file'
set -g FZF_CTRL_T_COMMAND "$FZF_DEFAULT_COMMAND"
set -g FZF_DEFAULT_OPTS '-m --height 50% --border'
# Use `starship` prompt
starship init fish | source
# Hook into direnv
direnv hook fish | source
end

View File

@ -0,0 +1 @@
]4;1;rgb:cc/24/1d]4;2;rgb:98/97/1a]4;3;rgb:d7/99/21]4;4;rgb:45/85/88]4;5;rgb:b1/62/86]4;6;rgb:68/9d/6a]11;rgb:28/28/28]10;rgb:eb/db/b2]4;0;rgb:28/28/28]4;7;rgb:a8/99/84]4;8;rgb:92/83/74]4;9;rgb:fb/59/34]4;10;rgb:b8/bb/26]4;11;rgb:fa/bd/2f]4;12;rgb:83/a5/98]4;13;rgb:d3/86/9b]4;14;rgb:8e/c0/7c]4;15;rgb:eb/db/b2]4;236;rgb:32/30/2f]4;234;rgb:1d/20/21]4;235;rgb:28/28/28]4;237;rgb:3c/38/36]4;239;rgb:50/49/45]4;241;rgb:66/5c/54]4;243;rgb:7c/6f/64]4;244;rgb:92/83/74]4;245;rgb:92/83/74]4;228;rgb:f2/e5/bc]4;230;rgb:f9/f5/d7]4;229;rgb:fb/f1/c7]4;223;rgb:eb/db/b2]4;250;rgb:d5/c4/a1]4;248;rgb:bd/ae/93]4;246;rgb:a8/99/84]4;167;rgb:fb/49/34]4;142;rgb:b8/bb/26]4;214;rgb:fa/bd/2f]4;109;rgb:83/a5/98]4;175;rgb:d3/86/9b]4;108;rgb:8e/c0/7c]4;208;rgb:fe/80/19]4;88;rgb:9d/00/06]4;100;rgb:79/74/0e]4;136;rgb:b5/76/14]4;24;rgb:07/66/78]4;96;rgb:8f/3f/71]4;66;rgb:42/7b/58]4;130;rgb:af/3a/03

View File

@ -0,0 +1,150 @@
#!/usr/local/bin/fish
function abbrs --description 'All abbreviations'
# Directory aliases
abbr -a l ls
abbr -a lh 'ls -lh'
abbr -a ll 'ls -alhF'
abbr -a lf 'ls -lh | fzf'
abbr -a c cd
abbr -a -- - 'cd -'
abbr -a proj 'cd $PROJ'
abbr -a mkd 'mkdir -pv'
# Tmux
abbr -a ta 'tmux attach-session'
abbr -a tan 'tmux attach-session -t noah'
abbr -a tnn 'tmux new-session -s noah'
# Git
abbr -a g git
abbr -a gs 'git status'
abbr -a gd 'git diff'
abbr -a gds 'git diff --staged'
abbr -a gdp 'git diff HEAD^'
abbr -a ga 'git add'
abbr -a gaa 'git add -A'
abbr -a gac 'git commit -am'
abbr -a gc 'git commit -m'
abbr -a gca 'git commit --amend --no-edit'
abbr -a gu 'git pull'
abbr -a gp 'git push'
abbr -a gpp git-push-upstream
abbr -a gl 'git log --graph --decorate --oneline -20'
abbr -a gll 'git log --graph --decorate --oneline'
abbr -a gco 'git checkout'
abbr -a gcom 'git checkout master'
abbr -a gcob 'git checkout -b'
abbr -a gb 'git branch'
abbr -a gbd 'git branch -d'
abbr -a gbD 'git branch -D'
abbr -a gr 'git reset'
abbr -a grh 'git reset --hard'
abbr -a gm 'git merge'
abbr -a gcp 'git cherry-pick'
abbr -a cdg 'cd (git rev-parse --show-toplevel)'
# GitHub
abbr -a ghr 'gh repo view -w'
abbr -a gha 'gh run list | head -1 | awk \'{ print $(NF-2) }\' | xargs gh run view'
abbr -a grw 'noti gh run watch'
abbr -a grf 'gh run view --log-failed'
abbr -a grl 'gh run view --log'
abbr -a ghpr 'gh pr create && sleep 3 && noti gh run watch'
abbr -a ghm 'gh pr merge -s -d && git pull'
# Vim
if command -v nvim >/dev/null
alias --save vim='nvim'
abbr -a vimrc 'vim $HOME/.config/nvim/init.lua'
else
alias --save vim='vim'
abbr -a vimrc 'vim $HOME/.vimrc'
end
abbr -a v vim
abbr -a vl 'vim -c "normal! `0"'
abbr -a vll 'vim -c "Telescope oldfiles"'
abbr -a vh 'vim -c "Telescope oldfiles"'
# Notes
abbr -a qn quicknote
abbr -a sn syncnotes
abbr -a to today
abbr -a work 'vim $NOTES_PATH/work.md'
# RSS
abbr -a nb newsboat
# Improved CLI Tools
abbr -a cat bat # Swap cat with bat
abbr -a h 'http -Fh --all' # Curl site for headers
abbr -a j just
# Fun CLI Tools
abbr weather 'curl wttr.in/$WEATHER_CITY'
abbr moon 'curl wttr.in/Moon'
# Dotfile and config shortcuts
abbr -a s sudo
abbr -a boot '$DOTS/scripts/bootstrap'
abbr -a sshc 'vim ~/.ssh/config'
abbr -a hosts 'sudo nvim /etc/hosts'
abbr -a frc 'vim $HOME/.config/fish/config.fish'
abbr -a falias 'vim $HOME/.config/fish/functions/abbrs.fish'
# Cheat Sheets
abbr -a ssl 'openssl req -new -newkey rsa:2048 -nodes' \
'-keyout server.key -out server.csr'
abbr -a fingerprint 'ssh-keyscan myhost.com | ssh-keygen -lf -'
abbr -a publickey 'ssh-keygen -y -f ~/.ssh/id_rsa > ~/.ssh/id_rsa.pub'
abbr -a forloop 'for i in (seq 1 100)'
abbr -a gatekeeper 'sudo spctl --master-disable'
abbr -a flushdns 'sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder'
# Docker
abbr -a dc '$DOTS/bin/docker_cleanup'
abbr -a dr 'docker run --rm -it'
abbr -a db 'docker build . -t'
abbr -a ds 'docker ps -a'
abbr -a de 'docker exec -it'
abbr -a dpy 'docker run --rm -it -v $PWD:/project python:alpine python'
abbr -a alp 'docker run --rm -it -v $PWD:/project alpine sh'
# Terraform
abbr -a te terraform
abbr -a tap 'terraform apply'
# Kubernetes
abbr -a k kubectl
abbr -a pods 'kubectl get pods -A'
abbr -a nodes 'kubectl get nodes'
abbr -a deploys 'kubectl get deployments -A'
abbr -a dash kube-dashboard
abbr -a ks k9s
# Cloud
abbr -a awsc 'vim ~/.aws/credentials'
# Python
abbr -a py python
abbr -a po poetry
abbr -a pr 'poetry run python'
abbr -a pl 'poetry run pylint *'
abbr -a black 'poetry run black --target-version py38 .'
abbr -a bl 'poetry run black --target-version py38 .'
# Rust
abbr -a ca cargo
# macOS
abbr -a casks 'vim $DOTS/homebrew/Caskfile'
abbr -a t trash
# Linux
if [ (uname) = Linux ]
linux
end
end

View File

@ -0,0 +1,10 @@
function brews --description "Open Homebrew bundles file"
set -lx brewdir $DOTS/homebrew
set -l brewfile (basename $brewdir/*.Brewfile \
| fzf \
--height 70% \
--preview-window right:70% \
--preview 'bat --color=always $brewdir/{}' \
)
and vim $brewdir/$brewfile
end

View File

@ -0,0 +1,9 @@
function brewsearch --description "Install brew plugins"
set -l inst (brew formulae | eval "fzf $FZF_DEFAULT_OPTS -m --header='[press ctrl-i for info, enter to install]' --bind 'ctrl-i:preview(brew info {})'")
if not test (count $inst) = 0
for prog in $inst
brew install "$prog"
end
end
end

View File

@ -0,0 +1,10 @@
#!/usr/local/bin/fish
function commandline-git-commits
set commit (git-commits)
if [ $commit ]
commandline -i "$commit"
else
commandline -i "HEAD"
end
end

View File

@ -0,0 +1,3 @@
function copy --description 'Copy file contents into clipboard'
cat $argv | pbcopy
end

View File

@ -0,0 +1,6 @@
function edit --description "Open a file in Vim"
set vimfile (fzf)
and set vimfile (echo $vimfile | tr -d '\r')
and commandline -r "vim $vimfile"
and commandline -f execute
end

View File

@ -0,0 +1,3 @@
function envs --description 'Set from a bash environment variables file'
set -gx (cat $argv | tr "=" " " | string split ' ')
end

View File

@ -0,0 +1,12 @@
function fcd --description 'Jump to directory' -a 'directory'
if test -z $directory
set directory "$HOME"
end
if ! test -d $directory
echo "Directory not found: $directory"
return 1
end
set jump (fd -t d . $directory | fzf)
and cd $jump $argv;
and commandline -f execute;
end

View File

@ -0,0 +1,17 @@
#!/usr/local/bin/fish
function fish_user_key_bindings
bind -M insert \co 'edit'
bind -M default \co 'edit'
bind -M insert \ca 'cd ~; and edit; and commandline -a "; cd -"; commandline -f execute'
bind -M default \ca 'cd ~; and edit; and commandline -a "; cd -"; commandline -f execute'
bind -M insert \ce 'recent'
bind -M default \ce 'recent'
bind -M insert \cg 'commandline-git-commits'
bind -M insert \cf 'fcd'
bind -M default \cf 'fcd'
bind -M insert \cp 'prj'
bind -M default \cp 'prj'
bind -M insert \x1F accept-autosuggestion
bind -M default \x1F accept-autosuggestion
end

View File

@ -0,0 +1,122 @@
#!/usr/local/bin/fish
function fish_vi_cursor -d 'Set cursor shape for different vi modes'
# If we're not interactive, there is effectively no bind mode.
if not status is-interactive
return
end
# This is hard to test in expect, since the exact sequences depend on the environment.
# Instead disable it.
if set -q FISH_UNIT_TESTS_RUNNING
return
end
# If this variable is set, skip all checks
if not set -q fish_vi_force_cursor
# Emacs Makes All Cursors Suck
if set -q INSIDE_EMACS
return
end
# vte-based terms set $TERM = xterm*, but only gained support in 2015.
# From https://bugzilla.gnome.org/show_bug.cgi?id=720821, it appears it was version 0.40.0
if set -q VTE_VERSION
and test "$VTE_VERSION" -lt 4000 2>/dev/null
return
end
# Similarly, genuine XTerm can do it since v280.
if set -q XTERM_VERSION
and not test (string replace -r "XTerm\((\d+)\)" '$1' -- "$XTERM_VERSION") -ge 280 2>/dev/null
return
end
# We need one of these terms.
# It would be lovely if we could rely on terminfo, but:
# - The "Ss" entry isn't a thing in macOS' old and crusty terminfo
# - It is set for xterm, and everyone and their dog claims to be xterm
#
# So we just don't care about $TERM, unless it is one of the few terminals that actually have their own entry.
#
# Note: Previous versions also checked $TMUX, and made sure that then $TERM was screen* or tmux*.
# We don't care, since we *cannot* handle term-in-a-terms 100% correctly.
if not set -q KONSOLE_PROFILE_NAME
and not test -n "$KONSOLE_VERSION" -a "$KONSOLE_VERSION" -ge 200400 # konsole, but new.
and not set -q ITERM_PROFILE
and not set -q VTE_VERSION # which version is already checked above
and not set -q WT_PROFILE_ID
and not set -q XTERM_VERSION
and not string match -rq '^st(-.*)$' -- $TERM
and not string match -q 'xterm-kitty*' -- $TERM
and not string match -q 'rxvt*' -- $TERM
and not string match -q 'alacritty*' -- $TERM
return
end
# HACK: Explicitly disable on ITERM because of #3696, which is weirdness with multi-line prompts.
# --force-iterm is now deprecated; set $fish_vi_force_cursor instead
if contains -- $argv[1] --force-iterm
set -e argv[1]
else if set -q ITERM_PROFILE
return
end
end
set -l terminal $argv[1]
set -q terminal[1]
or set terminal auto
set -l function
switch "$terminal"
case auto
# Nowadays, konsole does not set $KONSOLE_PROFILE_NAME anymore,
# and it uses the xterm sequences.
if set -q KONSOLE_PROFILE_NAME
set function __fish_cursor_konsole
else if set -q ITERM_PROFILE
set function __fish_cursor_1337
else
set function __fish_cursor_xterm
end
case konsole
set function __fish_cursor_konsole
case xterm
set function __fish_cursor_xterm
end
set -l tmux_prefix
set -l tmux_postfix
if set -q TMUX
set tmux_prefix echo -ne "'\ePtmux;\e'"
set tmux_postfix echo -ne "'\e\\\\'"
end
set -q fish_cursor_unknown
or set -g fish_cursor_unknown block blink
echo "
function fish_vi_cursor_handle --on-variable fish_bind_mode --on-event fish_postexec --on-event fish_focus_in
set -l varname fish_cursor_\$fish_bind_mode
if not set -q \$varname
set varname fish_cursor_unknown
end
$tmux_prefix
$function \$\$varname
$tmux_postfix
end
" | source
echo "
function fish_vi_cursor_handle_preexec --on-event fish_preexec
set -l varname fish_cursor_default
if not set -q \$varname
set varname fish_cursor_unknown
end
$tmux_prefix
$function \$\$varname
$tmux_postfix
end
" | source
end

View File

@ -0,0 +1 @@
/usr/local/opt/fzf/shell/key-bindings.fish

View File

@ -0,0 +1,8 @@
# This function creates an output file of just the printf values for
# modifying the shell colors. This output file is used to load the
# current colors into my shell much faster than running the function on
# prompt.
function generate_fish_colors --description "Create fish colors file"
theme_gruvbox dark > $DOTS/fish.configlink/fish_colors
end

View File

@ -0,0 +1,16 @@
function git-add-fuzzy
set gitfile (git status -s \
| fzf \
--height 50% \
-m \
--preview-window right:70% \
--layout reverse \
--preview 'set -l IFS; set gd (git diff --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2)); if test "$gd"; echo "$gd"; else; bat --color=always (echo {} | awk \'{$1=$1};1\' | cut -d" " -f2); end')
and for gf in $gitfile
set gf (echo $gf \
| awk '{$1=$1};1' \
| cut -d' ' -f2 \
)
and git add $gf
end
end

View File

@ -0,0 +1,4 @@
function git-checkout-fuzzy
set branch (git-fuzzy-branch "checkout branch...")
and git checkout $branch
end

View File

@ -0,0 +1,10 @@
function git-commits
set commitline (git log \
--pretty="format:%C(auto)%ar %h%d %s" \
| fzf \
--height 50% \
--preview 'git show --color=always (echo {} | cut -d" " -f4)' \
)
and set commit (echo $commitline | cut -d" " -f4)
and echo $commit
end

View File

@ -0,0 +1,4 @@
function git-delete-fuzzy
set branch (git-fuzzy-branch "delete branch...")
and git branch -d $branch
end

View File

@ -0,0 +1,4 @@
function git-force-delete-fuzzy
set branch (git-fuzzy-branch "force delete branch...")
and git branch -D $branch
end

View File

@ -0,0 +1,12 @@
function git-fuzzy-branch -a header
set -l current (git rev-parse --abbrev-ref HEAD | tr -d '\n')
set -l branch (git branch \
--format "%(refname:short)" \
| fzf \
--height 50% \
--header="On $current, $header" \
--preview-window right:70% \
--preview 'git log {} --color=always --pretty="format:%C(auto)%ar %h%d %s"' \
)
and echo $branch
end

View File

@ -0,0 +1,16 @@
function git-history
if not count $argv > /dev/null
echo "Must provide filename."
return 1
end
set commitline ( git log \
--follow \
--pretty="format:%C(auto)%ar %h%d %s" \
-- ./$argv \
| fzf \
--height 100% \
--preview "git diff --color=always (echo {} | cut -d' ' -f4)^1..(echo {} | cut -d' ' -f4) -- ./$argv" \
)
and set commit (echo $commitline | cut -d" " -f4)
and echo $commit
end

View File

@ -0,0 +1,4 @@
function git-merge-fuzzy
set branch (git-fuzzy-branch "merge from...")
and git merge $branch
end

View File

@ -0,0 +1,6 @@
function git-push-upstream --description "Create upstream branch"
set -l branch (git branch 2>/dev/null | grep '^\*' | colrm 1 2)
set -l command "git push --set-upstream origin $branch"
commandline -r $command
commandline -f execute
end

View File

@ -0,0 +1,8 @@
function git-show-fuzzy
set commitline (git log \
--pretty="format:%C(auto)%ar %h%d %s" \
| fzf \
)
and set commit (echo $commitline | cut -d" " -f4 )
and git show $commit
end

View File

@ -0,0 +1,39 @@
function git
if contains f $argv
switch $argv[1]
case "checkout"
git-checkout-fuzzy
case "add"
git-add-fuzzy
case "show"
git-show-fuzzy
case "merge"
git-merge-fuzzy
case "branch"
if test "$argv[2]" = "-d"
git-delete-fuzzy
else if test "$argv[2]" = "-D"
git-force-delete-fuzzy
else
echo "Not a fuzzy option."
return 1
end
case "reset"
set commit (git-commits)
and if test "$argv[2]" = "--hard"
git reset --hard $commit
else
git reset $commit
end
case "*"
echo "No fuzzy option."
return 1
end
else
if count $argv > /dev/null
command git $argv
else
command git status -sb
end
end
end

View File

@ -0,0 +1,7 @@
function ip
if count $argv > /dev/null
curl ipinfo.io/$argv
else
curl checkip.amazonaws.com
end
end

View File

@ -0,0 +1,10 @@
function journal --description "Create today's journal"
note-dates
if [ -f $TODAY_NOTE_FILE ]
echo "Already exists."
else
note-header
printf $JOURNAL_HEADER > $TODAY_NOTE_FILE
echo "New journal added."
end
end

View File

@ -0,0 +1,3 @@
function json --description "Tidy up JSON with jq"
pbpaste | jq '.' | pbcopy
end

View File

@ -0,0 +1,4 @@
function linux --description "Load only on Linux"
alias pbcopy='xclip -selection clipboard -in'
alias pbpaste='xclip -selection clipboard -out'
end

View File

@ -0,0 +1,3 @@
function ls --description "Use exa to list files"
exa $argv
end

View File

@ -0,0 +1,11 @@
function meeting --description "Describe a meeting" -a "name"
note-dates
set today_date (date -j +"%Y-%m-%d")
set time (date +"%I:%M%p" | tr '[:upper:]' '[:lower:]')
set meeting_name (echo $name | tr ' ' '-' | tr '[:upper:]' '[:lower:]')
set meeting_note $today_date-$meeting_name
set meeting_file meetings/$meeting_note.md
printf "[$TODAY_NOTE](../journal/$TODAY_NOTE.md) | #meeting\n\n# $name\n\n---\n\n" > $NOTES_PATH/$meeting_file
printf "\n\n---\n\n$time - [$name](../$meeting_file)\n\n---\n\n" >> $TODAY_NOTE_FILE
vim $NOTES_PATH/$meeting_file
end

View File

@ -0,0 +1,7 @@
function note-dates
set -g TODAY_NOTE (date +"%Y-%m-%d_%a")
set -g YESTERDAY_NOTE (date -jv "-1d" +"%Y-%m-%d_%a")
set -g TOMORROW_NOTE (date -jv "+1d" +"%Y-%m-%d_%a")
set -g LONG_DATE (date +"%A, %B %e, %Y" | sed 's/ */ /g')
set -g TODAY_NOTE_FILE $NOTES_PATH/journal/$TODAY_NOTE.md
end

View File

@ -0,0 +1,4 @@
function note-header
set -g CURRENT_WEATHER (curl -s "https://wttr.in/?format=1")
set -g JOURNAL_HEADER "[Yesterday]($YESTERDAY_NOTE.md) | [Home](../home.md) | [Today](obsidian://advanced-uri?daily=true) | [Tomorrow]($TOMORROW_NOTE.md)\n\n$LONG_DATE\n$CURRENT_WEATHER\n#journal\n\n---\n\n"
end

View File

@ -0,0 +1,10 @@
function note --description "Edit or create a note" -a "filename"
if test -n "$filename"
vim $NOTES_PATH/$filename.md
else
set file (ls $NOTES_PATH | fzf)
if [ $status -eq 0 ]
vim $NOTES_PATH/$file
end
end
end

View File

@ -0,0 +1,3 @@
function ping --description "Improved ping" -a "target"
prettyping --nolegend $target
end

View File

@ -0,0 +1,5 @@
function prj --description "cd to a project"
set projdir (ls $PROJ | fzf)
and cd $PROJ/$projdir
and commandline -f execute
end

View File

@ -0,0 +1,3 @@
function psf --description "Search for open process" -a "process"
ps aux | rg -v "$USER.*rg $argv" | rg $argv
end

View File

@ -0,0 +1,3 @@
function qr
qrencode $argv[1] -o /tmp/qr.png | open /tmp/qr.png
end

View File

@ -0,0 +1,5 @@
function quicknote --description "Write a quick note" -a "note"
note-dates
set time (date +"%I:%M%p" | tr '[:upper:]' '[:lower:]')
printf "\n\n---\n\n#### $time\n$note\n" >> $TODAY_NOTE_FILE
end

View File

@ -0,0 +1,6 @@
function recent --description "Open a recent file in Vim"
set vimfile (fd -t f --exec stat -f "%m%t%N" | sort -nr | cut -f2 | fzf)
and set vimfile (echo $vimfile | tr -d '\r')
and commandline -r "vim $vimfile"
and commandline -f execute
end

View File

@ -0,0 +1,3 @@
function reload --description "Reload fish configuration"
source $DOTS/fish.configlink/config.fish
end

View File

@ -0,0 +1,42 @@
#!/usr/local/bin/fish
function repos --description 'Clone GitHub repositories' -a 'organization'
set directory (gh-repos $organization)
and cd $directory
end
#switch $organization
# case t2; set organization "take-two"
# case d2c; set organization "take-two-t2gp"
# case t2gp; set organization "take-two-t2gp"
# case pd; set organization "private-division"
# case dots; set organization "playdots"
# case '*'; set organization "nmasur"
#end
#set selected (gh repo list "$organization" \
# --limit 50 \
# --no-archived \
# --json=name,description,isPrivate,updatedAt,primaryLanguage \
# | jq -r '.[] | .name + "," + if .description == "" then "-" else .description end + "," + .updatedAt + "," + .primaryLanguage.name' \
# | begin
# echo "REPO,DESCRIPTION,UPDATED,LANGUAGE"
# cat -
# end | column -s , -t
# | fzf \
# --header-lines=1 \
# --layout=reverse
#--bind "ctrl-o:execute:gh repo view -w $organization/{1}" \
#--preview "GH_FORCE_TTY=49% gh repo view $organization/{1} | glow -" \
#--preview-window up
#)
#if test -n (echo $selected | tr -d '\r')
# set directory "$HOME/dev/work"
# if test $organization = "nmasur"
# set directory "$HOME/dev/personal"
# end
# set repo (echo $selected | awk '{print $1}')
# set repo_full "$organization/$repo"
# gh repo clone "$repo_full" "$directory/$repo"
# cd "$directory/$repo"
#end
#end

View File

@ -0,0 +1,9 @@
function syncnotes --description "Full git commit on notes"
set current_dir $PWD
cd $NOTES_PATH
git pull
git add -A
git commit -m "autosync"
git push
cd $current_dir
end

View File

@ -0,0 +1,141 @@
#!/usr/bin/fish
function theme_gruvbox --description 'Apply gruvbox theme'
set -l mode 'light'
if test (count $argv) -gt 0
set mode $argv[1]
end
set -g contrast 'medium'
if test (count $argv) -gt 1
set contrast $argv[2]
end
switch $contrast
case 'soft'
case 'medium'
case 'hard'
case '*'
set_color $fish_color_error
echo 'Unknown contrast $contrast, choose soft, medium or hard'
set_color $fish_color_normal
return 1
end
switch $mode
case 'light'
__theme_gruvbox_base
__theme_gruvbox_light
case 'dark'
__theme_gruvbox_base
__theme_gruvbox_dark
case '*'
set_color $fish_color_error
echo 'Unknown mode $mode, choose light or dark'
set_color $fish_color_normal
return 1
end
__theme_gruvbox_palette
return 0
end
function __theme_gruvbox_base
__printf_color 1 'cc/24/1d'
__printf_color 2 '98/97/1a'
__printf_color 3 'd7/99/21'
__printf_color 4 '45/85/88'
__printf_color 5 'b1/62/86'
__printf_color 6 '68/9d/6a'
end
function __theme_gruvbox_light
set -l bg 'fb/f1/c7'
switch $contrast
case "soft"
set bg 'f2/e5/bc'
case "hard"
set bg 'f9/f5/d7'
end
command printf "\033]11;rgb:$bg\007"
set -l fg '3c/38/36'
command printf "\033]10;rgb:$fg\007"
__printf_color 0 $bg
__printf_color 7 '7c/6f/64'
__printf_color 8 '92/83/74'
__printf_color 9 '9d/00/06'
__printf_color 10 '79/74/0e'
__printf_color 11 'b5/76/14'
__printf_color 12 '07/66/78'
__printf_color 13 '8f/3f/71'
__printf_color 14 '42/7b/58'
__printf_color 15 $fg
end
function __theme_gruvbox_dark
set -l bg '28/28/28'
switch $contrast
case "soft"
set bg '32/30/2f'
case "hard"
set bg '1d/20/21'
end
command printf "\033]11;rgb:$bg\007"
set -l fg 'eb/db/b2'
command printf "\033]10;rgb:$fg\007"
__printf_color 0 $bg
__printf_color 7 'a8/99/84'
__printf_color 8 '92/83/74'
__printf_color 9 'fb/59/34'
__printf_color 10 'b8/bb/26'
__printf_color 11 'fa/bd/2f'
__printf_color 12 '83/a5/98'
__printf_color 13 'd3/86/9b'
__printf_color 14 '8e/c0/7c'
__printf_color 15 $fg
end
function __theme_gruvbox_palette
__printf_color 236 '32/30/2f'
__printf_color 234 '1d/20/21'
__printf_color 235 '28/28/28'
__printf_color 237 '3c/38/36'
__printf_color 239 '50/49/45'
__printf_color 241 '66/5c/54'
__printf_color 243 '7c/6f/64'
__printf_color 244 '92/83/74'
__printf_color 245 '92/83/74'
__printf_color 228 'f2/e5/bc'
__printf_color 230 'f9/f5/d7'
__printf_color 229 'fb/f1/c7'
__printf_color 223 'eb/db/b2'
__printf_color 250 'd5/c4/a1'
__printf_color 248 'bd/ae/93'
__printf_color 246 'a8/99/84'
__printf_color 167 'fb/49/34'
__printf_color 142 'b8/bb/26'
__printf_color 214 'fa/bd/2f'
__printf_color 109 '83/a5/98'
__printf_color 175 'd3/86/9b'
__printf_color 108 '8e/c0/7c'
__printf_color 208 'fe/80/19'
__printf_color 88 '9d/00/06'
__printf_color 100 '79/74/0e'
__printf_color 136 'b5/76/14'
__printf_color 24 '07/66/78'
__printf_color 96 '8f/3f/71'
__printf_color 66 '42/7b/58'
__printf_color 130 'af/3a/03'
end
function __printf_color
command printf "\033]4;$argv[1];rgb:$argv[2]\007"
end

View File

@ -0,0 +1,11 @@
#!/usr/local/bin/fish
function tickers --description "Stock and money tickers"
abbr -a tk 'tickrs -s'
abbr -a vt 'tickrs -s vt'
abbr -a vti 'tickrs -s vti'
abbr -a vxus 'tickrs -s vxus'
abbr -a btc 'rates btc usd'
abbr -a ada 'rates ada usd'
abbr -a eth 'rates eth usd'
end

Some files were not shown because too many files have changed in this diff Show More