Compare commits

...

8 Commits

Author SHA1 Message Date
Ismo Vuorinen
16d455a262 2023-01-30 2023-01-30 12:16:20 +02:00
Ismo Vuorinen
9ba66c7734 dfm: dotfiles update 2023-01-19 16:33:36 +02:00
Ismo Vuorinen
86824d8c45 bin: git-dirty - list dirty git repositories 2023-01-19 16:32:07 +02:00
38d853aa8a rcrc: Skip *-secret files from rc linking 2023-01-19 16:29:22 +02:00
Ismo Vuorinen
34a0d7d8c4 brew: Brewfile update 2023-01-17 10:02:09 +02:00
Ismo Vuorinen
65bf470c5b dfm: brew autoupdate now removes first, then adds 2023-01-17 10:01:40 +02:00
Ismo Vuorinen
965c47efef zshrc: secret exports, alias and functions files 2023-01-17 10:00:49 +02:00
410f5ac2b5 nvim: wakatime/vim-wakatime 2023-01-16 22:58:22 +02:00
11 changed files with 133 additions and 29 deletions

View File

@@ -120,6 +120,8 @@ brew "mas"
brew "midnight-commander" brew "midnight-commander"
# Ambitious Vim-fork focused on extensibility and agility # Ambitious Vim-fork focused on extensibility and agility
brew "neovim" brew "neovim"
# No Nonsense Neovim Client in Rust
brew "neovide"
# Port scanning utility for large networks # Port scanning utility for large networks
brew "nmap" brew "nmap"
# Manage multiple Node.js versions # Manage multiple Node.js versions
@@ -128,6 +130,8 @@ brew "nvm"
brew "openjdk" brew "openjdk"
# Generate clients, server & docs from an OpenAPI spec (v2, v3) # Generate clients, server & docs from an OpenAPI spec (v2, v3)
brew "openapi-generator" brew "openapi-generator"
# Swiss-army knife of markup format conversion
brew "pandoc"
# Highly capable, feature-rich programming language # Highly capable, feature-rich programming language
brew "perl" brew "perl"
# Interpreted, interactive, object-oriented programming language # Interpreted, interactive, object-oriented programming language
@@ -232,8 +236,6 @@ cask "insomnia"
cask "jetbrains-toolbox" cask "jetbrains-toolbox"
# Kubernetes IDE # Kubernetes IDE
cask "lens" cask "lens"
# Neovim Client
cask "neovide"
# Reverse proxy, secure introspectable tunnels to localhost # Reverse proxy, secure introspectable tunnels to localhost
cask "ngrok" cask "ngrok"
# Collaboration platform for API development # Collaboration platform for API development
@@ -266,8 +268,12 @@ cask "syntax-highlight"
cask "visual-studio-code" cask "visual-studio-code"
# Multimedia player # Multimedia player
cask "vlc" cask "vlc"
# Spell-checking service for Finnish
cask "voikkospellservice"
# Rust-based terminal # Rust-based terminal
cask "warp" cask "warp"
# View output from scripts in the menu bar
cask "xbar"
mas "1Password for Safari", id: 1569813296 mas "1Password for Safari", id: 1569813296
mas "Flow", id: 1423210932 mas "Flow", id: 1423210932
mas "GarageBand", id: 682658836 mas "GarageBand", id: 682658836
@@ -275,4 +281,5 @@ mas "iMovie", id: 408981434
mas "Keynote", id: 409183694 mas "Keynote", id: 409183694
mas "Numbers", id: 409203825 mas "Numbers", id: 409203825
mas "Pages", id: 409201541 mas "Pages", id: 409201541
mas "pullBar", id: 1601913905
mas "Tailscale", id: 1475387142 mas "Tailscale", id: 1475387142

View File

@@ -4,6 +4,7 @@
*.cache *.cache
*~ *~
*-secret
__secret __secret
__ignored __ignored
__test_*.php __test_*.php

View File

@@ -204,4 +204,7 @@ return function(use)
requires = { "jose-elias-alvarez/null-ls.nvim" } requires = { "jose-elias-alvarez/null-ls.nvim" }
} }
-- WakaTime Support
use { "wakatime/vim-wakatime" }
end end

View File

@@ -22,32 +22,32 @@ function section_install
case "$1" in case "$1" in
all) all)
$0 install antigen && msg_done "New antigen installed" $0 install antigen
$0 install macos && msg_done "macOS Defaults set" $0 install macos
$0 install brew && msg_done "Brewfile defined apps has been installed" $0 install brew
$0 install ext_gh && msg_done "Extensions for GitHub CLI have been installed" $0 install ext_gh
$0 install ext_go && msg_done "Go packages have been installed" $0 install ext_go
;; ;;
antigen) antigen)
curl -L git.io/antigen > "$DOTFILES/local/bin/antigen.zsh" && msg_done "🎉 Done!" curl -L git.io/antigen > "$DOTFILES/local/bin/antigen.zsh" && msg_done "🎉 New antigen installed!"
;; ;;
brew) brew)
brew bundle install --file="$BREWFILE" && msg_done "🎉 Done!" brew bundle install --file="$BREWFILE" && msg_done "🎉 macOS Defaults set!"
;; ;;
macos) macos)
bash "$DOTFILES/scripts/set-macos-defaults.sh" && msg_done "🎉 Done!" bash "$DOTFILES/scripts/set-macos-defaults.sh" && msg_done "🎉 Brewfile defined apps has been installed!"
;; ;;
ext_go) ext_go)
bash "$DOTFILES/scripts/install-go-packages.sh" && msg_done "🎉 Done!" bash "$DOTFILES/scripts/install-go-packages.sh" && msg_done "🎉 Go packages have been installed!"
;; ;;
ext_gh) ext_gh)
bash "$DOTFILES/scripts/install-gh-extensions.sh" && msg_done "🎉 Done!" bash "$DOTFILES/scripts/install-gh-extensions.sh" && msg_done "🎉 Extensions for GitHub CLI have been installed!"
;; ;;
settler) settler)
bash "$DOTFILES/scripts/settler.sh" && msg_done "🎉 Done!" bash "$DOTFILES/scripts/settler.sh" && msg_done "🎉 Settler has been run!"
;; ;;
*) *)
menu_section "$USAGE_PREFIX" "all | antigen | brew | macos | ext_go | ext_gh | settler" menu_section "$USAGE_PREFIX" "all | antigen | brew | ext_gh | ext_go | macos | settler"
menu_item "all" "Installs antigen, macos, brew, ext_gh and ext_go" menu_item "all" "Installs antigen, macos, brew, ext_gh and ext_go"
menu_item "antigen" "Updates the antigen.zsh file" menu_item "antigen" "Updates the antigen.zsh file"
menu_item "brew" "Install Brewfile contents" menu_item "brew" "Install Brewfile contents"
@@ -84,6 +84,7 @@ function section_brew
--describe && msg_done "🎉 Done!" --describe && msg_done "🎉 Done!"
;; ;;
autoupdate) autoupdate)
brew autoupdate delete
brew autoupdate start 43200 --upgrade --cleanup --immediate brew autoupdate start 43200 --upgrade --cleanup --immediate
;; ;;
*) *)
@@ -102,7 +103,7 @@ function section_dotfiles
case "$1" in case "$1" in
link) link)
rcup -B "$HOSTNAME" -f -v && msg_done "🎉 Done!" rcup -B "$HOSTNAME" -f -v && msg_done "🎉 dotfiles have been linked!"
;; ;;
update) update)
# Updates .dotfiles/scripts/install.sh and formats it # Updates .dotfiles/scripts/install.sh and formats it
@@ -111,16 +112,20 @@ function section_dotfiles
&& sed -i '' "s|$HOME|\$HOME|g" "$INSTALL_SCRIPT" \ && sed -i '' "s|$HOME|\$HOME|g" "$INSTALL_SCRIPT" \
&& sed -i '' "s|install.sh|$(basename "$INSTALL_SCRIPT")|g" "$INSTALL_SCRIPT" && sed -i '' "s|install.sh|$(basename "$INSTALL_SCRIPT")|g" "$INSTALL_SCRIPT"
$0 dotfiles shfmt $0 dotfiles shfmt
msg_done "🎉 Done!" $0 dotfiles link
msg_done "🎉 dotfiles updated and linked!"
;; ;;
shfmt) shfmt)
# Format shell scripts according to following rules. # Format shell scripts according to following rules.
shfmt -fn -l -w -i 2 -ci -sr -bn "$DOTFILES" find "$DOTFILES" \
\( -name '*.sh' -or -name '*.zsh' -or -name 'x-*' -or -not '*.pl' \) \
-exec shfmt -fn -l -w -i 2 -ci -sr -bn {} \;
msg_done "🎉 dotfiles have been formatted!"
;; ;;
*) *)
menu_section "$USAGE_PREFIX" "link | update | shfmt" menu_section "$USAGE_PREFIX" "link | update | shfmt"
menu_item "link" "Use rcrc to update dotfile links" menu_item "link" "Use rcrc to update dotfile links"
menu_item "update" "Updates dotfile links, installs host specific overrides automatically" menu_item "update" "Updates dotfile links (scripts/install.sh), formats it and runs it."
menu_item "shfmt" "Run shfmt to all dotfiles" menu_item "shfmt" "Run shfmt to all dotfiles"
;; ;;
esac esac
@@ -172,4 +177,3 @@ case "$1" in
tests) section_tests "$2" ;; tests) section_tests "$2" ;;
*) usage && exit 1 ;; *) usage && exit 1 ;;
esac esac

82
local/bin/git-dirty Executable file
View File

@@ -0,0 +1,82 @@
#!/usr/bin/env bash
# Get git repository status for all subdirectories
# recursively in specified dir.
#
# Check the default dir:
# `git-dirty.sh`
# Check specific dir:
# `git-dirty.sh ~/Projects`
# Override default dir with env:
# `GIT_DIRTY_DIR=$HOME/Projects git-dirty.sh`
#
# If you want to skip directory from checks, just add `.ignore` file next
# to the `.git` folder. ProTip: Add `.ignore` to your global `.gitignore`.
#
# The script automatically skips folders:
# node_modules, vendor
#
# SET Defaults:
# Default dir to check, can be overridden in env (.bashrc, .zshrc, ...)
: "${GIT_DIRTY_DIR:=$HOME/Code}"
# If user has provided folder as a first argument, use it.
if [ "$1" != "" ]; then
GIT_DIRTY_DIR="$1"
fi
# UTF-8 ftw
GITDIRTY="❌ "
GITCLEAN="✅ "
catch()
{
echo "Error $1 occurred on $2"
}
gitdirty()
{
local d="$1"
trap 'catch $? $LINENO' ERR
if [[ -d "$d" ]]; then
if [[ -e "$d/.ignore" ]]; then
echo -e ""
else
# Check that $d is not '--', 'vendor', or 'node_modules'
if [[ "${d:0:2}" == "--" ]] || [[ "$d" == "vendor" ]] || [[ "$d" == "node_modules" ]]; then
echo ""
else
cd "$d" > /dev/null
# If we have `.git` folder, check it.
if [[ -d ".git" ]]; then
ISDIRTY=$(git diff --shortstat 2> /dev/null | tail -n1)
ICON="$GITCLEAN"
[[ $ISDIRTY != "" ]] && ICON="$GITDIRTY"
printf " %s %s\n" "$ICON" "$(pwd)"
else
# If it wasn't git repository, check subdirectories.
gitdirtyrepos -- *
fi
fi
cd .. > /dev/null
fi
fi
}
gitdirtyrepos()
{
for x in "$@"; do
gitdirty "$x"
done
}
set -e
trap 'case $? in
139) echo "segfault occurred";;
11) echo "ssegfault occurred";;
esac' EXIT
gitdirtyrepos "$GIT_DIRTY_DIR"

2
rcrc
View File

@@ -1,2 +1,2 @@
EXCLUDES="*.md *.sh *.lock.json Brewfile scripts" EXCLUDES="*.md *.sh *.lock.json Brewfile scripts *-secret xbar"
HOSTNAME=$(hostname -s) HOSTNAME=$(hostname -s)

View File

@@ -9,7 +9,7 @@
# env VERBOSE=1 sh install-dotfiles.sh # env VERBOSE=1 sh install-dotfiles.sh
# #
# DO NOT EDIT THIS FILE # DO NOT EDIT THIS FILE
# #
# This file is generated by rcm(7) as: # This file is generated by rcm(7) as:
# #
# rcup -B 0 -g # rcup -B 0 -g
@@ -22,14 +22,12 @@
: ${MKDIR:=/bin/mkdir} : ${MKDIR:=/bin/mkdir}
: ${RM:=/bin/rm} : ${RM:=/bin/rm}
: ${DIRNAME:=/usr/bin/dirname} : ${DIRNAME:=/usr/bin/dirname}
verbose() verbose() {
{
if [ "$VERBOSE" -gt 0 ]; then if [ "$VERBOSE" -gt 0 ]; then
echo "$@" echo "$@"
fi fi
} }
handle_file_cp() handle_file_cp() {
{
if [ -e "$2" ]; then if [ -e "$2" ]; then
printf "%s " "overwrite $2? [yN]" printf "%s " "overwrite $2? [yN]"
read overwrite read overwrite
@@ -47,8 +45,7 @@ handle_file_cp()
$MKDIR -p "$($DIRNAME "$2")" $MKDIR -p "$($DIRNAME "$2")"
$CP -R "$1" "$2" $CP -R "$1" "$2"
} }
handle_file_ln() handle_file_ln() {
{
if [ -e "$2" ]; then if [ -e "$2" ]; then
printf "%s " "overwrite $2? [yN]" printf "%s " "overwrite $2? [yN]"
read overwrite read overwrite
@@ -84,10 +81,11 @@ handle_file_ln "$HOME/.dotfiles/git_profiles" "$HOME/.git_profiles"
handle_file_ln "$HOME/.dotfiles/huskyrc" "$HOME/.huskyrc" 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/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/dfm" "$HOME/.local/bin/dfm"
handle_file_ln "$HOME/.dotfiles/local/bin/git-dirty" "$HOME/.local/bin/git-dirty"
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-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-dupes.pl" "$HOME/.local/bin/x-dupes.pl"
handle_file_ln "$HOME/.dotfiles/local/bin/x-foreach" "$HOME/.local/bin/x-foreach" 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-multi-ping.pl" "$HOME/.local/bin/x-multi-ping.pl"
handle_file_ln "$HOME/.dotfiles/local/bin/x-open-ports" "$HOME/.local/bin/x-open-ports" 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-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-error" "$HOME/.local/bin/x-until-error"

View File

@@ -104,3 +104,10 @@ function menu_item()
LINE=$(printf '%-15s %-30s\n' "$1" "$2") LINE=$(printf '%-15s %-30s\n' "$1" "$2")
echo -e "$(__log_indent)$(__log_marker) $LINE" echo -e "$(__log_indent)$(__log_marker) $LINE"
} }
# https://stackoverflow.com/a/85932
function fn_exists()
{
declare -f -F "$1" > /dev/null
return $?
}

2
zshrc
View File

@@ -48,7 +48,9 @@ function x-load-configs()
# Load the shell dotfiles, and then some: # Load the shell dotfiles, and then some:
for file in ~/.dotfiles/config/{exports,alias,functions}; do for file in ~/.dotfiles/config/{exports,alias,functions}; do
[ -r "$file" ] && [ -f "$file" ] && source "$file" [ -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" ] && [ -f "$file-$HOSTNAME" ] && source "$file-$HOSTNAME"
[ -r "$file-$HOSTNAME-secret" ] && [ -f "$file-$HOSTNAME-secret" ] && source "$file-$HOSTNAME-secret"
done done
} }
x-load-configs x-load-configs