mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-27 23:41:05 +00:00
Compare commits
47 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
34a0d7d8c4 | ||
|
|
65bf470c5b | ||
|
|
965c47efef | ||
| 410f5ac2b5 | |||
|
|
b6a18688c4 | ||
| 9f1ba5034f | |||
|
|
4cf956aa17 | ||
|
|
f9142a4780 | ||
|
|
bb921189e2 | ||
| a4eb0b0186 | |||
| 1222b8fdb3 | |||
| cced3a5310 | |||
|
|
6c680a0fa9 | ||
|
|
6746fb5381 | ||
| 7b2831ec94 | |||
| a605d46294 | |||
|
|
5e98f61942 | ||
|
|
e2583f4d91 | ||
| 80b2e542bf | |||
| 9c3ba8f2e8 | |||
| 632424ecf9 | |||
|
|
8c8436254e | ||
|
|
fe6f070beb | ||
|
|
2a5b2400d7 | ||
| e109cca22a | |||
| 1d948f6915 | |||
|
|
14c3e376dc | ||
|
|
75a32331b0 | ||
|
|
a708085dda | ||
|
|
7921e079da | ||
|
|
2369eae0ef | ||
|
|
6dc5849f9c | ||
|
|
5cc0018f1d | ||
| 8fbeca17a4 | |||
| 1d1a95fad2 | |||
| 3acc948c23 | |||
| 0f94386231 | |||
| 5e06a735cc | |||
|
|
9471a63475 | ||
|
|
01328498b6 | ||
|
|
bab6f7daab | ||
| 4baabbdd5d | |||
| d5757d231f | |||
| 6190be3bdd | |||
| 0db64845bc | |||
|
|
8a8699bf0c | ||
|
|
8814c777f5 |
@@ -3,25 +3,10 @@ root = true
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
# indent_size = 4
|
||||
indent_size = 2
|
||||
indent_style = space
|
||||
insert_final_newline = true
|
||||
# max_line_length = 160
|
||||
# tab_width = 4
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[{*.yaml,*.yml}]
|
||||
indent_size = 2
|
||||
|
||||
[*.sh]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
tab_width = 2
|
||||
|
||||
shell_variant = posix # like -ln=posix
|
||||
binary_next_line = true # like -bn
|
||||
switch_case_indent = true # like -ci
|
||||
space_redirects = true # like -sr
|
||||
keep_padding = false # like -kp
|
||||
function_next_line = false # like -fn
|
||||
never_split = true # like -ns
|
||||
[local/bin/antigen.zsh]
|
||||
ignore = true
|
||||
|
||||
43
.github/workflows/linters.yml
vendored
Normal file
43
.github/workflows/linters.yml
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
name: reviewdog
|
||||
on: [ push ]
|
||||
jobs:
|
||||
linters:
|
||||
name: Linters
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
||||
- name: GitHub Actions
|
||||
uses: reviewdog/action-actionlint@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
reporter: github-pr-review
|
||||
|
||||
- name: detect-secrets
|
||||
uses: reviewdog/action-detect-secrets@master
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
reporter: github-pr-review
|
||||
|
||||
- name: markdownlint
|
||||
uses: reviewdog/action-markdownlint@v0
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
reporter: github-pr-review
|
||||
|
||||
- name: shfmt
|
||||
uses: reviewdog/action-shfmt@v1
|
||||
with:
|
||||
github_token: ${{ secrets.GITHUB_TOKEN }}
|
||||
shfmt_flags: |
|
||||
--find
|
||||
--list
|
||||
--write
|
||||
--diff
|
||||
--simplify
|
||||
--language-dialect bash
|
||||
--indent 2
|
||||
--binary-next-line
|
||||
--case-indent
|
||||
--space-redirects
|
||||
--func-next-line
|
||||
59
Brewfile
59
Brewfile
@@ -7,12 +7,13 @@ tap "github/gh"
|
||||
tap "homebrew/autoupdate"
|
||||
tap "homebrew/bundle"
|
||||
tap "homebrew/cask"
|
||||
tap "homebrew/cask-fonts"
|
||||
tap "homebrew/core"
|
||||
tap "homebrew/services"
|
||||
tap "mongodb/brew"
|
||||
tap "shivammathur/extensions"
|
||||
tap "shivammathur/php"
|
||||
# Interpreted, interactive, object-oriented programming language
|
||||
brew "python@3.10"
|
||||
tap "teamookla/speedtest"
|
||||
# Automate deployment, configuration, and upgrading
|
||||
brew "ansible"
|
||||
# Zstandard is a real-time compression algorithm
|
||||
@@ -33,6 +34,8 @@ brew "glib"
|
||||
brew "pkg-config"
|
||||
# Open source suite of directory software
|
||||
brew "openldap"
|
||||
# Get a file from an HTTP, HTTPS or FTP server
|
||||
brew "curl"
|
||||
# Libraries to talk to Microsoft SQL Server and Sybase databases
|
||||
brew "freetds"
|
||||
# C/C++ and Java libraries for Unicode and globalization
|
||||
@@ -45,6 +48,8 @@ brew "php"
|
||||
brew "composer"
|
||||
# GNU File, Shell, and Text utilities
|
||||
brew "coreutils"
|
||||
# Get, unpack, build, and install modules from CPAN
|
||||
brew "cpanminus"
|
||||
# Diff that understands syntax
|
||||
brew "difftastic"
|
||||
# Tool for exploring each layer in a docker image
|
||||
@@ -55,6 +60,8 @@ brew "dog"
|
||||
brew "eg-examples"
|
||||
# CLI for templating and/or deploying FaaS functions
|
||||
brew "faas-cli"
|
||||
# Simple, fast and user-friendly alternative to find
|
||||
brew "fd"
|
||||
# Monitor a directory for changes and run a shell command
|
||||
brew "fswatch"
|
||||
# GitHub command-line tool
|
||||
@@ -67,6 +74,8 @@ brew "git-extras"
|
||||
brew "git-flow-avh"
|
||||
# See your latest local git branches, formatted real fancy
|
||||
brew "git-recent"
|
||||
# Open-source GitLab command-line tool
|
||||
brew "glab"
|
||||
# GNU implementation of the famous stream editor
|
||||
brew "gnu-sed"
|
||||
# Validating, recursive, caching DNS resolver
|
||||
@@ -75,6 +84,8 @@ brew "unbound"
|
||||
brew "gnutls"
|
||||
# GNU Pretty Good Privacy (PGP) package
|
||||
brew "gnupg"
|
||||
# Open source programming language to build simple/reliable/efficient software
|
||||
brew "go"
|
||||
# Image manipulation
|
||||
brew "netpbm"
|
||||
# OpenType text shaping engine
|
||||
@@ -107,6 +118,10 @@ brew "m-cli"
|
||||
brew "mas"
|
||||
# Terminal-based visual file manager
|
||||
brew "midnight-commander"
|
||||
# Ambitious Vim-fork focused on extensibility and agility
|
||||
brew "neovim"
|
||||
# No Nonsense Neovim Client in Rust
|
||||
brew "neovide"
|
||||
# Port scanning utility for large networks
|
||||
brew "nmap"
|
||||
# Manage multiple Node.js versions
|
||||
@@ -115,6 +130,12 @@ brew "nvm"
|
||||
brew "openjdk"
|
||||
# Generate clients, server & docs from an OpenAPI spec (v2, v3)
|
||||
brew "openapi-generator"
|
||||
# Swiss-army knife of markup format conversion
|
||||
brew "pandoc"
|
||||
# Highly capable, feature-rich programming language
|
||||
brew "perl"
|
||||
# Interpreted, interactive, object-oriented programming language
|
||||
brew "python@3.10"
|
||||
# Interpreted, interactive, object-oriented programming language
|
||||
brew "python@3.8"
|
||||
# RC file (dotfile) management
|
||||
@@ -127,6 +148,8 @@ brew "ruby"
|
||||
brew "shellcheck"
|
||||
# Autoformat shell script source code
|
||||
brew "shfmt"
|
||||
# Version control system designed to be a better CVS
|
||||
brew "subversion"
|
||||
# Send macOS User Notifications from the command-line
|
||||
brew "terminal-notifier", link: false
|
||||
# Tool to build, change, and version infrastructure
|
||||
@@ -153,6 +176,8 @@ brew "watch"
|
||||
brew "wget"
|
||||
# Personal information dashboard for your terminal
|
||||
brew "wtfutil"
|
||||
# JavaScript package manager
|
||||
brew "yarn"
|
||||
# Tracks most-used directories to make cd smarter
|
||||
brew "z"
|
||||
# A vulnerability scanner for container images and filesystems
|
||||
@@ -161,6 +186,8 @@ brew "anchore/grype/grype"
|
||||
brew "ddosify/tap/ddosify"
|
||||
# lets you quickly switch between multiple git user profiles
|
||||
brew "gesquive/tap/git-user"
|
||||
# High-performance, schema-free, document-oriented database
|
||||
brew "mongodb/brew/mongodb-community"
|
||||
# Xdebug PHP extension
|
||||
brew "shivammathur/extensions/xdebug@7.4"
|
||||
# Xdebug PHP extension
|
||||
@@ -173,14 +200,30 @@ brew "shivammathur/php/php"
|
||||
brew "shivammathur/php/php@7.4"
|
||||
# General-purpose scripting language
|
||||
brew "shivammathur/php/php@8.0"
|
||||
# Ookla Speedtest
|
||||
brew "teamookla/speedtest/speedtest"
|
||||
# Command-line helper for the 1Password password manager
|
||||
cask "1password-cli"
|
||||
# Text editor
|
||||
cask "coda"
|
||||
# App to build and share containerized applications and microservices
|
||||
cask "docker"
|
||||
# Reimagine your terminal
|
||||
cask "fig"
|
||||
# Unofficial overcast.fm podcast app
|
||||
cask "fog"
|
||||
# Typeface made for developers
|
||||
cask "font-jetbrains-mono"
|
||||
# Developer targeted fonts with a high number of glyphs
|
||||
cask "font-jetbrains-mono-nerd-font"
|
||||
cask "font-lato"
|
||||
cask "font-open-sans"
|
||||
# Font with a mechanical skeleton and the forms are largely geometric
|
||||
cask "font-roboto"
|
||||
cask "font-source-code-pro"
|
||||
cask "font-source-code-pro-for-powerline"
|
||||
cask "font-source-sans-pro"
|
||||
cask "font-source-serif-pro"
|
||||
# Open Source Webfont Converter
|
||||
cask "fontplop"
|
||||
# GIT client
|
||||
@@ -195,6 +238,8 @@ cask "jetbrains-toolbox"
|
||||
cask "lens"
|
||||
# Reverse proxy, secure introspectable tunnels to localhost
|
||||
cask "ngrok"
|
||||
# Collaboration platform for API development
|
||||
cask "postman"
|
||||
# Display image info and preview unsupported formats in QuickLook
|
||||
cask "qlimagesize"
|
||||
# QuickLook generator for Markdown files
|
||||
@@ -205,10 +250,14 @@ cask "qlstephen"
|
||||
cask "quicklook-json"
|
||||
# QuickLook generator for Adobe Swatch Exchange files
|
||||
cask "quicklookase"
|
||||
# Move and resize windows using keyboard shortcuts or snap areas
|
||||
cask "rectangle"
|
||||
# MySQL/MariaDB database management
|
||||
cask "sequel-ace"
|
||||
# Collection of apps available by subscription
|
||||
cask "setapp"
|
||||
# Team communication and collaboration software
|
||||
cask "slack"
|
||||
# Sound and audio controller
|
||||
cask "soundsource"
|
||||
# Application for inspecting installer packages
|
||||
@@ -219,12 +268,18 @@ cask "syntax-highlight"
|
||||
cask "visual-studio-code"
|
||||
# Multimedia player
|
||||
cask "vlc"
|
||||
# Spell-checking service for Finnish
|
||||
cask "voikkospellservice"
|
||||
# Rust-based terminal
|
||||
cask "warp"
|
||||
# View output from scripts in the menu bar
|
||||
cask "xbar"
|
||||
mas "1Password for Safari", id: 1569813296
|
||||
mas "Flow", id: 1423210932
|
||||
mas "GarageBand", id: 682658836
|
||||
mas "iMovie", id: 408981434
|
||||
mas "Keynote", id: 409183694
|
||||
mas "Numbers", id: 409203825
|
||||
mas "Pages", id: 409201541
|
||||
mas "pullBar", id: 1601913905
|
||||
mas "Tailscale", id: 1475387142
|
||||
|
||||
100
README.md
100
README.md
@@ -1,39 +1,58 @@
|
||||
# .dotfiles
|
||||
|
||||
The folder structure follows [XDG Base Directory Specification][xdg] where possible.
|
||||
Welcome to [ivuorinen](https://github.com/ivuorinen)'s .dotfiles repository. It's a hodgepodge of scripts
|
||||
and configurations, tests and mistakes I'm not aware of yet. As I find more interesting tools, configs and
|
||||
other stuff, this repository will live accordingly.
|
||||
|
||||
Please for the love of everything good do not use these 1:1 as your own dotfiles,
|
||||
fork or download the repo as a zip and go from there with your own configs.
|
||||
|
||||
## Setup
|
||||
|
||||
## rcrc
|
||||
### First time setup
|
||||
|
||||
Update install script
|
||||
1. Clone this repository to `$HOME/.dotfiles`
|
||||
2. `bash $HOME/.dotfiles/scripts/settler.sh`
|
||||
3. ???
|
||||
4. Profit
|
||||
|
||||
```bash
|
||||
rcup -B 0 -g > ~/.dotfiles/install.sh | shfmt -w -l ~/.dotfiles/install.sh
|
||||
```
|
||||
Note: there's a bit chicken/egg situation, because settler assumes you don't have git,
|
||||
and you need git to clone the repo. This will change soon™.
|
||||
|
||||
## brew
|
||||
## Interesting files and locations
|
||||
|
||||
Install everything described in `Brewfile`
|
||||
### Special folders
|
||||
|
||||
```bash
|
||||
brew bundle install --force --file=~/.dotfiles/Brewfile
|
||||
```
|
||||
| Path | Description |
|
||||
|--------------------|-------------------------------------------------------------------------------------|
|
||||
| `.github` | GitHub Repository configuration files. Not part of the dotfiles per se. |
|
||||
| `host-{hostname}/` | Host specific dotfiles. Configurations that should apply to that host only. |
|
||||
| `local/bin` | Helper scripts that I've collected or wrote to make life easier. |
|
||||
| `scripts` | Setup scripts. Some can be run many times, some are meant only for the first round. |
|
||||
|
||||
### dotfile folders
|
||||
|
||||
Update `Brewfile`
|
||||
| Repo | Destination | Description |
|
||||
|-----------|-------------|------------------------------------------------------------------|
|
||||
| `config/` | `.config/` | Configurations for applications. |
|
||||
| `local/` | `.local/` | XDG Base folder, contains `bin`, `share` and `state` for example |
|
||||
| `ssh/` | `.ssh/` | SSH Configurations. |
|
||||
|
||||
```bash
|
||||
brew bundle dump --force --file=~/.dotfiles/Brewfile --describe
|
||||
```
|
||||
### dfm - the dotfiles manager
|
||||
|
||||
Enable automatic brew updates and upgrades.
|
||||
`.local/bin/dfm` is a shell script that has some tools that help with dotfiles management.
|
||||
|
||||
```bash
|
||||
brew autoupdate start 43200 --upgrade --cleanup --immediate
|
||||
```
|
||||
### `scripts/install-dotfiles.sh` - dotfiles linker
|
||||
|
||||
## XDG Variables
|
||||
The `scripts/install-dotfiles.sh` is a `rcm` generated shell script that does all the necessary linking.
|
||||
|
||||
To refresh the file, you can run `dfm dotfiles update`
|
||||
|
||||
## Configuration
|
||||
|
||||
The folder structure follows [XDG Base Directory Specification][xdg] where possible.
|
||||
|
||||
### XDG Variables
|
||||
|
||||
| Var | Default |
|
||||
|--------------------|----------------------|
|
||||
@@ -42,15 +61,36 @@ brew autoupdate start 43200 --upgrade --cleanup --immediate
|
||||
| `$XDG_STATE_HOME` | `$HOME/.local/state` |
|
||||
| `$XDG_CONFIG_HOME` | `$HOME/.config` |
|
||||
|
||||
|
||||
- `$XDG_DATA_HOME` defines the base directory relative to which user-specific data files should be stored. If `$XDG_DATA_HOME` is either not set or empty, a default equal to ` $HOME/.local/share` should be used.
|
||||
- `$XDG_CONFIG_HOME` defines the base directory relative to which user-specific configuration files should be stored. If `$XDG_CONFIG_HOME` is either not set or empty, a default equal to `$HOME/.config` should be used.
|
||||
- `$XDG_STATE_HOME` defines the base directory relative to which user-specific state files should be stored. If `$XDG_STATE_HOME` is either not set or empty, a default equal to `$HOME/.local/state` should be used.
|
||||
- The `$XDG_STATE_HOME` contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in `$XDG_DATA_HOME`. It may contain:
|
||||
- actions history (logs, history, recently used files, …)
|
||||
- current state of the application that can be reused on a restart (view, layout, open files, undo history, …)
|
||||
- User-specific executable files may be stored in `$HOME/.local/bin`. Distributions should ensure this directory shows up in the UNIX `$PATH` environment variable, at an appropriate place.
|
||||
- `$XDG_DATA_DIRS` defines the preference-ordered set of base directories to search for data files in addition to the `$XDG_DATA_HOME` base directory. The directories in `$XDG_DATA_DIRS` should be seperated with a colon ':'.
|
||||
|
||||
- `$XDG_DATA_HOME` defines the base directory relative to which user-specific data
|
||||
files should be stored. If `$XDG_DATA_HOME` is either not set or empty,
|
||||
a default equal to `$HOME/.local/share` should be used.
|
||||
- `$XDG_CONFIG_HOME` defines the base directory relative to which user-specific configuration
|
||||
files should be stored. If `$XDG_CONFIG_HOME` is either not set or empty,
|
||||
a default equal to `$HOME/.config` should be used.
|
||||
- `$XDG_STATE_HOME` defines the base directory relative to which user-specific state files should be stored.
|
||||
If `$XDG_STATE_HOME` is either not set or empty, a default equal to `$HOME/.local/state` should be used.
|
||||
- The `$XDG_STATE_HOME` contains state data that should persist between (application) restarts,
|
||||
but that is not important or portable enough to the user that it should be stored in `$XDG_DATA_HOME`.
|
||||
It may contain:
|
||||
- actions history (logs, history, recently used files, …)
|
||||
- current state of the application that can be reused on a restart (view, layout, open files, undo history, …)
|
||||
- User-specific executable files may be stored in `$HOME/.local/bin`. Distributions should ensure this
|
||||
directory shows up in the UNIX `$PATH` environment variable, at an appropriate place.
|
||||
- `$XDG_DATA_DIRS` defines the preference-ordered set of base directories to search for data files in addition
|
||||
to the `$XDG_DATA_HOME` base directory. The directories in `$XDG_DATA_DIRS` should be seperated with a colon ':'.
|
||||
|
||||
[xdg]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||
|
||||
## Interesting links
|
||||
|
||||
### Interesting dotfiles repos
|
||||
|
||||
- https://dotfiles.github.io/inspiration/
|
||||
- https://github.com/frdmn/dotfiles - Ansible-based dotfile setup for macOS
|
||||
- https://github.com/mvdan/dotfiles - Here be dragons
|
||||
- https://github.com/vsouza/dotfiles - 🏡 My dotfiles
|
||||
- https://github.com/freekmurze/dotfiles - My personal dotfiles
|
||||
|
||||
### Interesting dotfiles tools
|
||||
|
||||
- https://github.com/zero-sh/zero.sh - Radically simple personal bootstrapping tool for macOS.
|
||||
|
||||
78
config/alias
78
config/alias
@@ -1,39 +1,77 @@
|
||||
# shellcheck shell=bash
|
||||
# macOS specific
|
||||
|
||||
# Get installed php versions from brew and setup aliases
|
||||
function x-set-php-aliases
|
||||
{
|
||||
local php_versions=()
|
||||
while IFS="" read -r line; do php_versions+=("$line"); done < <(brew list | grep '^php')
|
||||
|
||||
php_error_reporting='-d error_reporting=22527'
|
||||
|
||||
for version in "${php_versions[@]}"; do
|
||||
# drop the dot from version (8.0 -> 80)
|
||||
local php_abbr="${version//\./}"
|
||||
# replace "php@" with "p" so "php@80" becomes "p80"
|
||||
local php_alias="${php_abbr//php@/p}"
|
||||
|
||||
# Skip php = php aliasing
|
||||
# if [[ "$php_abbr" == "$php_alias" ]]; then continue; fi;
|
||||
|
||||
# Fetch the exec path once
|
||||
php_exec="$(brew --prefix "$version")/bin/php"
|
||||
|
||||
# Raw PHP without error_reporting flag.
|
||||
# shellcheck disable=SC2139
|
||||
alias ${php_alias}r="$php_exec"
|
||||
# PHP with error_reporting flag.
|
||||
# shellcheck disable=SC2139
|
||||
alias $php_alias="$php_exec $php_error_reporting"
|
||||
# Local PHP Server.
|
||||
# shellcheck disable=SC2139
|
||||
alias ${php_alias}s="$php_exec -S localhost:9000"
|
||||
# Use composer with specific PHP and error_reporting flag on.
|
||||
# shellcheck disable=SC2139
|
||||
alias ${php_alias}c="$php_exec $php_error_reporting $(which composer)"
|
||||
done
|
||||
}
|
||||
|
||||
if [[ $(uname) == 'Darwin' ]]; then
|
||||
alias file_hide="chflags hidden"
|
||||
alias file_show="chflags nohidden"
|
||||
alias brewUp='brew update && brew outdated && brew upgrade && brew cleanup'
|
||||
|
||||
alias php74='$(brew --prefix php@7.4)/bin/php'
|
||||
alias php80='$(brew --prefix php@8.0)/bin/php -d error_reporting=22527'
|
||||
alias phpc='$(brew --prefix php)/bin/php -d error_reporting=22527'
|
||||
alias php80raw='$(brew --prefix php@8.0)/bin/php'
|
||||
|
||||
alias php-server='php -S localhost:9000'
|
||||
|
||||
alias p74c='$(brew --prefix php@7.4)/bin/php -d error_reporting=22527 $(which composer)'
|
||||
alias p80c='$(brew --prefix php@8.0)/bin/php -d error_reporting=22527 $(which composer)'
|
||||
alias p8c='$(brew --prefix php)/bin/php -d error_reporting=22527 $(which composer)'
|
||||
alias p7a='$(brew --prefix php@7.4)/bin/php artisan'
|
||||
alias p8a='$(brew --prefix php)/bin/php artisan'
|
||||
x-set-php-aliases
|
||||
|
||||
alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail'
|
||||
|
||||
# Flush Directory Service cache
|
||||
alias flushdns="sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder"
|
||||
|
||||
# Lock the screen
|
||||
alias afk="osascript -e 'tell application \"System Events\" to keystroke \"q\" using {command down,control down}'"
|
||||
|
||||
# Empty the Trash on all mounted volumes and the main HDD
|
||||
# Also, clear Apple’s System Logs to improve shell startup speed
|
||||
alias emptytrash="sudo rm -rfv /Volumes/*/.Trashes; sudo rm -rfv ~/.Trash; sudo rm -rfv /private/var/log/asl/*.asl"
|
||||
fi
|
||||
|
||||
alias watchx='watch -dpbc'
|
||||
alias watchx='watch -dpbc' # watch with: differences, precise, beep and color
|
||||
alias zapds='find . -name ".DS_Store" -print -delete'
|
||||
alias t='tail -f'
|
||||
alias dn='du -chd1'
|
||||
alias t='tail -f' # tail with follow flag on
|
||||
alias dn='du -chd1' # directory usage, return only the total
|
||||
|
||||
alias codescanner='docker run --env SOURCE_CODE="$PWD" --volume "$PWD":/code --volume /var/run/docker.sock:/var/run/docker.sock registry.gitlab.com/gitlab-org/ci-cd/codequality:${VERSION:-latest} /code'
|
||||
alias code_scanner="docker run \
|
||||
--env SOURCE_CODE='${PWD}' \
|
||||
--volume '${PWD}':/code \
|
||||
--volume /var/run/docker.sock:/var/run/docker.sock \
|
||||
registry.gitlab.com/gitlab-org/ci-cd/codequality:${CODEQUALITY_VERSION:-latest} \
|
||||
/code"
|
||||
|
||||
alias composerUp='composer global update'
|
||||
alias npmUp='npm -g up'
|
||||
|
||||
alias zedit='code ~/.zshrc ~/.alias'
|
||||
alias zedit='$EDITOR ~/.dotfiles'
|
||||
|
||||
if [[ -f "$HOME/.aliases.local" ]]; then
|
||||
# shellcheck disable=SC1091
|
||||
source "$HOME/.aliases.local"
|
||||
fi
|
||||
|
||||
|
||||
23
config/exports
Normal file
23
config/exports
Normal file
@@ -0,0 +1,23 @@
|
||||
# shellcheck shell=bash
|
||||
|
||||
export HIST_STAMPS="yyyy-mm-dd"
|
||||
|
||||
# Larger bash history (allow 32³ entries; default is 500)
|
||||
export HISTSIZE=32768
|
||||
export HISTFILESIZE=$HISTSIZE
|
||||
export HISTCONTROL=ignoredups
|
||||
|
||||
# Make some commands not show up in history
|
||||
export HISTIGNORE="ls:cd:cd -:pwd:exit:date:* --help"
|
||||
|
||||
# And include the parameter for ZSH
|
||||
export HISTORY_IGNORE="(ls|cd|cd -|pwd|exit|date|* --help)"
|
||||
|
||||
# Highlight section titles in manual pages
|
||||
export LESS_TERMCAP_md="$ORANGE"
|
||||
|
||||
# Don’t clear the screen after quitting a manual page
|
||||
export MANPAGER="less -X"
|
||||
|
||||
# Always enable colored `grep` output
|
||||
export GREP_OPTIONS="--color=auto"
|
||||
6
config/flipperdevices.com/qFlipper.ini
Normal file
6
config/flipperdevices.com/qFlipper.ini
Normal file
@@ -0,0 +1,6 @@
|
||||
[General]
|
||||
ApplicationUpdateChannel=release
|
||||
CheckApplicatonUpdates=true
|
||||
FirmwareUpdateChannel=release
|
||||
LastFolderUrl=/Users/ivuorinen
|
||||
ShowHiddenFiles=false
|
||||
67
config/functions
Normal file
67
config/functions
Normal file
@@ -0,0 +1,67 @@
|
||||
# shellcheck shell=bash
|
||||
#
|
||||
# shell functions
|
||||
#
|
||||
|
||||
# Weather in Tampere, or other city
|
||||
function weather
|
||||
{
|
||||
# https://github.com/chubin/wttr.in#usage
|
||||
local city="${1:-Tampere}"
|
||||
curl "http://wttr.in/${city// /+}?2nFQM&lang=fi"
|
||||
}
|
||||
|
||||
# Docker
|
||||
function ssh-docker
|
||||
{
|
||||
docker exec -it "$@" bash
|
||||
}
|
||||
|
||||
# Create a new directory and enter it
|
||||
function mkd
|
||||
{
|
||||
mkdir -p "$@" && cd "$@" || exit
|
||||
}
|
||||
|
||||
# All the dig info
|
||||
function digga
|
||||
{
|
||||
dig +nocmd "$1" any +multiline +noall +answer
|
||||
}
|
||||
|
||||
# Rector project to php version 8.0 by default.
|
||||
function rector
|
||||
{
|
||||
local php="${1:-80}"
|
||||
docker run -v "$(pwd)":/project rector/rector:latest process \
|
||||
"/project/$1" \
|
||||
--set "php${php}" \
|
||||
--autoload-file /project/vendor/autoload.php
|
||||
}
|
||||
|
||||
# Commit everything
|
||||
function commit
|
||||
{
|
||||
commitMessage="$*"
|
||||
|
||||
if [ "$commitMessage" = "" ]; then
|
||||
commitMessage="Automated commit"
|
||||
fi
|
||||
|
||||
git add .
|
||||
eval "git commit -a -m '${commitMessage}'"
|
||||
}
|
||||
|
||||
function scheduler
|
||||
{
|
||||
while :; do
|
||||
php artisan schedule:run
|
||||
echo "Sleeping 60 seconds..."
|
||||
sleep 60
|
||||
done
|
||||
}
|
||||
|
||||
function silent
|
||||
{
|
||||
"$@" >&/dev/null
|
||||
}
|
||||
@@ -4,6 +4,7 @@
|
||||
*.cache
|
||||
*~
|
||||
|
||||
*-secret
|
||||
__secret
|
||||
__ignored
|
||||
__test_*.php
|
||||
@@ -13,15 +14,7 @@ _theme
|
||||
*.sql.gz
|
||||
*.WordPress.*.xml
|
||||
cachegrind.out.*
|
||||
client-*.json
|
||||
composer.phar
|
||||
devops/.infra_ip_cache
|
||||
wp_*.sh
|
||||
|
||||
redirectRules.csv
|
||||
results_redirectRules.csv
|
||||
testRedirect.sh
|
||||
|
||||
uploads-webpc
|
||||
webpc-passthru.php
|
||||
auth.json
|
||||
dfm.sh
|
||||
|
||||
732
config/nvim/init.lua
Normal file
732
config/nvim/init.lua
Normal file
@@ -0,0 +1,732 @@
|
||||
-- Install packer
|
||||
local install_path = vim.fn.stdpath 'data' .. '/site/pack/packer/start/packer.nvim'
|
||||
local is_bootstrap = false
|
||||
if vim.fn.empty(vim.fn.glob(install_path)) > 0 then
|
||||
is_bootstrap = true
|
||||
vim.fn.system {
|
||||
'git', 'clone', '--depth', '1',
|
||||
'https://github.com/wbthomason/packer.nvim',
|
||||
install_path
|
||||
}
|
||||
vim.cmd [[packadd packer.nvim]]
|
||||
end
|
||||
|
||||
require('packer').startup(function(use)
|
||||
-- Package manager
|
||||
use 'wbthomason/packer.nvim'
|
||||
|
||||
use { -- LSP Configuration & Plugins
|
||||
'neovim/nvim-lspconfig',
|
||||
requires = {
|
||||
-- Automatically install LSPs to stdpath for neovim
|
||||
'williamboman/mason.nvim',
|
||||
'williamboman/mason-lspconfig.nvim',
|
||||
|
||||
-- Useful status updates for LSP
|
||||
'j-hui/fidget.nvim',
|
||||
},
|
||||
}
|
||||
|
||||
use { -- Autocompletion
|
||||
'hrsh7th/nvim-cmp',
|
||||
requires = {
|
||||
'hrsh7th/cmp-nvim-lsp',
|
||||
'L3MON4D3/LuaSnip',
|
||||
'saadparwaiz1/cmp_luasnip',
|
||||
},
|
||||
}
|
||||
|
||||
use { -- Highlight, edit, and navigate code
|
||||
'nvim-treesitter/nvim-treesitter',
|
||||
run = function()
|
||||
pcall(require('nvim-treesitter.install').update { with_sync = true })
|
||||
end,
|
||||
}
|
||||
|
||||
use { -- Additional text objects via treesitter
|
||||
'nvim-treesitter/nvim-treesitter-textobjects',
|
||||
after = 'nvim-treesitter',
|
||||
}
|
||||
|
||||
-- Git related plugins
|
||||
use 'tpope/vim-fugitive'
|
||||
use 'tpope/vim-rhubarb'
|
||||
use 'lewis6991/gitsigns.nvim'
|
||||
|
||||
-- Theme based off the Material Pale Night
|
||||
use 'drewtempelmeyer/palenight.vim'
|
||||
-- Fancier statusline
|
||||
use 'nvim-lualine/lualine.nvim'
|
||||
-- Add indentation guides even on blank lines.
|
||||
use 'lukas-reineke/indent-blankline.nvim'
|
||||
-- "gc" to comment visual regions/lines
|
||||
use 'numToStr/Comment.nvim'
|
||||
-- Detect tabstop and shiftwidth automatically.
|
||||
use 'tpope/vim-sleuth'
|
||||
|
||||
-- Fuzzy Finder (files, lsp, etc)
|
||||
use { 'nvim-telescope/telescope.nvim',
|
||||
branch = '0.1.x', requires = { 'nvim-lua/plenary.nvim' } }
|
||||
|
||||
-- Fuzzy Finder Algorithm which requires local dependencies to be built.
|
||||
-- Only load if `make` is available
|
||||
use { 'nvim-telescope/telescope-fzf-native.nvim',
|
||||
run = 'make', cond = vim.fn.executable 'make' == 1 }
|
||||
|
||||
-- Add custom plugins to packer from
|
||||
-- ~/.config/nvim/lua/custom/plugins.lua
|
||||
local has_plugins, plugins = pcall(require, 'custom.plugins')
|
||||
if has_plugins then
|
||||
plugins(use)
|
||||
end
|
||||
|
||||
if is_bootstrap then
|
||||
require('packer').sync()
|
||||
end
|
||||
end)
|
||||
|
||||
-- When we are bootstrapping a configuration, it doesn't
|
||||
-- make sense to execute the rest of the init.lua.
|
||||
--
|
||||
-- You'll need to restart nvim, and then it will work.
|
||||
if is_bootstrap then
|
||||
print '=================================='
|
||||
print ' Plugins are being installed'
|
||||
print ' Wait until Packer completes,'
|
||||
print ' then restart nvim'
|
||||
print '=================================='
|
||||
return
|
||||
end
|
||||
|
||||
-- Automatically source and re-compile packer
|
||||
-- whenever you save this init.lua, or packages.lua
|
||||
local packer_group = vim.api.nvim_create_augroup('Packer', { clear = true })
|
||||
vim.api.nvim_create_autocmd('BufWritePost', {
|
||||
command = 'source <afile> | PackerCompile',
|
||||
group = packer_group,
|
||||
pattern = { vim.fn.expand '$MYVIMRC' },
|
||||
})
|
||||
-- Automatically run PackerSync for plugins.lua files.
|
||||
vim.api.nvim_create_autocmd('BufWritePost', {
|
||||
command = 'source <afile> | PackerSync | PackerCompile',
|
||||
group = packer_group,
|
||||
pattern = { '~/.dotfiles/config/nvim/**/plugins.lua' },
|
||||
})
|
||||
|
||||
-- [[ Setting options ]]
|
||||
-- See `:help vim.o`
|
||||
|
||||
-- Set highlight on search
|
||||
vim.o.hlsearch = false
|
||||
|
||||
-- Make line numbers default, enabled relative line numbers
|
||||
vim.wo.number = true
|
||||
vim.opt.relativenumber = true
|
||||
|
||||
-- Enable mouse mode
|
||||
vim.o.mouse = 'a'
|
||||
|
||||
-- Enable break indent
|
||||
vim.o.breakindent = true
|
||||
|
||||
-- Save undo history
|
||||
vim.o.undofile = true
|
||||
|
||||
-- Case insensitive searching UNLESS /C or capital in search
|
||||
vim.o.ignorecase = true
|
||||
vim.o.smartcase = true
|
||||
|
||||
-- Decrease update time
|
||||
vim.o.updatetime = 250
|
||||
vim.wo.signcolumn = 'yes'
|
||||
|
||||
-- Set colorscheme
|
||||
vim.o.termguicolors = true
|
||||
vim.cmd.colorscheme('palenight')
|
||||
|
||||
-- Set completeopt to have a better completion experience
|
||||
vim.o.completeopt = 'menuone,noselect'
|
||||
|
||||
-- Configure and disable providers.
|
||||
vim.g.python3_host_prog = '/opt/homebrew/bin/python3'
|
||||
vim.g.loaded_ruby_provider = 0
|
||||
|
||||
-- Setup winbar
|
||||
-- See :h statusline
|
||||
vim.o.winbar = '%=%m %f'
|
||||
|
||||
-- [[ Basic Keymaps ]]
|
||||
-- Set <space> as the leader key
|
||||
-- See `:help mapleader`
|
||||
-- NOTE: Must happen before plugins are required
|
||||
-- (otherwise wrong leader will be used)
|
||||
vim.g.mapleader = ' '
|
||||
vim.g.maplocalleader = ' '
|
||||
|
||||
-- Keymaps for better default experience
|
||||
-- See `:help vim.keymap.set()`
|
||||
vim.keymap.set({ 'n', 'v' }, '<Space>', '<Nop>', { silent = true })
|
||||
|
||||
-- Misc options.
|
||||
vim.o.incsearch = true
|
||||
|
||||
-- Keymap settings, etc.
|
||||
-- ~/.config/nvim/lua/custom/keymaps.lua
|
||||
local map = vim.api.nvim_set_keymap
|
||||
local default_options_table = {
|
||||
expr = true,
|
||||
silent = true,
|
||||
noremap = true,
|
||||
}
|
||||
|
||||
-- normal mode keymap setter
|
||||
---@param keys string Trigger keys
|
||||
---@param func string Function or command to run
|
||||
---@param opts table Optional table of vim.keymap.set options.
|
||||
---@param desc string Optional description
|
||||
local nmap = function(keys, func, opts, desc)
|
||||
if desc then
|
||||
desc = 'keymaps.nmap: ' .. desc
|
||||
end
|
||||
|
||||
local options = default_options_table
|
||||
|
||||
-- If we have options, merge them to the local options table
|
||||
if opts then
|
||||
for k, v in pairs(opts) do
|
||||
options[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
vim.keymap.set('n', keys, func, options)
|
||||
end
|
||||
|
||||
-- visual mode keymap setter
|
||||
---@param keys string Trigger keys
|
||||
---@param func string Function or command to run
|
||||
---@param opts table Optional table of vim.keymap.set options.
|
||||
---@param desc string Optional description
|
||||
local vmap = function(keys, func, opts, desc)
|
||||
if desc then
|
||||
desc = 'keymaps.vmap: ' .. desc
|
||||
end
|
||||
|
||||
local options = default_options_table
|
||||
|
||||
-- If we have options, merge them to the local options table
|
||||
if opts then
|
||||
for k, v in pairs(opts) do
|
||||
options[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
vim.keymap.set('v', keys, func, options)
|
||||
end
|
||||
|
||||
-- Format document
|
||||
nmap("<leader>D", ":Format")
|
||||
|
||||
-- Deal with word wrap
|
||||
nmap('k', "v:count == 0 ? 'gk' : 'k'")
|
||||
nmap('j', "v:count == 0 ? 'gj' : 'j'")
|
||||
|
||||
-- Diagnostic keymaps
|
||||
nmap('dz', vim.diagnostic.goto_prev)
|
||||
nmap('dx', vim.diagnostic.goto_next)
|
||||
nmap('<leader>e', vim.diagnostic.open_float)
|
||||
nmap('<leader>q', vim.diagnostic.setloclist)
|
||||
|
||||
--
|
||||
-- ThePrimeagen/refactoring.nvim
|
||||
-- https://github.com/ThePrimeagen/refactoring.nvim
|
||||
--
|
||||
|
||||
-- Remaps for the refactoring operations currently offered by the plugin
|
||||
local rf = { noremap = true, silent = true, expr = false }
|
||||
vmap("<leader>re", [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function')<CR>]], rf)
|
||||
vmap("<leader>rf", [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Function To File')<CR>]], rf)
|
||||
vmap("<leader>rv", [[ <Esc><Cmd>lua require('refactoring').refactor('Extract Variable')<CR>]], rf)
|
||||
vmap("<leader>ri", [[ <Esc><Cmd>lua require('refactoring').refactor('Inline Variable')<CR>]], rf)
|
||||
|
||||
-- Extract block doesn't need visual mode
|
||||
nmap("<leader>rb", [[ <Cmd>lua require('refactoring').refactor('Extract Block')<CR>]], rf)
|
||||
nmap("<leader>rbf", [[ <Cmd>lua require('refactoring').refactor('Extract Block To File')<CR>]], rf)
|
||||
|
||||
-- Inline variable can also pick up the identifier currently under the cursor without visual mode
|
||||
nmap("<leader>ri", [[ <Cmd>lua require('refactoring').refactor('Inline Variable')<CR>]], rf)
|
||||
|
||||
-- prompt for a refactor to apply when the remap is triggered
|
||||
vmap("<leader>rr", ":lua require('refactoring').select_refactor()<CR>", rf)
|
||||
|
||||
--
|
||||
--
|
||||
--
|
||||
|
||||
-- barbar keymaps
|
||||
local barbar_opts = { noremap = true, silent = true }
|
||||
|
||||
-- Move to previous/next
|
||||
map('n', '<C-,>', '<Cmd>BufferPrevious<CR>', barbar_opts)
|
||||
map('n', '<C-.>', '<Cmd>BufferNext<CR>', barbar_opts)
|
||||
-- Re-order to previous/next
|
||||
map('n', '<C-<>', '<Cmd>BufferMovePrevious<CR>', barbar_opts)
|
||||
map('n', '<C->>', '<Cmd>BufferMoveNext<CR>', barbar_opts)
|
||||
-- Goto buffer in position...
|
||||
map('n', '<leader>b1', '<Cmd>BufferGoto 1<CR>', barbar_opts)
|
||||
map('n', '<leader>b2', '<Cmd>BufferGoto 2<CR>', barbar_opts)
|
||||
map('n', '<leader>b3', '<Cmd>BufferGoto 3<CR>', barbar_opts)
|
||||
map('n', '<leader>b4', '<Cmd>BufferGoto 4<CR>', barbar_opts)
|
||||
map('n', '<leader>b5', '<Cmd>BufferGoto 5<CR>', barbar_opts)
|
||||
map('n', '<leader>b6', '<Cmd>BufferGoto 6<CR>', barbar_opts)
|
||||
map('n', '<leader>b7', '<Cmd>BufferGoto 7<CR>', barbar_opts)
|
||||
map('n', '<leader>b8', '<Cmd>BufferGoto 8<CR>', barbar_opts)
|
||||
map('n', '<leader>b9', '<Cmd>BufferGoto 9<CR>', barbar_opts)
|
||||
map('n', '<leader>b0', '<Cmd>BufferLast<CR>', barbar_opts)
|
||||
-- Pin/unpin buffer
|
||||
map('n', '<A-p>', '<Cmd>BufferPin<CR>', barbar_opts)
|
||||
-- Close buffer
|
||||
map('n', '<A-c>', '<Cmd>BufferClose<CR>', barbar_opts)
|
||||
-- Wipeout buffer
|
||||
-- :BufferWipeout
|
||||
-- Close commands
|
||||
-- :BufferCloseAllButCurrent
|
||||
-- :BufferCloseAllButPinned
|
||||
-- :BufferCloseAllButCurrentOrPinned
|
||||
-- :BufferCloseBuffersLeft
|
||||
-- :BufferCloseBuffersRight
|
||||
-- Magic buffer-picking mode
|
||||
map('n', '<C-p>', '<Cmd>BufferPick<CR>', barbar_opts)
|
||||
-- Sort automatically by...
|
||||
map('n', '<Space>bb', '<Cmd>BufferOrderByBufferNumber<CR>', barbar_opts)
|
||||
map('n', '<Space>bd', '<Cmd>BufferOrderByDirectory<CR>', barbar_opts)
|
||||
map('n', '<Space>bl', '<Cmd>BufferOrderByLanguage<CR>', barbar_opts)
|
||||
map('n', '<Space>bw', '<Cmd>BufferOrderByWindowNumber<CR>', barbar_opts)
|
||||
|
||||
-- Other:
|
||||
-- :BarbarEnable - enables barbar (enabled by default)
|
||||
-- :BarbarDisable - very bad command, should never be used
|
||||
|
||||
|
||||
local highlight_group = vim.api.nvim_create_augroup(
|
||||
'YankHighlight', { clear = true }
|
||||
)
|
||||
vim.api.nvim_create_autocmd('TextYankPost', {
|
||||
callback = function()
|
||||
vim.highlight.on_yank()
|
||||
end,
|
||||
group = highlight_group,
|
||||
pattern = '*',
|
||||
})
|
||||
|
||||
-- Set lualine as statusline
|
||||
-- See `:help lualine.txt`
|
||||
require('lualine').setup {
|
||||
options = {
|
||||
icons_enabled = true,
|
||||
theme = 'auto',
|
||||
component_separators = '|',
|
||||
section_separators = '',
|
||||
},
|
||||
}
|
||||
|
||||
-- Enable Comment.nvim
|
||||
require('Comment').setup()
|
||||
|
||||
-- Enable `lukas-reineke/indent-blankline.nvim`
|
||||
-- See `:help indent_blankline.txt`
|
||||
require('indent_blankline').setup {
|
||||
-- char = '┊',
|
||||
show_trailing_blankline_indent = true,
|
||||
space_char_blankline = " ",
|
||||
show_current_context = true,
|
||||
show_current_context_start = true,
|
||||
}
|
||||
|
||||
-- Gitsigns
|
||||
-- See `:help gitsigns.txt`
|
||||
require('gitsigns').setup {
|
||||
signs = {
|
||||
add = { text = '+' },
|
||||
change = { text = '~' },
|
||||
delete = { text = '_' },
|
||||
topdelete = { text = '‾' },
|
||||
changedelete = { text = '~' },
|
||||
},
|
||||
}
|
||||
|
||||
-- [[ Configure Telescope ]]
|
||||
-- See `:help telescope` and `:help telescope.setup()`
|
||||
require('telescope').setup {
|
||||
defaults = {
|
||||
mappings = {
|
||||
i = {
|
||||
['<C-u>'] = false,
|
||||
['<C-d>'] = false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Enable telescope fzf native, if installed
|
||||
pcall(require('telescope').load_extension, 'fzf')
|
||||
|
||||
local ks = vim.keymap.set
|
||||
local tl = require('telescope.builtin')
|
||||
|
||||
-- See `:help telescope.builtin`
|
||||
ks('n', '<leader>?', tl.oldfiles, { desc = '[?] Find recently opened files' })
|
||||
ks('n', '<leader><space>', tl.buffers, { desc = '[ ] Find existing buffers' })
|
||||
ks('n', '<leader>/', function()
|
||||
-- You can pass additional configuration to telescope to
|
||||
-- change theme, layout, etc.
|
||||
tl.current_buffer_fuzzy_find(
|
||||
require('telescope.themes').get_dropdown {
|
||||
winblend = 10,
|
||||
previewer = false,
|
||||
})
|
||||
end, { desc = '[/] Fuzzily search in current buffer]' })
|
||||
|
||||
ks('n', '<leader>sf', tl.find_files, { desc = '[S]earch [F]iles' })
|
||||
ks('n', '<leader>sh', tl.help_tags, { desc = '[S]earch [H]elp' })
|
||||
ks('n', '<leader>sw', tl.grep_string, { desc = '[S]earch current [W]ord' })
|
||||
ks('n', '<leader>sg', tl.live_grep, { desc = '[S]earch by [G]rep' })
|
||||
ks('n', '<leader>sd', tl.diagnostics, { desc = '[S]earch [D]iagnostics' })
|
||||
|
||||
-- Add harpoon to telescope
|
||||
require("telescope").load_extension('harpoon')
|
||||
|
||||
-- [[ Configure Treesitter ]]
|
||||
-- See `:help nvim-treesitter`
|
||||
require('nvim-treesitter.configs').setup {
|
||||
-- Add languages to be installed here that you want
|
||||
-- installed for treesitter
|
||||
ensure_installed = {
|
||||
'bash',
|
||||
'c', 'comment', 'cpp',
|
||||
'diff', 'dockerfile',
|
||||
'gitattributes', 'gitignore', 'go',
|
||||
'html', 'http',
|
||||
'javascript', 'jq', 'jsdoc', 'json',
|
||||
'lua',
|
||||
'markdown',
|
||||
'org',
|
||||
'php', 'phpdoc', 'python',
|
||||
'regex', 'rust',
|
||||
'scss', 'sql',
|
||||
'typescript',
|
||||
'vim', 'vue',
|
||||
'yaml',
|
||||
'help',
|
||||
},
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
-- Required for spellcheck, some LaTex highlights and
|
||||
-- code block highlights that do not have ts grammar
|
||||
additional_vim_regex_highlighting = { 'org' },
|
||||
},
|
||||
|
||||
indent = { enable = true, disable = { 'python' } },
|
||||
|
||||
incremental_selection = {
|
||||
enable = true,
|
||||
keymaps = {
|
||||
init_selection = '<c-space>',
|
||||
node_incremental = '<c-space>',
|
||||
scope_incremental = '<c-s>',
|
||||
node_decremental = '<c-backspace>',
|
||||
},
|
||||
},
|
||||
|
||||
textobjects = {
|
||||
select = {
|
||||
enable = true,
|
||||
-- Automatically jump forward to textobj, similar to targets.vim
|
||||
lookahead = true,
|
||||
keymaps = {
|
||||
-- You can use the capture groups defined in textobjects.scm
|
||||
['aa'] = '@parameter.outer',
|
||||
['ia'] = '@parameter.inner',
|
||||
['af'] = '@function.outer',
|
||||
['if'] = '@function.inner',
|
||||
['ac'] = '@class.outer',
|
||||
['ic'] = '@class.inner',
|
||||
},
|
||||
},
|
||||
move = {
|
||||
enable = true,
|
||||
set_jumps = true, -- whether to set jumps in the jumplist
|
||||
goto_next_start = {
|
||||
[']m'] = '@function.outer',
|
||||
[']]'] = '@class.outer',
|
||||
},
|
||||
goto_next_end = {
|
||||
[']M'] = '@function.outer',
|
||||
[']['] = '@class.outer',
|
||||
},
|
||||
goto_previous_start = {
|
||||
['[m'] = '@function.outer',
|
||||
['[['] = '@class.outer',
|
||||
},
|
||||
goto_previous_end = {
|
||||
['[M'] = '@function.outer',
|
||||
['[]'] = '@class.outer',
|
||||
},
|
||||
},
|
||||
swap = {
|
||||
enable = true,
|
||||
swap_next = {
|
||||
['<leader>a'] = '@parameter.inner',
|
||||
},
|
||||
swap_previous = {
|
||||
['<leader>A'] = '@parameter.inner',
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- Load custom treesitter grammar for org filetype
|
||||
require('orgmode').setup_ts_grammar()
|
||||
require('orgmode').setup({
|
||||
org_agenda_files = {
|
||||
vim.fn.expand '~/.local/share/_nvalt/**/*',
|
||||
vim.fn.expand '~/.dotfiles/local/org/**/*'
|
||||
},
|
||||
org_default_notes_file = vim.fn.expand '~/.local/share/_nvalt/refile.org',
|
||||
})
|
||||
|
||||
-- LSP settings.
|
||||
-- This function gets run when an LSP connects to a particular buffer.
|
||||
local on_attach = function(_, bufnr)
|
||||
-- NOTE: Remember that lua is a real programming language,
|
||||
-- and as such it is possible to define small helper and
|
||||
-- utility functions so you don't have to repeat yourself
|
||||
-- many times.
|
||||
--
|
||||
-- In this case, we create a function that lets us more
|
||||
-- easily define mappings specific for LSP related items.
|
||||
-- It sets the mode, buffer and description for us each time.
|
||||
local nm = function(keys, func, desc)
|
||||
if desc then
|
||||
desc = 'LSP: ' .. desc
|
||||
end
|
||||
|
||||
vim.keymap.set('n', keys, func, { buffer = bufnr, desc = desc })
|
||||
end
|
||||
|
||||
local t = require('telescope.builtin')
|
||||
local vbuf = vim.lsp.buf
|
||||
|
||||
nm('<leader>rn', vbuf.rename, '[R]e[n]ame')
|
||||
nm('<leader>ca', vbuf.code_action, '[C]ode [A]ction')
|
||||
|
||||
nm('gd', vbuf.definition, '[G]oto [D]efinition')
|
||||
nm('gr', t.lsp_references, '[G]oto [R]eferences')
|
||||
nm('gI', vbuf.implementation, '[G]oto [I]mplementation')
|
||||
nm('<leader>D', vbuf.type_definition, 'Type [D]efinition')
|
||||
nm('<leader>ds', t.lsp_document_symbols, '[D]ocument [S]ymbols')
|
||||
nm('<leader>ws', t.lsp_dynamic_workspace_symbols, '[W]orkspace [S]ymbols')
|
||||
|
||||
-- See `:help K` for why this keymap
|
||||
nm('K', vbuf.hover, 'Hover Documentation')
|
||||
nm('<C-k>', vbuf.signature_help, 'Signature Documentation')
|
||||
|
||||
-- Lesser used LSP functionality
|
||||
nm('gD', vbuf.declaration, '[G]oto [D]eclaration')
|
||||
nm('<leader>wa', vbuf.add_workspace_folder, '[W]orkspace [A]dd Folder')
|
||||
nm('<leader>wr', vbuf.remove_workspace_folder, '[W]orkspace [R]emove Folder')
|
||||
nm('<leader>wl', function()
|
||||
print(vim.inspect(vbuf.list_workspace_folders()))
|
||||
end, '[W]orkspace [L]ist Folders')
|
||||
|
||||
-- Create a command `:Format` local to the LSP buffer
|
||||
vim.api.nvim_buf_create_user_command(bufnr, 'Format', function(_)
|
||||
if vim.lsp.buf.format then
|
||||
vim.lsp.buf.format()
|
||||
elseif vim.lsp.buf.formatting then
|
||||
vim.lsp.buf.formatting()
|
||||
end
|
||||
end, { desc = 'Format current buffer with LSP' })
|
||||
end
|
||||
|
||||
-- Setup mason so it can manage external tooling
|
||||
require('mason').setup()
|
||||
require("null-ls").setup()
|
||||
|
||||
-- Enable the following language servers.
|
||||
-- Feel free to add/remove any LSPs that you want here.
|
||||
-- They will automatically be installed.
|
||||
-- https://github.com/williamboman/mason-lspconfig.nvim#available-lsp-servers
|
||||
local servers = {
|
||||
-- a
|
||||
'angularls',
|
||||
'ansiblels',
|
||||
-- b
|
||||
'bashls',
|
||||
-- c
|
||||
'clangd',
|
||||
'cssls',
|
||||
-- d
|
||||
'dockerls',
|
||||
-- e
|
||||
'eslint',
|
||||
'emmet_ls',
|
||||
-- f
|
||||
-- g
|
||||
'gopls',
|
||||
'graphql',
|
||||
-- h
|
||||
'html',
|
||||
-- i
|
||||
-- j
|
||||
'quick_lint_js', -- js
|
||||
'jsonls',
|
||||
-- k
|
||||
-- l
|
||||
'sumneko_lua', -- lua
|
||||
-- m
|
||||
'marksman', -- markdown
|
||||
-- n
|
||||
-- o
|
||||
-- p
|
||||
'intelephense', 'phpactor', 'psalm',
|
||||
'pyright',
|
||||
-- q
|
||||
-- r
|
||||
'rust_analyzer',
|
||||
-- s
|
||||
'sqlls',
|
||||
'stylelint_lsp',
|
||||
-- t
|
||||
'tailwindcss',
|
||||
'terraformls',
|
||||
'tflint',
|
||||
'tsserver',
|
||||
-- u
|
||||
-- v / w
|
||||
'volar', -- vue
|
||||
'vuels', -- vue
|
||||
-- x / y / z
|
||||
'lemminx', -- xml
|
||||
'yamlls', -- yaml
|
||||
}
|
||||
|
||||
-- Ensure the servers above are installed
|
||||
require('mason-lspconfig').setup {
|
||||
ensure_installed = servers,
|
||||
}
|
||||
|
||||
require("mason-lspconfig").setup_handlers {
|
||||
-- The first entry (without a key) will be the default handler
|
||||
-- and will be called for each installed server that doesn't have
|
||||
-- a dedicated handler.
|
||||
function(server_name)
|
||||
-- default handler (optional)
|
||||
require("lspconfig")[server_name].setup {}
|
||||
end,
|
||||
}
|
||||
|
||||
-- nvim-cmp supports additional completion capabilities
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
||||
|
||||
for _, lsp in ipairs(servers) do
|
||||
require('lspconfig')[lsp].setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
}
|
||||
end
|
||||
|
||||
-- Turn on lsp status information
|
||||
require('fidget').setup()
|
||||
|
||||
-- Example custom configuration for lua.
|
||||
-- Make runtime files discoverable to the server
|
||||
local runtime_path = vim.split(package.path, ';')
|
||||
table.insert(runtime_path, 'lua/?.lua')
|
||||
table.insert(runtime_path, 'lua/?/init.lua')
|
||||
|
||||
require('lspconfig').sumneko_lua.setup {
|
||||
on_attach = on_attach,
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
-- Tell the language server which version of Lua you're
|
||||
-- using (most likely LuaJIT)
|
||||
version = 'LuaJIT',
|
||||
-- Setup your lua path
|
||||
path = runtime_path,
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { 'vim' },
|
||||
},
|
||||
workspace = {
|
||||
library = vim.api.nvim_get_runtime_file('', true),
|
||||
checkThirdParty = false,
|
||||
},
|
||||
-- Do not send telemetry data containing a randomized
|
||||
-- but unique identifier
|
||||
telemetry = { enable = false },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
-- nvim-cmp setup
|
||||
local cmp = require 'cmp'
|
||||
local luasnip = require 'luasnip'
|
||||
|
||||
cmp.setup {
|
||||
snippet = {
|
||||
expand = function(args)
|
||||
luasnip.lsp_expand(args.body)
|
||||
end,
|
||||
},
|
||||
mapping = cmp.mapping.preset.insert {
|
||||
['<C-d>'] = cmp.mapping.scroll_docs(-4),
|
||||
['<C-f>'] = cmp.mapping.scroll_docs(4),
|
||||
['<C-Space>'] = cmp.mapping.complete(),
|
||||
['<CR>'] = cmp.mapping.confirm {
|
||||
behavior = cmp.ConfirmBehavior.Replace,
|
||||
select = true,
|
||||
},
|
||||
['<Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
elseif luasnip.expand_or_jumpable() then
|
||||
luasnip.expand_or_jump()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
['<S-Tab>'] = cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
elseif luasnip.jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end, { 'i', 's' }),
|
||||
},
|
||||
sources = {
|
||||
{ name = 'nvim_lsp' },
|
||||
{ name = 'luasnip' },
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
|
||||
vim.api.nvim_create_autocmd("BufWritePost",
|
||||
{ pattern = "plugins.lua", command = "source <afile> | PackerSync" })
|
||||
vim.api.nvim_create_autocmd("BufRead",
|
||||
{ pattern = "*/node_modules/*", command = "lua vim.diagnostic.disable(0)" })
|
||||
vim.api.nvim_create_autocmd("BufNewFile",
|
||||
{ pattern = "*/node_modules/*", command = "lua vim.diagnostic.disable(0)" })
|
||||
-- Enable spell checking for certain file types
|
||||
vim.api.nvim_create_autocmd({ "BufRead", "BufNewFile" },
|
||||
{ pattern = { "*.txt", "*.md", "*.tex" },
|
||||
command = "setlocal spell" })
|
||||
|
||||
-- The line beneath this is called `modeline`. See `:help modeline`
|
||||
-- vim: ts=2 sts=2 sw=2 et
|
||||
210
config/nvim/lua/custom/plugins.lua
Normal file
210
config/nvim/lua/custom/plugins.lua
Normal file
@@ -0,0 +1,210 @@
|
||||
return function(use)
|
||||
|
||||
-- 💥 Create key bindings that stick.
|
||||
-- WhichKey is a lua plugin that displays a popup with
|
||||
-- possible keybindings of the command you started typing.
|
||||
-- https://github.com/folke/which-key.nvim
|
||||
use({
|
||||
"folke/which-key.nvim",
|
||||
config = function()
|
||||
require("which-key").setup({})
|
||||
end
|
||||
})
|
||||
|
||||
-- 🍨 Soothing pastel theme for (Neo)vim
|
||||
-- https://github.com/catppuccin/nvim
|
||||
-- use { "catppuccin/nvim", as = "catppuccin" }
|
||||
-- vim.cmd.colorscheme('catppuccin-latte')
|
||||
|
||||
-- markdown preview plugin for (neo)vim
|
||||
-- https://github.com/iamcco/markdown-preview.nvim
|
||||
use({
|
||||
"iamcco/markdown-preview.nvim",
|
||||
run = function()
|
||||
vim.fn["mkdp#util#install"]()
|
||||
end,
|
||||
})
|
||||
|
||||
-- The neovim tabline plugin.
|
||||
-- https://github.com/romgrk/barbar.nvim
|
||||
use 'nvim-tree/nvim-web-devicons'
|
||||
use { 'romgrk/barbar.nvim', wants = 'nvim-web-devicons' }
|
||||
|
||||
--
|
||||
-- Pretty UI
|
||||
--
|
||||
|
||||
-- Neovim plugin to improve the default vim.ui interfaces
|
||||
use 'stevearc/dressing.nvim'
|
||||
-- A fancy, configurable, notification manager for NeoVim
|
||||
use 'rcarriga/nvim-notify'
|
||||
-- Non-intrusive notification system for neovim
|
||||
use 'vigoux/notifier.nvim'
|
||||
-- ✅ Highlight, list and search todo comments in your projects
|
||||
use {
|
||||
'folke/todo-comments.nvim',
|
||||
requires = 'nvim-lua/plenary.nvim',
|
||||
config = function()
|
||||
require('todo-comments').setup {}
|
||||
end,
|
||||
}
|
||||
|
||||
-- The Refactoring library based off the Refactoring book by Martin Fowler
|
||||
-- https://github.com/ThePrimeagen/refactoring.nvim
|
||||
use {
|
||||
"ThePrimeagen/refactoring.nvim",
|
||||
requires = {
|
||||
{ "nvim-lua/plenary.nvim" },
|
||||
{ "nvim-treesitter/nvim-treesitter" }
|
||||
}
|
||||
}
|
||||
|
||||
-- harpoon, by ThePrimeagen
|
||||
-- https://github.com/ThePrimeagen/harpoon
|
||||
use {
|
||||
"ThePrimeagen/harpoon",
|
||||
requires = { { "nvim-lua/plenary.nvim" } }
|
||||
}
|
||||
|
||||
-- An asynchronous linter plugin for Neovim complementary to
|
||||
-- the built-in Language Server Protocol support.
|
||||
-- https://github.com/mfussenegger/nvim-lint
|
||||
use 'mfussenegger/nvim-lint'
|
||||
vim.api.nvim_create_autocmd({ "BufWritePost" }, {
|
||||
callback = function()
|
||||
require("lint").try_lint()
|
||||
end,
|
||||
})
|
||||
|
||||
-- nvim orgmode, to get me use nvim even more.
|
||||
use({
|
||||
"nvim-orgmode/orgmode",
|
||||
config = function()
|
||||
require('orgmode').setup_ts_grammar()
|
||||
end,
|
||||
})
|
||||
|
||||
-- Markdown support
|
||||
use 'preservim/vim-markdown'
|
||||
use 'godlygeek/tabular'
|
||||
|
||||
-- obsidian plugin for nvim
|
||||
-- https://github.com/epwalsh/obsidian.nvim
|
||||
use({
|
||||
"epwalsh/obsidian.nvim",
|
||||
config = function()
|
||||
require("obsidian").setup({
|
||||
dir = '~/.local/share/_nvalt',
|
||||
notes_subdir = "notes",
|
||||
daily_notes = {
|
||||
folder = "_daily"
|
||||
},
|
||||
completion = {
|
||||
nvim_cmp = true, -- if using nvim-cmp, otherwise set to false
|
||||
}
|
||||
})
|
||||
end
|
||||
})
|
||||
|
||||
-- Creates missing folders on save
|
||||
-- https://github.com/jghauser/mkdir.nvim
|
||||
use { 'jghauser/mkdir.nvim' }
|
||||
|
||||
-- Neovim plugin for dimming the highlights of unused
|
||||
-- functions, variables, parameters, and more
|
||||
-- https://github.com/zbirenbaum/neodim
|
||||
use {
|
||||
"zbirenbaum/neodim",
|
||||
event = "LspAttach",
|
||||
config = function()
|
||||
require("neodim").setup({
|
||||
alpha = 0.75,
|
||||
blend_color = "#000000",
|
||||
update_in_insert = {
|
||||
enable = true,
|
||||
delay = 100,
|
||||
},
|
||||
hide = {
|
||||
virtual_text = true,
|
||||
signs = true,
|
||||
underline = true,
|
||||
}
|
||||
})
|
||||
end
|
||||
}
|
||||
|
||||
-- EditorConfig plugin for Neovim
|
||||
-- https://github.com/gpanders/editorconfig.nvim
|
||||
use { 'gpanders/editorconfig.nvim' }
|
||||
|
||||
-- Use Neovim as a language server to inject LSP diagnostics, code actions, and more via Lua.
|
||||
-- https://github.com/jose-elias-alvarez/null-ls.nvim
|
||||
use {
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
config = function()
|
||||
local n = require("null-ls")
|
||||
local b = n.builtins
|
||||
require("null-ls").setup({
|
||||
b.code_actions.eslint,
|
||||
b.code_actions.shellcheck,
|
||||
b.code_actions.xo,
|
||||
b.completion.luasnip,
|
||||
b.completion.spell,
|
||||
b.diagnostics.actionlint,
|
||||
b.diagnostics.alex,
|
||||
b.diagnostics.ansiblelint,
|
||||
b.diagnostics.codespell,
|
||||
b.diagnostics.dotenv_linter,
|
||||
b.diagnostics.editorconfig_checker,
|
||||
b.diagnostics.eslint,
|
||||
b.diagnostics.hadolint,
|
||||
b.diagnostics.jsonlint,
|
||||
b.diagnostics.luacheck,
|
||||
b.diagnostics.markdownlint,
|
||||
b.diagnostics.php,
|
||||
b.diagnostics.phpcs,
|
||||
b.diagnostics.phpstan,
|
||||
b.diagnostics.psalm,
|
||||
b.diagnostics.shellcheck,
|
||||
b.diagnostics.spectral,
|
||||
b.diagnostics.stylelint,
|
||||
b.diagnostics.todo_comments,
|
||||
b.diagnostics.trail_space,
|
||||
b.diagnostics.xo,
|
||||
b.diagnostics.yamllint,
|
||||
b.formatting.blade_formatter,
|
||||
b.formatting.eslint,
|
||||
b.formatting.fixjson,
|
||||
b.formatting.lua_format,
|
||||
b.formatting.markdownlint,
|
||||
b.formatting.prettier,
|
||||
b.formatting.shfmt,
|
||||
b.formatting.stylelint,
|
||||
-- b.formatting.stylua,
|
||||
b.formatting.terraform_fmt,
|
||||
b.formatting.trim_whitespace,
|
||||
b.formatting.yamlfmt,
|
||||
})
|
||||
end,
|
||||
requires = { "nvim-lua/plenary.nvim" }
|
||||
}
|
||||
|
||||
-- mason-null-ls bridges mason.nvim with the null-ls plugin
|
||||
-- - making it easier to use both plugins together.
|
||||
-- https://github.com/jay-babu/mason-null-ls.nvim
|
||||
use {
|
||||
"jayp0521/mason-null-ls.nvim",
|
||||
config = function()
|
||||
require("mason-null-ls").setup({
|
||||
ensure_installed = nil,
|
||||
automatic_installation = true,
|
||||
automatic_setup = false,
|
||||
})
|
||||
end,
|
||||
requires = { "jose-elias-alvarez/null-ls.nvim" }
|
||||
}
|
||||
|
||||
-- WakaTime Support
|
||||
use { "wakatime/vim-wakatime" }
|
||||
|
||||
end
|
||||
1
config/nvim/plugin/.gitignore
vendored
Normal file
1
config/nvim/plugin/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
packer_compiled.lua
|
||||
53
config/tmux/tmux.conf
Normal file
53
config/tmux/tmux.conf
Normal file
@@ -0,0 +1,53 @@
|
||||
# ~/.config/tmux/tmux.conf, or .dotfiles/config/tmux/tmux.conf
|
||||
#
|
||||
# Contains configuration from the follwing sources:
|
||||
# - https://tmuxguide.readthedocs.io/en/latest/tmux/tmux.html
|
||||
# -
|
||||
|
||||
# unbind default prefix and set it to ctrl-a
|
||||
unbind C-b
|
||||
set -g prefix C-a
|
||||
bind C-a send-prefix
|
||||
|
||||
# make delay shorter
|
||||
set -sg escape-time 0
|
||||
|
||||
|
||||
|
||||
#### key bindings ####
|
||||
|
||||
# reload config file
|
||||
bind r source-file ~/.dotfiles/config/tmux/tmux.conf \; display "tmux.conf reloaded!"
|
||||
|
||||
# quickly open a new window
|
||||
bind N new-window
|
||||
|
||||
# synchronize all panes in a window
|
||||
bind y setw synchronize-panes
|
||||
|
||||
# pane movement shortcuts (same as vim)
|
||||
bind h select-pane -L
|
||||
bind j select-pane -D
|
||||
bind k select-pane -U
|
||||
bind l select-pane -R
|
||||
|
||||
# enable mouse support for switching panes/windows
|
||||
#set -g mouse-utf8 on
|
||||
#set -g mouse on
|
||||
|
||||
#### copy mode : vim ####
|
||||
|
||||
# set vi mode for copy mode
|
||||
setw -g mode-keys vi
|
||||
|
||||
# copy mode using 'Esc'
|
||||
unbind [
|
||||
bind Escape copy-mode
|
||||
|
||||
# start selection with 'space' and copy using 'y'
|
||||
#bind -t vi-copy 'y' copy-selection
|
||||
|
||||
# paste using 'p'
|
||||
unbind p
|
||||
bind p paste-buffer
|
||||
|
||||
@@ -58,3 +58,9 @@
|
||||
allowedSignersFile = ~/.ssh/allowed_signers
|
||||
[commit]
|
||||
gpgsign = true
|
||||
[credential "https://github.com"]
|
||||
helper =
|
||||
helper = !/opt/homebrew/bin/gh auth git-credential
|
||||
[credential "https://gist.github.com"]
|
||||
helper =
|
||||
helper = !/opt/homebrew/bin/gh auth git-credential
|
||||
|
||||
4
huskyrc
4
huskyrc
@@ -1,7 +1,7 @@
|
||||
#!/bin/env bash
|
||||
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
||||
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
||||
|
||||
alias php="php -d error_reporting=22527"
|
||||
|
||||
83
install.sh
83
install.sh
@@ -1,83 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# sh install.sh
|
||||
#
|
||||
# Environment variables: VERBOSE, CP, LN, MKDIR, RM, DIRNAME.
|
||||
#
|
||||
# env VERBOSE=1 sh install.sh
|
||||
#
|
||||
# DO NOT EDIT THIS FILE
|
||||
#
|
||||
# This file is generated by rcm(7) as:
|
||||
#
|
||||
# rcup -B 0 -g
|
||||
#
|
||||
# To update it, re-run the above command.
|
||||
#
|
||||
: ${VERBOSE:=0}
|
||||
: ${CP:=/bin/cp}
|
||||
: ${LN:=/bin/ln}
|
||||
: ${MKDIR:=/bin/mkdir}
|
||||
: ${RM:=/bin/rm}
|
||||
: ${DIRNAME:=/usr/bin/dirname}
|
||||
verbose() {
|
||||
if [ "$VERBOSE" -gt 0 ]; then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
handle_file_cp() {
|
||||
if [ -e "$2" ]; then
|
||||
printf "%s " "overwrite $2? [yN]"
|
||||
read overwrite
|
||||
case "$overwrite" in
|
||||
y)
|
||||
$RM -rf "$2"
|
||||
;;
|
||||
*)
|
||||
echo "skipping $2"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
verbose "'$1' -> '$2'"
|
||||
$MKDIR -p "$($DIRNAME "$2")"
|
||||
$CP -R "$1" "$2"
|
||||
}
|
||||
handle_file_ln() {
|
||||
if [ -e "$2" ]; then
|
||||
printf "%s " "overwrite $2? [yN]"
|
||||
read overwrite
|
||||
case "$overwrite" in
|
||||
y)
|
||||
$RM -rf "$2"
|
||||
;;
|
||||
*)
|
||||
echo "skipping $2"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
verbose "'$1' -> '$2'"
|
||||
$MKDIR -p "$($DIRNAME "$2")"
|
||||
$LN -sf "$1" "$2"
|
||||
}
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/bash_profile" "/Users/ivuorinen/.bash_profile"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/bashrc" "/Users/ivuorinen/.bashrc"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/config/alias" "/Users/ivuorinen/.config/alias"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/config/antigen.zsh" "/Users/ivuorinen/.config/antigen.zsh"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/config/gh/config.yml" "/Users/ivuorinen/.config/gh/config.yml"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/config/git/config" "/Users/ivuorinen/.config/git/config"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/config/git/gitignore" "/Users/ivuorinen/.config/git/gitignore"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/config/wtf/config.yml" "/Users/ivuorinen/.config/wtf/config.yml"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/git_profiles" "/Users/ivuorinen/.git_profiles"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/huskyrc" "/Users/ivuorinen/.huskyrc"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/dotfiles" "/Users/ivuorinen/.local/bin/dotfiles"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/x-check-git-attributes" "/Users/ivuorinen/.local/bin/x-check-git-attributes"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/x-open-ports" "/Users/ivuorinen/.local/bin/x-open-ports"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/rcrc" "/Users/ivuorinen/.rcrc"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/ssh/allowed_signers" "/Users/ivuorinen/.ssh/allowed_signers"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/ssh/config" "/Users/ivuorinen/.ssh/config"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/vuerc" "/Users/ivuorinen/.vuerc"
|
||||
handle_file_ln "/Users/ivuorinen/.dotfiles/zshrc" "/Users/ivuorinen/.zshrc"
|
||||
33
local/bin/README.md
Normal file
33
local/bin/README.md
Normal file
@@ -0,0 +1,33 @@
|
||||
# Scripts
|
||||
|
||||
All scripts have been normalized to same code standard using `shfmt`.
|
||||
Some problematic code has been fixed per `shellcheck` suggestions.
|
||||
|
||||
## Homegrown
|
||||
|
||||
- dfm
|
||||
- x-backup-mysql-with-prefix
|
||||
- x-check-git-attributes
|
||||
- x-open-ports
|
||||
|
||||
## Sourced
|
||||
|
||||
| Script | Source |
|
||||
|-------------------------|-------------------|
|
||||
| `x-dupes` | skx/sysadmin-util |
|
||||
| `x-foreach` | mvdan/dotfiles |
|
||||
| `x-multi-ping` | skx/sysadmin-util |
|
||||
| `x-ssl-expiry-date` | skx/sysadmin-util |
|
||||
| `x-until-error` | skx/sysadmin-util |
|
||||
| `x-until-success` | skx/sysadmin-util |
|
||||
| `x-validate-sha256-sum` | onnimonni |
|
||||
| `x-when-down` | skx/sysadmin-util |
|
||||
| `x-when-up` | skx/sysadmin-util |
|
||||
|
||||
- Sources:
|
||||
- [skx/sysadmin-utils](https://github.com/skx/sysadmin-util/)
|
||||
- Tools for Linux/Unix sysadmins.
|
||||
- [Licence](https://github.com/skx/sysadmin-util/blob/master/LICENSE)
|
||||
- onnimonni
|
||||
- https://gist.github.com/onnimonni/b49779ebc96216771a6be3de46449fa1
|
||||
- [mvdan/dotfiles](https://github.com/mvdan/dotfiles)
|
||||
@@ -24,7 +24,7 @@ if [[ $ANTIGEN_CACHE != false ]]; then
|
||||
for config in $ANTIGEN_CHECK_FILES; do
|
||||
if [[ "$config" -nt "$config.zwc" ]]; then
|
||||
# Flag configuration file as newer
|
||||
{ zcompile "$config" } &!
|
||||
{ zcompile "$config"; } &!
|
||||
# Kill cache file in order to force full loading (see a few lines below)
|
||||
[[ -f "$ANTIGEN_CACHE" ]] && rm -f "$ANTIGEN_CACHE"
|
||||
fi
|
||||
@@ -151,7 +151,7 @@ antigen () {
|
||||
# String if record is found
|
||||
-antigen-find-record () {
|
||||
local bundle=$1
|
||||
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
@@ -255,7 +255,7 @@ antigen () {
|
||||
return 0
|
||||
}
|
||||
|
||||
# This function check ZSH_EVAL_CONTEXT to determine if running in interactive shell.
|
||||
# This function check ZSH_EVAL_CONTEXT to determine if running in interactive shell.
|
||||
#
|
||||
# Usage
|
||||
# -antigen-interactive-mode
|
||||
@@ -283,7 +283,7 @@ antigen () {
|
||||
# Branch name
|
||||
-antigen-parse-branch () {
|
||||
local url="$1" branch="$2" branches
|
||||
|
||||
|
||||
local match mbegin mend MATCH MBEGIN MEND
|
||||
|
||||
if [[ "$branch" =~ '\*' ]]; then
|
||||
@@ -466,7 +466,7 @@ antigen () {
|
||||
|
||||
# Compatibility with oh-my-zsh themes.
|
||||
-antigen-set-default _ANTIGEN_THEME_COMPAT true
|
||||
|
||||
|
||||
# Add default built-in extensions to load at start up
|
||||
-antigen-set-default _ANTIGEN_BUILTIN_EXTENSIONS 'lock parallel defer cache'
|
||||
|
||||
@@ -555,7 +555,7 @@ antigen () {
|
||||
if [[ $#list == 0 ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Using a for rather than `source $list` as we need to check for zsh-themes
|
||||
# In order to create antigen-compat file. This is only needed for interactive-mode
|
||||
# theme switching, for static loading (cache) there is no need.
|
||||
@@ -643,7 +643,7 @@ antigen () {
|
||||
|
||||
shift
|
||||
done
|
||||
|
||||
|
||||
# Check if url is just the plugin name. Super short syntax.
|
||||
if [[ "${args[url]}" != */* ]]; then
|
||||
case "$ANTIGEN_DEFAULT_REPO_URL" in
|
||||
@@ -728,13 +728,13 @@ antigen () {
|
||||
# if it's local then path is just the "url" argument, loc remains the same
|
||||
args[dir]=${args[url]}
|
||||
fi
|
||||
|
||||
|
||||
# Escape url and branch (may contain semver-like and pipe characters)
|
||||
args[url]="${(qq)args[url]}"
|
||||
if [[ -n "${args[branch]}" ]]; then
|
||||
args[branch]="${(qq)args[branch]}"
|
||||
fi
|
||||
|
||||
|
||||
# Escape bundle name (may contain semver-like characters)
|
||||
args[name]="${(qq)args[name]}"
|
||||
|
||||
@@ -821,7 +821,7 @@ antigen-bundle () {
|
||||
printf "Seems %s is already installed!\n" ${bundle[name]}
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Clone bundle if we haven't done do already.
|
||||
if [[ ! -d "${bundle[dir]}" ]]; then
|
||||
if ! -antigen-bundle-install ${(kv)bundle}; then
|
||||
@@ -835,7 +835,7 @@ antigen-bundle () {
|
||||
printf "Antigen: Failed to load %s.\n" ${bundle[btype]} >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
# Only add it to the record if it could be installed and loaded.
|
||||
_ANTIGEN_BUNDLE_RECORD+=("$record")
|
||||
}
|
||||
@@ -1326,7 +1326,7 @@ antigen-update () {
|
||||
local url=""
|
||||
local make_local_clone=""
|
||||
local start=$(date +'%s')
|
||||
|
||||
|
||||
if [[ $# -eq 0 ]]; then
|
||||
printf "Antigen: Missing argument.\n" >&2
|
||||
return 1
|
||||
@@ -1340,14 +1340,14 @@ antigen-update () {
|
||||
|
||||
url="$(echo "$record" | cut -d' ' -f1)"
|
||||
make_local_clone=$(echo "$record" | cut -d' ' -f4)
|
||||
|
||||
|
||||
local branch="master"
|
||||
if [[ $url == *\|* ]]; then
|
||||
branch="$(-antigen-parse-branch ${url%|*} ${url#*|})"
|
||||
fi
|
||||
|
||||
printf "Updating %s... " $(-antigen-bundle-short-name "$url" "$branch")
|
||||
|
||||
|
||||
if [[ $make_local_clone == "false" ]]; then
|
||||
printf "Bundle has no local clone. Will not be updated.\n" >&2
|
||||
return 1
|
||||
@@ -1358,7 +1358,7 @@ antigen-update () {
|
||||
printf "Error! Activate logging and try again.\n" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
local took=$(( $(date +'%s') - $start ))
|
||||
printf "Done. Took %ds.\n" $took
|
||||
}
|
||||
@@ -1410,7 +1410,7 @@ typeset -g _ANTIGEN_EXTENSIONS; _ANTIGEN_EXTENSIONS=()
|
||||
# -antigen-add-hook antigen-apply antigen-apply-hook ["replace"|"pre"|"post"] ["once"|"repeat"]
|
||||
antigen-add-hook () {
|
||||
local target="$1" hook="$2" type="$3" mode="${4:-repeat}"
|
||||
|
||||
|
||||
if (( ! $+functions[$target] )); then
|
||||
printf "Antigen: Function %s doesn't exist.\n" $target
|
||||
return 1
|
||||
@@ -1428,7 +1428,7 @@ antigen-add-hook () {
|
||||
fi
|
||||
|
||||
_ANTIGEN_HOOKS_META[$hook]="target $target type $type mode $mode called 0"
|
||||
|
||||
|
||||
# Do shadow for this function if there is none already
|
||||
local hook_function="${_ANTIGEN_HOOK_PREFIX}$target"
|
||||
if (( ! $+functions[$hook_function] )); then
|
||||
@@ -1441,7 +1441,7 @@ antigen-add-hook () {
|
||||
return \$?
|
||||
}"
|
||||
fi
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -1454,7 +1454,7 @@ antigen-add-hook () {
|
||||
|
||||
typeset -a pre_hooks replace_hooks post_hooks;
|
||||
typeset -a hooks; hooks=(${(s|:|)_ANTIGEN_HOOKS[$target]})
|
||||
|
||||
|
||||
typeset -A meta;
|
||||
for hook in $hooks; do
|
||||
meta=(${(s: :)_ANTIGEN_HOOKS_META[$hook]})
|
||||
@@ -1500,7 +1500,7 @@ antigen-add-hook () {
|
||||
[[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
if [[ $replace_hook == 0 ]]; then
|
||||
WARN "${_ANTIGEN_HOOK_PREFIX}$target $args"
|
||||
noglob ${_ANTIGEN_HOOK_PREFIX}$target $args
|
||||
@@ -1514,7 +1514,7 @@ antigen-add-hook () {
|
||||
noglob $hook $args
|
||||
[[ $? == -1 ]] && WARN "$hook shortcircuited" && return $ret
|
||||
done
|
||||
|
||||
|
||||
LOG "Return from hook ${target} with ${ret}"
|
||||
|
||||
return $ret
|
||||
@@ -1533,7 +1533,7 @@ antigen-remove-hook () {
|
||||
hooks[$hooks[(I)$hook]]=()
|
||||
fi
|
||||
_ANTIGEN_HOOKS[${target}]="${(j|:|)hooks}"
|
||||
|
||||
|
||||
if [[ $#hooks == 0 ]]; then
|
||||
# Destroy base hook
|
||||
eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)"
|
||||
@@ -1554,7 +1554,7 @@ antigen-remove-hook () {
|
||||
eval "function $(functions -- ${_ANTIGEN_HOOK_PREFIX}$target | sed s/${_ANTIGEN_HOOK_PREFIX}//)"
|
||||
unfunction -- "${_ANTIGEN_HOOK_PREFIX}$target" 2> /dev/null
|
||||
done
|
||||
|
||||
|
||||
_ANTIGEN_HOOKS=()
|
||||
_ANTIGEN_HOOKS_META=()
|
||||
_ANTIGEN_EXTENSIONS=()
|
||||
@@ -1570,14 +1570,14 @@ antigen-ext () {
|
||||
eval $func
|
||||
local ret=$?
|
||||
WARN "$func return code was $ret"
|
||||
if (( $ret == 0 )); then
|
||||
if (( $ret == 0 )); then
|
||||
LOG "LOADED EXTENSION $ext" EXT
|
||||
-antigen-$ext-execute && _ANTIGEN_EXTENSIONS+=($ext)
|
||||
else
|
||||
WARN "IGNORING EXTENSION $func" EXT
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
else
|
||||
printf "Antigen: No extension defined or already loaded: %s\n" $func >&2
|
||||
return 1
|
||||
@@ -1617,7 +1617,7 @@ antigen-ext-init () {
|
||||
return -1 # Stop right there
|
||||
}
|
||||
antigen-add-hook antigen-bundle antigen-bundle-defer replace
|
||||
|
||||
|
||||
# Hooks antigen-apply in order to release hooked functions
|
||||
antigen-apply-defer () {
|
||||
WARN "Defer pre-apply" DEFER PRE-APPLY
|
||||
@@ -1639,14 +1639,14 @@ antigen-ext-init () {
|
||||
# Default lock path.
|
||||
-antigen-set-default ANTIGEN_LOCK $ADOTDIR/.lock
|
||||
typeset -g _ANTIGEN_LOCK_PROCESS=false
|
||||
|
||||
|
||||
# Use env variable to determine if we should load this extension
|
||||
-antigen-set-default ANTIGEN_MUTEX true
|
||||
# Set ANTIGEN_MUTEX to false to avoid loading this extension
|
||||
if [[ $ANTIGEN_MUTEX == true ]]; then
|
||||
return 0;
|
||||
fi
|
||||
|
||||
|
||||
# Do not use mutex
|
||||
return 1;
|
||||
}
|
||||
@@ -1714,7 +1714,7 @@ antigen-ext-init () {
|
||||
else
|
||||
WARN "Bundle ${bundle[name]} already cloned locally." PARALLEL
|
||||
fi
|
||||
|
||||
|
||||
repositories+=(${bundle[url]})
|
||||
done
|
||||
|
||||
@@ -1734,7 +1734,7 @@ antigen-ext-init () {
|
||||
for bundle in ${_PARALLEL_BUNDLE[@]}; do
|
||||
antigen-bundle $bundle
|
||||
done
|
||||
|
||||
|
||||
|
||||
WARN "Parallel install done" PARALLEL
|
||||
}
|
||||
@@ -1751,7 +1751,7 @@ antigen-ext-init () {
|
||||
antigen-add-hook antigen-bundle antigen-bundle-parallel replace
|
||||
}
|
||||
antigen-add-hook antigen-apply antigen-apply-parallel pre once
|
||||
|
||||
|
||||
antigen-apply-parallel-execute () {
|
||||
WARN "Parallel replace-apply" PARALLEL REPLACE-APPLY
|
||||
antigen-remove-hook antigen-bundle-parallel
|
||||
@@ -1872,14 +1872,14 @@ EOC
|
||||
|
||||
# Cache auto config files to check for changes (.zshrc, .antigenrc etc)
|
||||
-antigen-set-default ANTIGEN_AUTO_CONFIG true
|
||||
|
||||
|
||||
# Default cache path.
|
||||
-antigen-set-default ANTIGEN_CACHE $ADOTDIR/init.zsh
|
||||
-antigen-set-default ANTIGEN_RSRC $ADOTDIR/.resources
|
||||
if [[ $ANTIGEN_CACHE == false ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -1911,21 +1911,21 @@ EOC
|
||||
antigen-remove-hook -antigen-load-source-cached
|
||||
antigen-remove-hook antigen-bundle-cached
|
||||
}
|
||||
|
||||
|
||||
antigen-add-hook antigen-apply antigen-apply-cached post once
|
||||
|
||||
|
||||
# Defer antigen-bundle.
|
||||
antigen-bundle-cached () {
|
||||
_ZCACHE_CAPTURE_BUNDLE+=("${(j: :)${@}}")
|
||||
}
|
||||
antigen-add-hook antigen-bundle antigen-bundle-cached pre
|
||||
|
||||
|
||||
# Defer loading.
|
||||
-antigen-load-env-cached () {
|
||||
local bundle
|
||||
typeset -A bundle; bundle=($@)
|
||||
local location=${bundle[dir]}/${bundle[loc]}
|
||||
|
||||
|
||||
# Load to path if there is no sourceable
|
||||
if [[ ${bundle[loc]} == "/" ]]; then
|
||||
_ZCACHE_BUNDLE_SOURCE+=("${location}")
|
||||
@@ -1935,13 +1935,13 @@ EOC
|
||||
_ZCACHE_BUNDLE_SOURCE+=("${location}")
|
||||
}
|
||||
antigen-add-hook -antigen-load-env -antigen-load-env-cached replace
|
||||
|
||||
|
||||
# Defer sourcing.
|
||||
-antigen-load-source-cached () {
|
||||
_ZCACHE_BUNDLE_SOURCE+=($@)
|
||||
}
|
||||
antigen-add-hook -antigen-load-source -antigen-load-source-cached replace
|
||||
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
176
local/bin/dfm
Executable file
176
local/bin/dfm
Executable file
@@ -0,0 +1,176 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Dotfiles manager and install helper
|
||||
# (c) Ismo Vuorinen <https://github.com/ivuorinen> 2022
|
||||
# Licensed under MIT, see LICENSE
|
||||
#
|
||||
# shellcheck source-path=$HOME/.dotfiles/local/bin
|
||||
#
|
||||
# Helper variables, override with ENVs like `VERBOSE=1 dfm help`
|
||||
: "${VERBOSE:=0}"
|
||||
: "${DOTFILES:=$HOME/.dotfiles}"
|
||||
: "${INSTALL_SCRIPT:=$DOTFILES/scripts/install-dotfiles.sh}"
|
||||
: "${BREWFILE:=$DOTFILES/Brewfile}"
|
||||
|
||||
SCRIPT=$(basename "$0")
|
||||
|
||||
source "$DOTFILES/scripts/shared.sh"
|
||||
|
||||
function section_install
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT install"
|
||||
|
||||
case "$1" in
|
||||
all)
|
||||
$0 install antigen && msg_done "New antigen installed"
|
||||
$0 install macos && msg_done "macOS Defaults set"
|
||||
$0 install brew && msg_done "Brewfile defined apps has been installed"
|
||||
$0 install ext_gh && msg_done "Extensions for GitHub CLI have been installed"
|
||||
$0 install ext_go && msg_done "Go packages have been installed"
|
||||
;;
|
||||
antigen)
|
||||
curl -L git.io/antigen > "$DOTFILES/local/bin/antigen.zsh" && msg_done "🎉 Done!"
|
||||
;;
|
||||
brew)
|
||||
brew bundle install --file="$BREWFILE" && msg_done "🎉 Done!"
|
||||
;;
|
||||
macos)
|
||||
bash "$DOTFILES/scripts/set-macos-defaults.sh" && msg_done "🎉 Done!"
|
||||
;;
|
||||
ext_go)
|
||||
bash "$DOTFILES/scripts/install-go-packages.sh" && msg_done "🎉 Done!"
|
||||
;;
|
||||
ext_gh)
|
||||
bash "$DOTFILES/scripts/install-gh-extensions.sh" && msg_done "🎉 Done!"
|
||||
;;
|
||||
settler)
|
||||
bash "$DOTFILES/scripts/settler.sh" && msg_done "🎉 Done!"
|
||||
;;
|
||||
*)
|
||||
menu_section "$USAGE_PREFIX" "all | antigen | brew | macos | ext_go | ext_gh | settler"
|
||||
menu_item "all" "Installs antigen, macos, brew, ext_gh and ext_go"
|
||||
menu_item "antigen" "Updates the antigen.zsh file"
|
||||
menu_item "brew" "Install Brewfile contents"
|
||||
menu_item "ext_gh" "Install GitHub CLI Extensions"
|
||||
menu_item "ext_go" "Install Go Packages"
|
||||
menu_item "macos" "Setup nice macOS defaults"
|
||||
menu_item "settler" "Runs the WIP settler.sh"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function section_brew
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT brew"
|
||||
|
||||
if ! command -v brew &> /dev/null; then
|
||||
echo "brew could not be found, please install it first"
|
||||
exit
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
install)
|
||||
brew bundle install --file="$BREWFILE" && msg_done "🎉 Done!"
|
||||
;;
|
||||
update)
|
||||
brew update && brew outdated && brew upgrade && brew cleanup
|
||||
msg_done "🎉 Done!"
|
||||
;;
|
||||
updatebundle)
|
||||
# Updates .dotfiles/Brewfile with descriptions
|
||||
brew bundle dump \
|
||||
--force \
|
||||
--file="$BREWFILE" \
|
||||
--describe && msg_done "🎉 Done!"
|
||||
;;
|
||||
autoupdate)
|
||||
brew autoupdate delete
|
||||
brew autoupdate start 43200 --upgrade --cleanup --immediate
|
||||
;;
|
||||
*)
|
||||
menu_section "$USAGE_PREFIX" "install | update | updatebundle | autoupdate"
|
||||
menu_item "install" "Installs items defined in Brewfile"
|
||||
menu_item "update" "Updates and upgrades brew packages"
|
||||
menu_item "updatebundle" "Updates Brewfile with descriptions"
|
||||
menu_item "autoupdate" "Setups brew auto-update and runs it immediately"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function section_dotfiles
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT dotfiles"
|
||||
|
||||
case "$1" in
|
||||
link)
|
||||
rcup -B "$HOSTNAME" -f -v && msg_done "🎉 Done!"
|
||||
;;
|
||||
update)
|
||||
# Updates .dotfiles/scripts/install.sh and formats it
|
||||
rcup -B 0 -g \
|
||||
| tee "$INSTALL_SCRIPT" 1> /dev/null \
|
||||
&& sed -i '' "s|$HOME|\$HOME|g" "$INSTALL_SCRIPT" \
|
||||
&& sed -i '' "s|install.sh|$(basename "$INSTALL_SCRIPT")|g" "$INSTALL_SCRIPT"
|
||||
$0 dotfiles shfmt
|
||||
msg_done "🎉 Done!"
|
||||
;;
|
||||
shfmt)
|
||||
# Format shell scripts according to following rules.
|
||||
shfmt -fn -l -w -i 2 -ci -sr -bn "$DOTFILES"
|
||||
;;
|
||||
*)
|
||||
menu_section "$USAGE_PREFIX" "link | update | shfmt"
|
||||
menu_item "link" "Use rcrc to update dotfile links"
|
||||
menu_item "update" "Updates dotfile links, installs host specific overrides automatically"
|
||||
menu_item "shfmt" "Run shfmt to all dotfiles"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Secret menu for visual tests
|
||||
function section_tests
|
||||
{
|
||||
USAGE_PREFIX="$SCRIPT tests"
|
||||
|
||||
case "$1" in
|
||||
msg)
|
||||
msg "msg"
|
||||
msg_done "msg_done"
|
||||
msg_prompt "msg_prompt"
|
||||
msg_prompt_done "msg_prompt_done"
|
||||
msg_nested "msg_nested"
|
||||
msg_nested_done "msg_nested_done"
|
||||
msg_run "msg_run" "second_param"
|
||||
msg_ok "msg_ok"
|
||||
msg_warn "msg_warn"
|
||||
msg_err "msg_err"
|
||||
;;
|
||||
*)
|
||||
menu_section "$USAGE_PREFIX" "msg"
|
||||
menu_item "msg" "List all log functions from shared.sh"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function usage
|
||||
{
|
||||
echo ""
|
||||
menu_section "Usage: $SCRIPT" "install | brew | dotfiles"
|
||||
echo $" All commands have their own subcommands."
|
||||
echo ""
|
||||
section_install
|
||||
echo ""
|
||||
section_brew
|
||||
echo ""
|
||||
section_dotfiles
|
||||
}
|
||||
|
||||
# The main loop. first keyword after $0 triggers section, or help.
|
||||
case "$1" in
|
||||
install) section_install "$2" ;;
|
||||
brew) section_brew "$2" ;;
|
||||
dotfiles) section_dotfiles "$2" ;;
|
||||
tests) section_tests "$2" ;;
|
||||
*) usage && exit 1 ;;
|
||||
esac
|
||||
|
||||
@@ -1,104 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Dotfiles and install helper
|
||||
# (c) Ismo Vuorinen <https://github.com/ivuorinen> 2022
|
||||
# Licensed under MIT, see LICENSE
|
||||
#
|
||||
|
||||
# Helper variables, override with ENVs like `VERBOSE=1 helpers.sh help`
|
||||
: "${VERBOSE:=0}"
|
||||
: "${DOTFILES:=$HOME/.dotfiles}"
|
||||
: "${INSTALL_SCRIPT:=$DOTFILES/install.sh}"
|
||||
: "${BREWFILE:=$DOTFILES/Brewfile}"
|
||||
|
||||
function usage() {
|
||||
echo $"Usage: $0 [install | brew | dotfiles | other]"
|
||||
echo $" All commands have their own subcommands."
|
||||
echo $" When in doubt run the subcommand to show list."
|
||||
}
|
||||
|
||||
function section_install() {
|
||||
USAGE_PREFIX="Usage: $0 install"
|
||||
|
||||
case "$1" in
|
||||
*)
|
||||
echo "$USAGE_PREFIX [link | update]"
|
||||
echo " * link: Use rcrc to update dotfile links"
|
||||
echo " * update: Updates and upgrades brew packages"
|
||||
echo " * updatebundle: Updates Brewfile with descriptions"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function section_brew() {
|
||||
USAGE_PREFIX="Usage: $0 brew"
|
||||
|
||||
if ! command -v brew &> /dev/null; then
|
||||
echo "brew could not be found, please install it first"
|
||||
exit
|
||||
fi
|
||||
|
||||
case "$1" in
|
||||
install)
|
||||
brew bundle install --file="$BREWFILE"; echo "🎉 Done!"
|
||||
;;
|
||||
update)
|
||||
brew update && brew upgrade; echo "🎉 Done!"
|
||||
;;
|
||||
updatebundle)
|
||||
# Updates .dotfiles/Brewfile with descriptions
|
||||
brew bundle dump --force --file="$BREWFILE" --describe
|
||||
echo "🎉 Done!"
|
||||
;;
|
||||
autoupdate)
|
||||
brew autoupdate start 43200 --upgrade --cleanup --immediate
|
||||
;;
|
||||
*)
|
||||
echo "$USAGE_PREFIX [install | update | updatebundle]"
|
||||
echo " * install: Installs items defined in Brewfile"
|
||||
echo " * update: Updates and upgrades brew packages"
|
||||
echo " * updatebundle: Updates Brewfile with descriptions"
|
||||
echo " * autoupdate: Setups brew auto-update and runs it immediately"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function section_dotfiles() {
|
||||
USAGE_PREFIX="Usage: $0 dotfiles"
|
||||
|
||||
case "$1" in
|
||||
link)
|
||||
rcup -B "$HOSTNAME" -v && echo "🎉 Done!"
|
||||
;;
|
||||
update)
|
||||
# Updates .dotfiles/install.sh and formats it
|
||||
rcup -B 0 -g | \
|
||||
tee "$INSTALL_SCRIPT" 1> /dev/null && \
|
||||
shfmt -w -l "$INSTALL_SCRIPT" && \
|
||||
echo "🎉 Done!"
|
||||
;;
|
||||
*)
|
||||
echo "$USAGE_PREFIX [link | update]"
|
||||
echo " * link: Use rcrc to update dotfile links"
|
||||
echo " * update: Updates dotfile links, installs host specific overrides automatically"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
function section_other() {
|
||||
case "$1" in
|
||||
*)
|
||||
echo "section_other"
|
||||
echo "$1"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# The main loop. first keyword after $0 triggers section, or help.
|
||||
case "$1" in
|
||||
install) section_install "$2" ;;
|
||||
brew) section_brew "$2" ;;
|
||||
dotfiles) section_dotfiles "$2" ;;
|
||||
other) section_other "$2" ;;
|
||||
*) usage; exit 1 ;;
|
||||
esac
|
||||
43
local/bin/x-backup-mysql-with-prefix.sh
Executable file
43
local/bin/x-backup-mysql-with-prefix.sh
Executable file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Backup local MySQL Database tables with certain prefix.
|
||||
# Ismo Vuorinen <https://github.com/ivuorinen> 2018
|
||||
#
|
||||
|
||||
SCRIPT=$(basename "$0")
|
||||
PREFIX=$1
|
||||
FILENAME=$2
|
||||
DATABASE=$3
|
||||
|
||||
: "${VERBOSE:=0}"
|
||||
: "${DEFAULT_DATABASE:="wordpress"}"
|
||||
|
||||
if [ -z "${PREFIX}" ]; then
|
||||
echo "(!) TABLE_PREFIX (first argument) is missing"
|
||||
echo "(>) Usage: $SCRIPT <TABLE_PREFIX> <FILENAME_PREFIX> [<DATABASE>]"
|
||||
echo " * <TABLE_PREFIX> = database table prefix, e.g. 'wp_'"
|
||||
echo " * <FILENAME_PREFIX> = FILENAME prefix, defaults to table prefix. Use something descriptive e.g. 'wordpress'"
|
||||
echo " * <DATABASE> = [optional] Third argument DATABASE, defaults to '$DEFAULT_DATABASE'."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "${FILENAME}" ]; then
|
||||
# echo "FILENAME (second argument) is missing, using PREFIX ($PREFIX)"
|
||||
FILENAME=$PREFIX
|
||||
fi
|
||||
|
||||
if [ -z "${DATABASE}" ]; then
|
||||
# echo "DATABASE (third argument) is missing, using default ($DEFAULT_DATABASE)"
|
||||
DATABASE=$DEFAULT_DATABASE
|
||||
fi
|
||||
|
||||
TIMESTAMP=$(date "+%Y%m%d_%H%M%S")
|
||||
FILENAME_TIMESTAMP="${DATABASE}_${FILENAME}_${TIMESTAMP}.sql"
|
||||
|
||||
mysqldump \
|
||||
${DATABASE} \
|
||||
"$(
|
||||
echo "show tables like '${PREFIX}%';" \
|
||||
| mysql ${DATABASE} \
|
||||
| sed '/Tables_in/d'
|
||||
)" > "${FILENAME_TIMESTAMP}"
|
||||
@@ -1,6 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Check git repo's files .gitattributes and are all of them mapped.
|
||||
# Ismo Vuorinen <https://github.com/ivuorinen> 2022
|
||||
#
|
||||
|
||||
if ! command -v git &> /dev/null; then
|
||||
echo "git could not be found, please install it first"
|
||||
exit
|
||||
fi
|
||||
|
||||
missing_attributes=$(git ls-files | git check-attr -a --stdin | grep "text: auto")
|
||||
|
||||
if [[ "$missing_attributes" ]]; then
|
||||
echo ".gitattributes rule missing for the following files:"
|
||||
echo "$missing_attributes"
|
||||
|
||||
208
local/bin/x-dupes
Executable file
208
local/bin/x-dupes
Executable file
@@ -0,0 +1,208 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
=head1 NAME
|
||||
|
||||
dupes - Report on files with duplicate contents, via SHA1 hash.
|
||||
|
||||
=cut
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
dupes [options] directory
|
||||
|
||||
General Options:
|
||||
|
||||
--help Show the help information for this script.
|
||||
--verbose Show useful debugging information.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
=head1 ABOUT
|
||||
|
||||
dupes is a simple script to report upon files that are identical,
|
||||
recursively.
|
||||
|
||||
The process involves calculating the SHA1 hash of the file contents
|
||||
and reporting on anything collisions we see.
|
||||
|
||||
Note that a collision might be caused by a symbolic link, or hardlink,
|
||||
so blindly deleting duplicates without investigation is almost certainly
|
||||
a mistake.
|
||||
|
||||
=cut
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Steve
|
||||
--
|
||||
http://www.steve.org.uk/
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Copyright (c) 2013 by Steve Kemp. All rights reserved.
|
||||
|
||||
This script is free software;you can redistribute it and/or modify it under
|
||||
the same terms as Perl itself.
|
||||
|
||||
The LICENSE file contains the full text of the license.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Find;
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
|
||||
|
||||
#
|
||||
# Parse the arguments
|
||||
#
|
||||
my %config = parsedOptions();
|
||||
|
||||
|
||||
#
|
||||
# The path to examine.
|
||||
#
|
||||
my $path = $ARGV[0] || '.';
|
||||
|
||||
|
||||
#
|
||||
# Get the hashing object, dynamically.
|
||||
#
|
||||
my $ctx = getHashObject();
|
||||
my %digest;
|
||||
|
||||
|
||||
#
|
||||
# Find files and store the hash of their contents.
|
||||
#
|
||||
find( {
|
||||
'wanted' => sub {
|
||||
if ( -f $_ )
|
||||
{
|
||||
lstat;
|
||||
if ( ( -r _ ) && ( !-l _ ) )
|
||||
{
|
||||
$ctx->reset;
|
||||
$ctx->addfile($_);
|
||||
my $md5 = $ctx->hexdigest;
|
||||
if ( exists $digest{ $md5 } )
|
||||
{
|
||||
push @{ $digest{ $md5 }->{ 'dupes' } }, $_;
|
||||
}
|
||||
else
|
||||
{
|
||||
$digest{ $md5 } = { 'file' => $_,
|
||||
'dupes' => [] };
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$config{ 'verbose' } && print "Entering $_\n";
|
||||
}
|
||||
},
|
||||
'no_chdir' => 1
|
||||
},
|
||||
$path
|
||||
);
|
||||
|
||||
|
||||
#
|
||||
# Report upon collisions.
|
||||
#
|
||||
foreach my $hash ( keys %digest )
|
||||
{
|
||||
my $dupes = $digest{ $hash }->{ 'dupes' };
|
||||
my $src = $digest{ $hash }->{ 'file' };
|
||||
|
||||
if (@$dupes)
|
||||
{
|
||||
print $src . "\n";
|
||||
foreach my $dupe (@$dupes)
|
||||
{
|
||||
print "\t$dupe\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# All done.
|
||||
#
|
||||
exit(0);
|
||||
|
||||
|
||||
=begin doc
|
||||
|
||||
Load one of M<Digest::SHA> and M<Digest::SHA1>, depending on what is available.
|
||||
|
||||
=end doc
|
||||
|
||||
=cut
|
||||
|
||||
sub getHashObject
|
||||
{
|
||||
my $hash = undef;
|
||||
|
||||
foreach my $module (qw! Digest::SHA Digest::SHA1 !)
|
||||
{
|
||||
|
||||
# If we succeeded in calculating the hash we're done.
|
||||
next if ( defined($hash) );
|
||||
|
||||
# Attempt to load the module
|
||||
my $eval = "use $module;";
|
||||
|
||||
## no critic (Eval)
|
||||
eval($eval);
|
||||
## use critic
|
||||
|
||||
if ( !$@ )
|
||||
{
|
||||
$hash = $module->new;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ($hash)
|
||||
{
|
||||
return ($hash);
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Failed to load either DIgest::SHA or Digest::SHA1\n";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
=begin doc
|
||||
|
||||
Parse the options and return suitable values.
|
||||
|
||||
=end doc
|
||||
|
||||
=cut
|
||||
|
||||
sub parsedOptions
|
||||
{
|
||||
my %vars;
|
||||
|
||||
exit
|
||||
if (
|
||||
!GetOptions( "help" => \$vars{ 'help' },
|
||||
"verbose" => \$vars{ 'verbose' } ) );
|
||||
|
||||
pod2usage(1) if ( $vars{ 'help' } );
|
||||
|
||||
return (%vars);
|
||||
|
||||
}
|
||||
16
local/bin/x-foreach
Executable file
16
local/bin/x-foreach
Executable file
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# foreach <folder> <commands that should be run to each file>
|
||||
#
|
||||
# Source: https://github.com/mvdan/dotfiles/blob/master/.bin/foreach
|
||||
|
||||
cmd=$1
|
||||
shift
|
||||
|
||||
for dir in $($cmd); do
|
||||
(
|
||||
echo "$dir"
|
||||
cd "$dir" || exit 1
|
||||
eval "$@" # allow multiple commands like "foo && bar"
|
||||
)
|
||||
done
|
||||
228
local/bin/x-multi-ping
Executable file
228
local/bin/x-multi-ping
Executable file
@@ -0,0 +1,228 @@
|
||||
#!/usr/bin/env perl
|
||||
|
||||
=head1 NAME
|
||||
|
||||
multi-ping - Multi-protocol ping wrapper
|
||||
|
||||
=head1 SYNOPSIS
|
||||
|
||||
multi-ping [--loop|--forever] [--sleep=N] hostname1 hostname2 .. hostnameN
|
||||
|
||||
=cut
|
||||
|
||||
=head1 DESCRIPTION
|
||||
|
||||
This wrapper script will invoke one of 'ping' or 'ping6', as appropriate,
|
||||
to test the connectivity of a remote host and your route to it.
|
||||
|
||||
=cut
|
||||
|
||||
=head1 AUTHOR
|
||||
|
||||
Steve
|
||||
--
|
||||
http://www.steve.org.uk/
|
||||
|
||||
=cut
|
||||
|
||||
=head1 LICENSE
|
||||
|
||||
Copyright (c) 2013-2014 by Steve Kemp. All rights reserved.
|
||||
|
||||
This script is free software; you can redistribute it and/or modify it under
|
||||
the same terms as Perl itself.
|
||||
|
||||
The LICENSE file contains the full text of the license.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use Getopt::Long;
|
||||
use Pod::Usage;
|
||||
|
||||
|
||||
#
|
||||
# Check the dependencies.
|
||||
#
|
||||
checkSystem();
|
||||
|
||||
#
|
||||
# Parse the command-line.
|
||||
#
|
||||
my %config = parsedOptions();
|
||||
|
||||
|
||||
#
|
||||
# We could parse arguments here, for the moment we will hard-wire
|
||||
# a timeout of five seconds.
|
||||
#
|
||||
my $timeout = 5;
|
||||
|
||||
|
||||
#
|
||||
# If we didn't get any arguments then we should complain.
|
||||
#
|
||||
if ( scalar @ARGV < 1 )
|
||||
{
|
||||
print "Usage: multi-ping hostname1 hostname2 .. hostnameN\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
#
|
||||
# Process each hostname specified upon the command-line.
|
||||
#
|
||||
# Looping if applicable.
|
||||
#
|
||||
do
|
||||
{
|
||||
foreach my $host (@ARGV)
|
||||
{
|
||||
pingHost($host);
|
||||
}
|
||||
|
||||
sleep( $config{ 'sleep' } );
|
||||
|
||||
} until ( !$config{ 'loop' } );
|
||||
|
||||
|
||||
|
||||
|
||||
=begin doc
|
||||
|
||||
Given a hostname lookup both the AAAA & A records. For each result
|
||||
perform the appropriate ping request.
|
||||
|
||||
=end doc
|
||||
|
||||
=cut
|
||||
|
||||
sub pingHost
|
||||
{
|
||||
my ($hostname) = (@_);
|
||||
|
||||
#
|
||||
# If we've been given an URI then we'll remove the leading-scheme
|
||||
# and use the hostname only.
|
||||
#
|
||||
if ( $hostname =~ m!^([a-z]+:\/\/)([^/]+)/?!i )
|
||||
{
|
||||
$hostname = $2;
|
||||
|
||||
#
|
||||
# Port might be specified too, drop that if present.
|
||||
#
|
||||
if ( $hostname =~ /^(.*):([0-9]+)$/ )
|
||||
{
|
||||
$hostname = $1;
|
||||
}
|
||||
}
|
||||
|
||||
#
|
||||
# Lookup the IP for the name specified
|
||||
#
|
||||
my $res = Net::DNS::Resolver->new;
|
||||
|
||||
#
|
||||
# The two types we'll lookup.
|
||||
#
|
||||
# NOTE: This shouldn't be required but my laptop resolver seems to
|
||||
# struggle with lookups of the type "ANY". Sigh.
|
||||
#
|
||||
#
|
||||
foreach my $type (qw! A AAAA !)
|
||||
{
|
||||
my $query = $res->query( $hostname, $type );
|
||||
|
||||
if ($query)
|
||||
{
|
||||
foreach my $rr ( $query->answer )
|
||||
{
|
||||
my $ping_binary =
|
||||
$rr->type eq "A" ? "ping" :
|
||||
$rr->type eq "AAAA" ? "ping6" :
|
||||
"";
|
||||
if ($ping_binary)
|
||||
{
|
||||
my $result = system(
|
||||
"$ping_binary -c1 -w$timeout -W$timeout $hostname >/dev/null 2>/dev/null"
|
||||
);
|
||||
|
||||
print "Host $hostname - " . $rr->address() .
|
||||
( ( $result == 0 ) ? " - alive" : " - FAILED" ) . "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
print "WARNING: Failed to resolve $hostname [$type]\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
=begin doc
|
||||
|
||||
Test that we have the required perl dependencies present.
|
||||
|
||||
=end doc
|
||||
|
||||
=cut
|
||||
|
||||
sub checkSystem
|
||||
{
|
||||
my $eval = "use Net::DNS;";
|
||||
|
||||
## no critic (Eval)
|
||||
eval($eval);
|
||||
## use critic
|
||||
|
||||
#
|
||||
# If we don't have Net::DNS we're out of luck.
|
||||
#
|
||||
if ($@)
|
||||
{
|
||||
print "The required Net::DNS module is missing. Aborting.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
=begin doc
|
||||
|
||||
Parse the options and return suitable values.
|
||||
|
||||
=end doc
|
||||
|
||||
=cut
|
||||
|
||||
sub parsedOptions
|
||||
{
|
||||
my %vars;
|
||||
|
||||
#
|
||||
# Defaults
|
||||
#
|
||||
$vars{ 'loop' } = 0;
|
||||
$vars{ 'sleep' } = 1;
|
||||
|
||||
exit
|
||||
if (
|
||||
!GetOptions( "help" => \$vars{ 'help' },
|
||||
"verbose" => \$vars{ 'verbose' },
|
||||
"forever" => \$vars{ 'loop' },
|
||||
"loop" => \$vars{ 'loop' },
|
||||
"sleep=i" => \$vars{ 'sleep' },
|
||||
) );
|
||||
|
||||
pod2usage(1) if ( $vars{ 'help' } );
|
||||
|
||||
return (%vars);
|
||||
|
||||
}
|
||||
@@ -6,15 +6,15 @@
|
||||
# Originally from: https://www.commandlinefu.com/commands/view/8951
|
||||
# Original author: https://www.commandlinefu.com/commands/by/wickedcpj
|
||||
#
|
||||
echo 'User: Command: Port:';
|
||||
echo '=====================================================';
|
||||
echo 'User: Command: PID: Port:'
|
||||
echo '========================================================='
|
||||
|
||||
lsof -i 4 -P -n +c 0 | \
|
||||
grep -i 'listen' | \
|
||||
awk '{print $3, $1, $9}' | \
|
||||
sed 's/ [a-z0-9\.\*]*:/ /' | \
|
||||
sort -k 3 -n | \
|
||||
xargs printf '%-20s %-25s %-5s\n' | uniq
|
||||
|
||||
echo "";
|
||||
lsof -i 4 -P -n +c 0 \
|
||||
| grep -i 'listen' \
|
||||
| awk '{print $3, $1, $2, $9}' \
|
||||
| sed 's/ [a-z0-9\.\*]*:/ /' \
|
||||
| sort -k 3 -n \
|
||||
| xargs printf '%-15s %-25s %-8s %-5s\n' \
|
||||
| uniq
|
||||
|
||||
echo ""
|
||||
|
||||
134
local/bin/x-ssl-expiry-date
Executable file
134
local/bin/x-ssl-expiry-date
Executable file
@@ -0,0 +1,134 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# About
|
||||
# -----
|
||||
# Check the expiry date of the SSL certificate on the given host.
|
||||
#
|
||||
#
|
||||
# License
|
||||
# -------
|
||||
#
|
||||
# Copyright (c) 2013-2015 by Steve Kemp. All rights reserved.
|
||||
#
|
||||
# This script is free software; you can redistribute it and/or modify it under
|
||||
# the same terms as Perl itself.
|
||||
#
|
||||
# The LICENSE file contains the full text of the license.
|
||||
#
|
||||
#
|
||||
|
||||
#
|
||||
# Simple function to show usage information, and exit.
|
||||
#
|
||||
usage()
|
||||
{
|
||||
echo "Usage: $0 [-d] [-p 443] domain1.org domain2.com .. domainN"
|
||||
exit 0
|
||||
}
|
||||
|
||||
#
|
||||
# Default settings for flags set by the command-line arguments
|
||||
#
|
||||
days=0
|
||||
port=443
|
||||
|
||||
#
|
||||
# Parse the argument(s) - i.e. look for "-d" / "-p 443".
|
||||
#
|
||||
while getopts "h?dp:" opt; do
|
||||
case $opt in
|
||||
h)
|
||||
usage
|
||||
;;
|
||||
\?)
|
||||
usage
|
||||
;;
|
||||
d)
|
||||
days=1
|
||||
;;
|
||||
p)
|
||||
port=$OPTARG
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
#
|
||||
# Ensure we have some arguments
|
||||
#
|
||||
if [ "$#" = "0" ]; then
|
||||
usage
|
||||
fi
|
||||
|
||||
#
|
||||
# For each domain-name on the command-line.
|
||||
#
|
||||
for name in "$@"; do
|
||||
|
||||
#
|
||||
# Make a temporary file
|
||||
#
|
||||
# Test if we have BSD or GNU version of mktemp
|
||||
if (strings "$(which mktemp)" | grep -q GNU); then
|
||||
# We have the GNU version
|
||||
tmp=$(mktemp)
|
||||
else
|
||||
# We have the BSD version
|
||||
tmp=$(mktemp -t tmp)
|
||||
fi
|
||||
|
||||
#
|
||||
# Download the certificate
|
||||
#
|
||||
if (! echo "" | openssl s_client -connect $name:$port > $tmp 2> /dev/null); then
|
||||
echo "Failed to get cert from https://$name:$port/"
|
||||
exit 3
|
||||
fi
|
||||
|
||||
#
|
||||
# Get the expiry date
|
||||
#
|
||||
date=$(openssl x509 -in "$tmp" -noout -enddate | awk -F= '{print $2}')
|
||||
|
||||
#
|
||||
# Remove the temporary file
|
||||
#
|
||||
rm -f "$tmp"
|
||||
|
||||
#
|
||||
# Convert the expiry date + todays date to seconds-past epoch
|
||||
#
|
||||
# Check if we have the BSD or the GNU version of date
|
||||
if (strings "$(which date)" | grep -q GNU); then
|
||||
# We have GNU this is easy
|
||||
then=$(date --date "$date" +%s)
|
||||
else
|
||||
# We have BSD now it is getting complicated
|
||||
year=$(echo "$date" | awk '{print $4}')
|
||||
month=$(echo "$date" | awk '{print $1}')
|
||||
day=$(echo "$date" | awk '{print $2}')
|
||||
hour=$(echo "$date" | awk '{print $3}' | awk -F: '{print $1}')
|
||||
minute=$(echo "$date" | awk '{print $3}' | awk -F: '{print $2}')
|
||||
second=$(echo "$date" | awk '{print $3}' | awk -F: '{print $3}')
|
||||
then=$(date -v${year}y -v${month} -v${day}d -v${hour}H -v${minute}M -v${second}S -u +%s)
|
||||
fi
|
||||
|
||||
now=$(date +%s)
|
||||
|
||||
#
|
||||
# Day diff
|
||||
#
|
||||
diff=$(("$then" - "$now"))
|
||||
diff=$($diff / 86400)
|
||||
|
||||
#
|
||||
# All done
|
||||
#
|
||||
if [ "$days" = "1" ]; then
|
||||
echo "${name}: ${diff}"
|
||||
else
|
||||
echo "$name"
|
||||
echo " Expires: ${date}"
|
||||
echo " Days: ${diff}"
|
||||
fi
|
||||
done
|
||||
15
local/bin/x-until-error
Executable file
15
local/bin/x-until-error
Executable file
@@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# About
|
||||
# -----
|
||||
# Repeat the command until it fails - always run at least once.
|
||||
#
|
||||
|
||||
"$@"
|
||||
|
||||
#
|
||||
# If the status code was zero then repeat.
|
||||
#
|
||||
while [ $? -eq 0 ]; do
|
||||
"$@"
|
||||
done
|
||||
30
local/bin/x-until-success
Executable file
30
local/bin/x-until-success
Executable file
@@ -0,0 +1,30 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# About
|
||||
# -----
|
||||
# Repeat the command until it succeeds - always run at least once.
|
||||
#
|
||||
#
|
||||
# License
|
||||
# -------
|
||||
#
|
||||
# Copyright (c) 2013 by Steve Kemp. All rights reserved.
|
||||
#
|
||||
# This script is free software; you can redistribute it and/or modify it under
|
||||
# the same terms as Perl itself.
|
||||
#
|
||||
# The LICENSE file contains the full text of the license.
|
||||
#
|
||||
#
|
||||
|
||||
#
|
||||
# Run the first time.
|
||||
#
|
||||
"$@"
|
||||
|
||||
#
|
||||
# If the status code was not zero then repeat.
|
||||
#
|
||||
while [ $? -ne 0 ]; do
|
||||
"$@"
|
||||
done
|
||||
52
local/bin/x-validate-sha256sum.sh
Executable file
52
local/bin/x-validate-sha256sum.sh
Executable file
@@ -0,0 +1,52 @@
|
||||
#!/usr/bin/env bash
|
||||
##
|
||||
# This script contains helper for sha256 validating your downloads
|
||||
#
|
||||
# Source: https://gist.github.com/onnimonni/b49779ebc96216771a6be3de46449fa1
|
||||
# Author: Onni Hakala
|
||||
# License: MIT
|
||||
#
|
||||
# Updated by Ismo Vuorinen <https://github.com/ivuorinen> 2022
|
||||
##
|
||||
|
||||
if ! command -v sha256 &> /dev/null; then
|
||||
echo "git could not be found, please install it first"
|
||||
exit
|
||||
fi
|
||||
|
||||
# Stop program and give error message
|
||||
# $1 - error message (string)
|
||||
function error
|
||||
{
|
||||
echo "(!) ERROR: $1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# return sha256sum for file
|
||||
# $1 - filename (string)
|
||||
function get_sha256sum
|
||||
{
|
||||
sha256sum "$1" | head -c 64
|
||||
}
|
||||
|
||||
# Good variable names pls
|
||||
filename=$1
|
||||
file_hash=$2
|
||||
|
||||
# Check input
|
||||
if [ -z "$filename" ]; then
|
||||
error "You need to provide filename in first parameter"
|
||||
fi
|
||||
|
||||
if [ -z "$file_hash" ]; then
|
||||
error "You need to provide sha256sum in second parameter"
|
||||
fi
|
||||
|
||||
# Check if the file is valid
|
||||
if [ ! -f "$filename" ]; then
|
||||
error "File $filename doesn't exist"
|
||||
elif [ "$(get_sha256sum "$filename")" = "$file_hash" ]; then
|
||||
echo "(*) Success: $filename matches provided sha256sum"
|
||||
else
|
||||
error "$filename doesn't match provided sha256sum"
|
||||
fi
|
||||
32
local/bin/x-when-down
Executable file
32
local/bin/x-when-down
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Wait until a given host is down (determined by ping) then execute the
|
||||
# given command
|
||||
#
|
||||
# Usage:
|
||||
# ./when-down HOST COMMAND...
|
||||
#
|
||||
# Example
|
||||
# ./when-down 1.2.3.4 ssh 1.2.3.4
|
||||
#
|
||||
|
||||
#
|
||||
# Ensure we received the correct number of arguments.
|
||||
#
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: $0 HOST COMMAND..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
HOST=$1
|
||||
|
||||
echo "Waiting for $HOST to get down..."
|
||||
|
||||
true
|
||||
while [ $? -ne 1 ]; do
|
||||
ping -c 1 -W 1 $HOST > /dev/null
|
||||
done
|
||||
|
||||
shift
|
||||
|
||||
"$@"
|
||||
45
local/bin/x-when-up
Executable file
45
local/bin/x-when-up
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Wait until a given host is online (determined by ping) then execute the
|
||||
# given command
|
||||
#
|
||||
# Usage:
|
||||
# ./when-up HOST COMMAND...
|
||||
#
|
||||
# Example
|
||||
# ./when-up 1.2.3.4 ssh 1.2.3.4
|
||||
#
|
||||
# Special case:
|
||||
# when using when-up to ssh to a host, this host does not need to be given twice
|
||||
# ./when-up ssh 1.2.3.4
|
||||
#
|
||||
|
||||
#
|
||||
# Ensure we received the correct number of arguments.
|
||||
#
|
||||
if [ $# -lt 2 ]; then
|
||||
echo "Usage: $0 HOST COMMAND..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $1 = "ssh" ]; then
|
||||
HOST=$2
|
||||
else
|
||||
HOST=$1
|
||||
fi
|
||||
|
||||
echo "Waiting for $HOST to come online..."
|
||||
|
||||
ping -c 1 -W 1 $HOST > /dev/null
|
||||
while [ $? -ne 0 ]; do
|
||||
sleep 1
|
||||
ping -c 1 -W 1 $HOST > /dev/null
|
||||
done
|
||||
|
||||
# By the time we reach here the ping-command has completed successfully
|
||||
# so we can launch the command we were given - along with any arguments.
|
||||
if [ $1 != "ssh" ]; then
|
||||
shift
|
||||
fi
|
||||
|
||||
"$@"
|
||||
@@ -1,29 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install GitHub CLI extensions
|
||||
|
||||
# GitHub CLI extension for reviewing Dependabot PRs.
|
||||
gh extension install einride/gh-dependabot
|
||||
# A GitHub CLI extension that provides summary pull request metrics.
|
||||
gh extension install hectcastro/gh-metrics
|
||||
# being an extension to view the overall health of an organization's use of actions
|
||||
gh extension install rsese/gh-actions-status
|
||||
# GitHub CLI extension for label management
|
||||
gh extension install heaths/gh-label
|
||||
# An opinionated GitHub Cli extension for creating
|
||||
# changelogs that adhere to the keep a changelog specification.
|
||||
gh extension install chelnak/gh-changelog
|
||||
# Safely deletes local branches with no upstream and no un-pushed commits
|
||||
gh extension install davidraviv/gh-clean-branches
|
||||
# A beautiful CLI dashboard for GitHub 🚀
|
||||
gh extension install dlvhdr/gh-dash
|
||||
# A github-cli extension script to clone all repositories
|
||||
# in an organization, optionally filtering by topic.
|
||||
gh extension install matt-bartel/gh-clone-org
|
||||
# GitHub CLI extension to generate montage from GitHub user avatars
|
||||
gh extension install andyfeller/gh-montage
|
||||
# Organisation specific extension for gh cli to retrieve different statistics
|
||||
gh extension install VildMedPap/gh-orgstats
|
||||
# GitHub CLI extension for generating a report on repository dependencies.
|
||||
gh extension install andyfeller/gh-dependency-report
|
||||
# gh cli extension to generate account/organization/enterprise reports
|
||||
gh extension install stoe/gh-report
|
||||
101
scripts/install-dotfiles.sh
Normal file
101
scripts/install-dotfiles.sh
Normal file
@@ -0,0 +1,101 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# Usage:
|
||||
#
|
||||
# sh install-dotfiles.sh
|
||||
#
|
||||
# Environment variables: VERBOSE, CP, LN, MKDIR, RM, DIRNAME.
|
||||
#
|
||||
# env VERBOSE=1 sh install-dotfiles.sh
|
||||
#
|
||||
# DO NOT EDIT THIS FILE
|
||||
#
|
||||
# This file is generated by rcm(7) as:
|
||||
#
|
||||
# rcup -B 0 -g
|
||||
#
|
||||
# To update it, re-run the above command.
|
||||
#
|
||||
: ${VERBOSE:=0}
|
||||
: ${CP:=/bin/cp}
|
||||
: ${LN:=/bin/ln}
|
||||
: ${MKDIR:=/bin/mkdir}
|
||||
: ${RM:=/bin/rm}
|
||||
: ${DIRNAME:=/usr/bin/dirname}
|
||||
verbose()
|
||||
{
|
||||
if [ "$VERBOSE" -gt 0 ]; then
|
||||
echo "$@"
|
||||
fi
|
||||
}
|
||||
handle_file_cp()
|
||||
{
|
||||
if [ -e "$2" ]; then
|
||||
printf "%s " "overwrite $2? [yN]"
|
||||
read overwrite
|
||||
case "$overwrite" in
|
||||
y)
|
||||
$RM -rf "$2"
|
||||
;;
|
||||
*)
|
||||
echo "skipping $2"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
verbose "'$1' -> '$2'"
|
||||
$MKDIR -p "$($DIRNAME "$2")"
|
||||
$CP -R "$1" "$2"
|
||||
}
|
||||
handle_file_ln()
|
||||
{
|
||||
if [ -e "$2" ]; then
|
||||
printf "%s " "overwrite $2? [yN]"
|
||||
read overwrite
|
||||
case "$overwrite" in
|
||||
y)
|
||||
$RM -rf "$2"
|
||||
;;
|
||||
*)
|
||||
echo "skipping $2"
|
||||
return
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
verbose "'$1' -> '$2'"
|
||||
$MKDIR -p "$($DIRNAME "$2")"
|
||||
$LN -sf "$1" "$2"
|
||||
}
|
||||
handle_file_ln "$HOME/.dotfiles/bash_profile" "$HOME/.bash_profile"
|
||||
handle_file_ln "$HOME/.dotfiles/bashrc" "$HOME/.bashrc"
|
||||
handle_file_ln "$HOME/.dotfiles/config/alias" "$HOME/.config/alias"
|
||||
handle_file_ln "$HOME/.dotfiles/config/exports" "$HOME/.config/exports"
|
||||
handle_file_ln "$HOME/.dotfiles/config/flipperdevices.com/qFlipper.ini" "$HOME/.config/flipperdevices.com/qFlipper.ini"
|
||||
handle_file_ln "$HOME/.dotfiles/config/functions" "$HOME/.config/functions"
|
||||
handle_file_ln "$HOME/.dotfiles/config/gh/config.yml" "$HOME/.config/gh/config.yml"
|
||||
handle_file_ln "$HOME/.dotfiles/config/git/config" "$HOME/.config/git/config"
|
||||
handle_file_ln "$HOME/.dotfiles/config/git/gitignore" "$HOME/.config/git/gitignore"
|
||||
handle_file_ln "$HOME/.dotfiles/config/nvim/init.lua" "$HOME/.config/nvim/init.lua"
|
||||
handle_file_ln "$HOME/.dotfiles/config/nvim/lua/custom/plugins.lua" "$HOME/.config/nvim/lua/custom/plugins.lua"
|
||||
handle_file_ln "$HOME/.dotfiles/config/nvim/plugin/packer_compiled.lua" "$HOME/.config/nvim/plugin/packer_compiled.lua"
|
||||
handle_file_ln "$HOME/.dotfiles/config/tmux/tmux.conf" "$HOME/.config/tmux/tmux.conf"
|
||||
handle_file_ln "$HOME/.dotfiles/config/wtf/config.yml" "$HOME/.config/wtf/config.yml"
|
||||
handle_file_ln "$HOME/.dotfiles/git_profiles" "$HOME/.git_profiles"
|
||||
handle_file_ln "$HOME/.dotfiles/huskyrc" "$HOME/.huskyrc"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/antigen.zsh" "$HOME/.local/bin/antigen.zsh"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/dfm" "$HOME/.local/bin/dfm"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-check-git-attributes" "$HOME/.local/bin/x-check-git-attributes"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-dupes" "$HOME/.local/bin/x-dupes"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-foreach" "$HOME/.local/bin/x-foreach"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-multi-ping" "$HOME/.local/bin/x-multi-ping"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-open-ports" "$HOME/.local/bin/x-open-ports"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-ssl-expiry-date" "$HOME/.local/bin/x-ssl-expiry-date"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-until-error" "$HOME/.local/bin/x-until-error"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-until-success" "$HOME/.local/bin/x-until-success"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-when-down" "$HOME/.local/bin/x-when-down"
|
||||
handle_file_ln "$HOME/.dotfiles/local/bin/x-when-up" "$HOME/.local/bin/x-when-up"
|
||||
handle_file_ln "$HOME/.dotfiles/rcrc" "$HOME/.rcrc"
|
||||
handle_file_ln "$HOME/.dotfiles/ssh/allowed_signers" "$HOME/.ssh/allowed_signers"
|
||||
handle_file_ln "$HOME/.dotfiles/ssh/config" "$HOME/.ssh/config"
|
||||
handle_file_ln "$HOME/.dotfiles/vuerc" "$HOME/.vuerc"
|
||||
handle_file_ln "$HOME/.dotfiles/zshrc" "$HOME/.zshrc"
|
||||
53
scripts/install-gh-extensions.sh
Executable file
53
scripts/install-gh-extensions.sh
Executable file
@@ -0,0 +1,53 @@
|
||||
#!/usr/bin/env bash
|
||||
# Install GitHub CLI extensions
|
||||
|
||||
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||
|
||||
if ! command -v gh &> /dev/null; then
|
||||
msg_run "gh (GitHub Client) could not be found, please install it first"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extensions=(
|
||||
# GitHub CLI extension for reviewing Dependabot PRs.
|
||||
einride/gh-dependabot
|
||||
# A GitHub CLI extension that provides summary pull request metrics.
|
||||
hectcastro/gh-metrics
|
||||
# being an extension to view the overall health of an organization's use of actions
|
||||
rsese/gh-actions-status
|
||||
# GitHub CLI extension for label management
|
||||
heaths/gh-label
|
||||
# An opinionated GitHub Cli extension for creating
|
||||
# changelogs that adhere to the keep a changelog specification.
|
||||
chelnak/gh-changelog
|
||||
# Safely deletes local branches with no upstream and no un-pushed commits
|
||||
davidraviv/gh-clean-branches
|
||||
# A beautiful CLI dashboard for GitHub 🚀
|
||||
dlvhdr/gh-dash
|
||||
# A github-cli extension script to clone all repositories
|
||||
# in an organization, optionally filtering by topic.
|
||||
matt-bartel/gh-clone-org
|
||||
# GitHub CLI extension to generate montage from GitHub user avatars
|
||||
andyfeller/gh-montage
|
||||
# Organisation specific extension for gh cli to retrieve different statistics
|
||||
VildMedPap/gh-orgstats
|
||||
# GitHub CLI extension for generating a report on repository dependencies.
|
||||
andyfeller/gh-dependency-report
|
||||
# gh cli extension to generate account/organization/enterprise reports
|
||||
stoe/gh-report
|
||||
)
|
||||
|
||||
msg "Starting to install GitHub CLI extensions..."
|
||||
|
||||
for ext in "${extensions[@]}"; do
|
||||
# Trim spaces
|
||||
ext=${ext// /}
|
||||
# Skip comments
|
||||
if [[ ${ext:0:1} == "#" ]]; then continue; fi
|
||||
|
||||
msg_run "Installing $ext"
|
||||
gh extensions install "$ext"
|
||||
echo ""
|
||||
done
|
||||
|
||||
msg_ok "Done"
|
||||
27
scripts/install-go-packages.sh
Normal file
27
scripts/install-go-packages.sh
Normal file
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env zsh
|
||||
# Install Go packages
|
||||
|
||||
source "$HOME/.dotfiles/scripts/shared.sh"
|
||||
|
||||
if ! command -v go &> /dev/null; then
|
||||
msg "go hasn't been installed yet."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
packages=(
|
||||
# sysadmin/scripting utilities, distributed as a single binary
|
||||
github.com/skx/sysbox@latest
|
||||
)
|
||||
|
||||
for pkg in "${packages[@]}"; do
|
||||
# Trim spaces
|
||||
pkg=${pkg// /}
|
||||
# Skip comments
|
||||
if [[ ${pkg:0:1} == "#" ]]; then continue; fi
|
||||
|
||||
msg_run "Installing go package:" "$pkg"
|
||||
go install "$pkg"
|
||||
echo ""
|
||||
done
|
||||
|
||||
msg_ok "Done"
|
||||
@@ -1,11 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
echo 'start osx/set-defaults.sh'
|
||||
#
|
||||
# set-macos-defaults.sh - Sets macOS Defaults that I like
|
||||
#
|
||||
# This script contains large portions from following scripts:
|
||||
# - https://github.com/freekmurze/dotfiles/blob/main/macos/set-defaults.sh
|
||||
#
|
||||
|
||||
# Ask for the administrator password upfront
|
||||
sudo -v
|
||||
|
||||
# Keep-alive: update existing `sudo` time stamp until `.osx` has finished
|
||||
while true; do sudo -n true; sleep 60; kill -0 "$$" || exit; done 2>/dev/null &
|
||||
# Keep-alive: update existing `sudo` time stamp
|
||||
# until this script has finished
|
||||
while true; do
|
||||
sudo -n true
|
||||
sleep 60
|
||||
kill -0 "$$" || exit
|
||||
done 2> /dev/null &
|
||||
|
||||
###############################################################################
|
||||
# General UI/UX #
|
||||
@@ -17,8 +27,8 @@ sudo nvram SystemAudioVolume=" "
|
||||
# Menu bar: disable transparency
|
||||
#defaults write NSGlobalDomain AppleEnableMenuBarTransparency -bool false
|
||||
|
||||
# Set sidebar icon size to medium
|
||||
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 2
|
||||
# Set sidebar icon size to small
|
||||
defaults write NSGlobalDomain NSTableViewDefaultSizeMode -int 1
|
||||
|
||||
# Increase window resize speed for Cocoa applications
|
||||
defaults write NSGlobalDomain NSWindowResizeTime -float 0.001
|
||||
@@ -120,9 +130,9 @@ defaults write com.apple.screensaver askForPasswordDelay -int 0
|
||||
defaults write com.apple.finder NewWindowTarget -string "PfDe"
|
||||
defaults write com.apple.finder NewWindowTargetPath -string "file://${HOME}/Desktop/"
|
||||
|
||||
# Show icons for hard drives, servers, and removable media on the desktop
|
||||
# Show icons for external hard drives, servers, and removable media on the desktop
|
||||
defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true
|
||||
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool true
|
||||
defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false
|
||||
defaults write com.apple.finder ShowMountedServersOnDesktop -bool true
|
||||
defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true
|
||||
|
||||
@@ -151,7 +161,7 @@ defaults write com.apple.frameworks.diskimages skip-verify-remote -bool true
|
||||
|
||||
# Use list view in all Finder windows by default
|
||||
# Four-letter codes for the other view modes: `icnv`, `clmv`, `Flwv`
|
||||
defaults write com.apple.finder FXPreferredViewStyle -string "clmv"
|
||||
defaults write com.apple.finder FXPreferredViewStyle -string "icnv"
|
||||
|
||||
# Disable the warning before emptying the Trash
|
||||
defaults write com.apple.finder WarnOnEmptyTrash -bool false
|
||||
@@ -165,9 +175,9 @@ defaults write com.apple.finder WarnOnEmptyTrash -bool false
|
||||
# Expand the following File Info panes:
|
||||
# “General”, “Open with”, and “Sharing & Permissions”
|
||||
defaults write com.apple.finder FXInfoPanesExpanded -dict \
|
||||
General -bool true \
|
||||
OpenWith -bool true \
|
||||
Privileges -bool true
|
||||
General -bool true \
|
||||
OpenWith -bool true \
|
||||
Privileges -bool true
|
||||
|
||||
###############################################################################
|
||||
# Screenshots #
|
||||
@@ -177,7 +187,7 @@ defaults write com.apple.finder FXInfoPanesExpanded -dict \
|
||||
#defaults write com.apple.screencapture "location" -string "~/Documents/Screenshots"
|
||||
|
||||
# Exclude date and time in screenshot filenames
|
||||
defaults write com.apple.screencapture "include-date" -bool false
|
||||
defaults write com.apple.screencapture "include-date" -bool true
|
||||
|
||||
# Change the default screenshot file name
|
||||
defaults write com.apple.screencapture "name" -string "screenshot"
|
||||
@@ -189,16 +199,16 @@ defaults write com.apple.screencapture "name" -string "screenshot"
|
||||
# Prevent applications from bouncing in Dock
|
||||
defaults write com.apple.dock no-bouncing -bool true
|
||||
|
||||
# Set the icon size of Dock items to 72 pixels
|
||||
defaults write com.apple.dock tilesize -int 72
|
||||
# Set the icon size of Dock items to 30 pixels
|
||||
defaults write com.apple.dock tilesize -int 30
|
||||
|
||||
# Hide indicator lights for open applications in the Dock
|
||||
defaults write com.apple.dock show-process-indicators -bool false
|
||||
defaults write com.apple.dock show-process-indicators -bool true
|
||||
|
||||
# Wipe all (default) app icons from the Dock
|
||||
# This is only really useful when setting up a new Mac, or if you don’t use
|
||||
# the Dock to launch apps.
|
||||
defaults write com.apple.dock persistent-apps -array ""
|
||||
# defaults write com.apple.dock persistent-apps -array ""
|
||||
|
||||
# Disable Dashboard
|
||||
defaults write com.apple.dashboard mcx-disabled -bool true
|
||||
@@ -221,8 +231,11 @@ defaults write com.apple.Safari IncludeInternalDebugMenu -bool true
|
||||
|
||||
# Enable the Develop menu and the Web Inspector in Safari
|
||||
defaults write com.apple.Safari IncludeDevelopMenu -bool true
|
||||
defaults write com.apple.Safari WebKitDeveloperExtrasEnabledPreferenceKey -bool true
|
||||
defaults write com.apple.Safari com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled -bool true
|
||||
defaults write com.apple.Safari \
|
||||
WebKitDeveloperExtrasEnabledPreferenceKey -bool true
|
||||
defaults write com.apple.Safari \
|
||||
com.apple.Safari.ContentPageGroupIdentifier.WebKit2DeveloperExtrasEnabled \
|
||||
-bool true
|
||||
|
||||
# Don’t display the annoying prompt when quitting iTerm
|
||||
#defaults write com.googlecode.iterm2 PromptOnQuit -bool false
|
||||
@@ -263,18 +276,24 @@ defaults write com.apple.TextEdit PlainTextEncodingForWrite -int 4
|
||||
###############################################################################
|
||||
|
||||
# Disable smart quotes as it’s annoying for messages that contain code
|
||||
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "automaticQuoteSubstitutionEnabled" -bool false
|
||||
defaults write com.apple.messageshelper.MessageController \
|
||||
SOInputLineSettings \
|
||||
-dict-add "automaticQuoteSubstitutionEnabled" \
|
||||
-bool false
|
||||
|
||||
# Disable continuous spell checking
|
||||
defaults write com.apple.messageshelper.MessageController SOInputLineSettings -dict-add "continuousSpellCheckingEnabled" -bool false
|
||||
defaults write com.apple.messageshelper.MessageController \
|
||||
SOInputLineSettings \
|
||||
-dict-add "continuousSpellCheckingEnabled" \
|
||||
-bool false
|
||||
|
||||
###############################################################################
|
||||
# Kill affected applications #
|
||||
###############################################################################
|
||||
|
||||
for app in "Activity Monitor" "Address Book" "Calendar" "Contacts" "cfprefsd" \
|
||||
"Dock" "Finder" "Mail" "Messages" "Safari" "SizeUp" "SystemUIServer" \
|
||||
"Terminal" "Transmission" "Twitter" "iCal"; do
|
||||
killall "${app}" > /dev/null 2>&1
|
||||
"Dock" "Finder" "Mail" "Messages" "Safari" "SizeUp" "SystemUIServer" \
|
||||
"Terminal" "Transmission" "Twitter" "iCal"; do
|
||||
killall "${app}" > /dev/null 2>&1
|
||||
done
|
||||
echo "Done. Note that some of these changes require a logout/restart to take effect."
|
||||
61
scripts/settler.sh
Executable file
61
scripts/settler.sh
Executable file
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Settler - my macOS setup automator
|
||||
# Ismo Vuorinen <https://github.com/ivuorinen> 2018
|
||||
#
|
||||
|
||||
# Ask for the administrator password upfront
|
||||
sudo -v
|
||||
|
||||
# Keep-alive: update existing `sudo` time stamp until `settler` has finished
|
||||
while true; do
|
||||
sudo -n true
|
||||
sleep 60
|
||||
kill -0 "$$" || exit
|
||||
done 2> /dev/null &
|
||||
|
||||
# https://unix.stackexchange.com/a/408305
|
||||
# check if user has git installed and propose to install if not installed
|
||||
if [ "$(which git)" ]; then
|
||||
echo "You already have git. Continuing..."
|
||||
else
|
||||
XCODE_MESSAGE="$(
|
||||
osascript -e \
|
||||
'tell app "System Events" to display dialog "Please click install when Command Line Developer Tools appears"'
|
||||
)"
|
||||
|
||||
if [ "$XCODE_MESSAGE" = "button returned:OK" ]; then
|
||||
xcode-select --install
|
||||
else
|
||||
echo "You have cancelled the installation, please rerun the installer."
|
||||
exit
|
||||
fi
|
||||
fi
|
||||
|
||||
until [ "$(which git)" ]; do
|
||||
echo -n "."
|
||||
sleep 1
|
||||
done
|
||||
|
||||
# Install brew
|
||||
if [ "$(which brew)" ]; then
|
||||
echo 'Brew already installed'
|
||||
else
|
||||
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
|
||||
fi
|
||||
|
||||
bash "$HOME/.dotfiles/local/bin/dfm" brew install && "Installed Brewfile contents"
|
||||
bash "$HOME/.dotfiles/local/bin/dfm" dotfiles link && "Linked all dotfiles"
|
||||
|
||||
read -r -p "Do you want to set macOS defaults? (y/N) " yn
|
||||
|
||||
case $yn in
|
||||
[yY])
|
||||
bash "set-defaults.sh"
|
||||
;;
|
||||
*)
|
||||
echo "Skipping..."
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Done. Note that some of these changes require a logout/restart to take effect."
|
||||
106
scripts/shared.sh
Normal file
106
scripts/shared.sh
Normal file
@@ -0,0 +1,106 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Shared bash functions and helpers
|
||||
# that can be sourced to other scripts.
|
||||
#
|
||||
|
||||
# -- Colors -- #
|
||||
CLR_RED="\033[1;31m"
|
||||
CLR_YELLOW='\033[1;33m'
|
||||
CLR_GREEN="\033[1;32m"
|
||||
CLR_BLUE='\033[1;34m'
|
||||
CLR_RESET="\033[0m"
|
||||
|
||||
# -- Helpers -- #
|
||||
function __log_marker()
|
||||
{
|
||||
echo -e "${CLR_BLUE}➜${CLR_RESET}"
|
||||
}
|
||||
|
||||
function __log_marker_ok()
|
||||
{
|
||||
echo -e "${CLR_GREEN}✔${CLR_RESET}"
|
||||
}
|
||||
|
||||
function __log_marker_ok_blue()
|
||||
{
|
||||
echo -e "${CLR_BLUE}✔${CLR_RESET}"
|
||||
}
|
||||
|
||||
function __log_marker_warn()
|
||||
{
|
||||
echo -e "${CLR_YELLOW}⁕${CLR_RESET}"
|
||||
}
|
||||
|
||||
function __log_marker_err()
|
||||
{
|
||||
echo -e "${CLR_RED}⛌${CLR_RESET}"
|
||||
}
|
||||
|
||||
function __log_indent()
|
||||
{
|
||||
echo " "
|
||||
}
|
||||
|
||||
# -- Log -- #
|
||||
function msg()
|
||||
{
|
||||
echo -e "$(__log_marker) $1"
|
||||
}
|
||||
|
||||
function msg_done()
|
||||
{
|
||||
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||
}
|
||||
|
||||
function msg_prompt()
|
||||
{
|
||||
echo -e "$(__log_marker) $1"
|
||||
}
|
||||
|
||||
function msg_prompt_done()
|
||||
{
|
||||
echo -e "$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||
}
|
||||
|
||||
function msg_nested()
|
||||
{
|
||||
echo -e "$(__log_indent)$(__log_marker) $1"
|
||||
}
|
||||
|
||||
function msg_nested_done()
|
||||
{
|
||||
echo -e "$(__log_indent)$(__log_marker) $1 ...$(__log_marker_ok)"
|
||||
}
|
||||
|
||||
function msg_run()
|
||||
{
|
||||
echo -e "${CLR_GREEN}➜ $1${CLR_RESET} $2"
|
||||
}
|
||||
|
||||
function msg_ok()
|
||||
{
|
||||
echo -e "$(__log_marker_ok) $1"
|
||||
}
|
||||
|
||||
function msg_warn()
|
||||
{
|
||||
echo -e "$(__log_marker_warn) $1"
|
||||
}
|
||||
|
||||
function msg_err()
|
||||
{
|
||||
echo -e "$(__log_marker_err) $1"
|
||||
}
|
||||
|
||||
# -- Menu builder -- #
|
||||
function menu_section()
|
||||
{
|
||||
LINE=$(printf '%-18s [ %-15s ]\n' "$1" "$2")
|
||||
echo -e " $(__log_marker) $LINE"
|
||||
}
|
||||
function menu_item()
|
||||
{
|
||||
LINE=$(printf '%-15s %-30s\n' "$1" "$2")
|
||||
echo -e "$(__log_indent)$(__log_marker) $LINE"
|
||||
}
|
||||
16
ssh/config
16
ssh/config
@@ -1,2 +1,16 @@
|
||||
Host github.com
|
||||
User git
|
||||
HostName github.com
|
||||
IdentityFile ~/.ssh/id_rsa
|
||||
|
||||
Host bitbucket.com
|
||||
Hostname bitbucket.com
|
||||
IdentityFile ~/.ssh/id_rsa
|
||||
|
||||
Host gitlab.com
|
||||
Hostname gitlab.com
|
||||
IdentityFile ~/.ssh/id_rsa
|
||||
|
||||
Host *
|
||||
IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
|
||||
IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock"
|
||||
|
||||
|
||||
53
zshrc
53
zshrc
@@ -2,21 +2,15 @@
|
||||
[[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.pre.zsh"
|
||||
# shellcheck shell=bash
|
||||
|
||||
LOCAL_BIN="$HOME/.local/bin"
|
||||
autoload -U colors zsh/terminfo
|
||||
colors
|
||||
|
||||
PYTHON_38="$HOME/Library/Python/3.8/bin"
|
||||
COMPOSER_DIR="$HOME/.composer/vendor/bin"
|
||||
USR_SBIN=/usr/local/sbin
|
||||
|
||||
export PATH="/opt/homebrew/bin:$USR_SBIN:$PATH"
|
||||
export PATH="/opt/homebrew/opt/ruby/bin:/opt/homebrew/bin:/usr/local/sbin:$PATH"
|
||||
|
||||
if [ command -v brew &> /dev/null ]; then
|
||||
BREW_BIN=$(brew --prefix)/bin
|
||||
BREW_SBIN=$(brew --prefix)/sbin
|
||||
|
||||
# PHP_74=$(brew --prefix php@7.4)/bin
|
||||
# PHP_80=$(brew --prefix php@8.0)/bin
|
||||
# PHP_CUR=$(brew --prefix php)/bin
|
||||
BREW_PYTHON=$(brew --prefix python@3.8)/bin
|
||||
GNUBIN_DIR=$(brew --prefix coreutils)/libexec/gnubin
|
||||
BREW_RUBY=$(brew --prefix ruby)/bin
|
||||
@@ -25,8 +19,21 @@ if [ command -v brew &> /dev/null ]; then
|
||||
export PATH="$BREW_PYTHON:$GNUBIN_DIR:$BREW_GEMS:$BREW_RUBY:$BREW_BIN:$BREW_SBIN:$PATH"
|
||||
fi
|
||||
|
||||
export PATH="$LOCAL_BIN:$PYTHON_38:$COMPOSER_DIR:$PATH"
|
||||
export HIST_STAMPS="yyyy-mm-dd"
|
||||
# If we have go packages, include them to the PATH
|
||||
if command -v go &> /dev/null; then
|
||||
export GOPATH=$(go env GOPATH);
|
||||
if [ -d "$GOPATH/bin" ]; then
|
||||
export PATH="$GOPATH/bin:$PATH"
|
||||
fi
|
||||
fi
|
||||
|
||||
if command -v nvim &> /dev/null; then
|
||||
export EDITOR="nvim"
|
||||
fi
|
||||
|
||||
LOCAL_BIN="$HOME/.local/bin"
|
||||
COMPOSER_DIR="$HOME/.composer/vendor/bin"
|
||||
export PATH="$LOCAL_BIN:$COMPOSER_DIR:$PATH"
|
||||
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
export NVM_LAZY_LOAD=true
|
||||
@@ -35,11 +42,24 @@ export NVM_AUTO_USE=true
|
||||
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
|
||||
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
|
||||
|
||||
[[ -f "$HOME/.dotfiles/alias" ]] && source "$HOME/.dotfiles/alias"
|
||||
[[ -f "$HOME/.dotfiles/alias-$HOSTNAME" ]] && source "$HOME/.dotfiles/alias-$HOSTNAME"
|
||||
# Run x-load-configs in your terminal to reload the files.
|
||||
function x-load-configs()
|
||||
{
|
||||
# Load the shell dotfiles, and then some:
|
||||
for file in ~/.dotfiles/config/{exports,alias,functions}; do
|
||||
[ -r "$file" ] && [ -f "$file" ] && source "$file"
|
||||
[ -r "$file-secret" ] && [ -f "$file-secret" ] && source "$file-secret"
|
||||
[ -r "$file-$HOSTNAME" ] && [ -f "$file-$HOSTNAME" ] && source "$file-$HOSTNAME"
|
||||
[ -r "$file-$HOSTNAME-secret" ] && [ -f "$file-$HOSTNAME-secret" ] && source "$file-$HOSTNAME-secret"
|
||||
done
|
||||
}
|
||||
x-load-configs
|
||||
|
||||
# Import ssh keys in keychain
|
||||
ssh-add -A 2>/dev/null;
|
||||
|
||||
# Try to load antigen, if present
|
||||
[[ -f "$HOME/.config/antigen.zsh" ]] && source "$HOME/.config/antigen.zsh"
|
||||
[[ -f "$HOME/.local/bin/antigen.zsh" ]] && source "$HOME/.local/bin/antigen.zsh"
|
||||
|
||||
# antigen is present
|
||||
if command -v antigen &> /dev/null; then
|
||||
@@ -54,13 +74,14 @@ if command -v antigen &> /dev/null; then
|
||||
antigen bundle zsh-users/zsh-completions
|
||||
antigen bundle MichaelAquilina/zsh-you-should-use
|
||||
antigen bundle unixorn/autoupdate-antigen.zshplugin
|
||||
antigen bundle Sparragus/zsh-auto-nvm-use
|
||||
# antigen bundle git-auto-fetch
|
||||
|
||||
hash php 2>/dev/null && antigen bundle php
|
||||
hash nvm 2>/dev/null && antigen bundle nvm
|
||||
hash docker 2>/dev/null && antigen bundle docker
|
||||
|
||||
hash nvm 2>/dev/null && antigen bundle Sparragus/zsh-auto-nvm-use
|
||||
hash ruby 2>/dev/null && antigen bundle ruby
|
||||
hash python 2>/dev/null && antigen bundle MichaelAquilina/zsh-autoswitch-virtualenv
|
||||
hash jq 2>/dev/null && antigen bundle reegnz/jq-zsh-plugin
|
||||
hash docker-compose 2>/dev/null && antigen bundle sroze/docker-compose-zsh-plugin
|
||||
# antigen bundle voronkovich/phpcs.plugin.zsh
|
||||
|
||||
Reference in New Issue
Block a user