Skip to content

Commit

Permalink
usual wave of package updates ; minor git batch and my kitty changes (#…
Browse files Browse the repository at this point in the history
…68)

* bash docker desktop safety net
* Correct git batch on synk on main
* 🔧 increase treesitter plugins to knob 4
* 🔧 disable treesitter for markdown since it messages with NoSpell in code blocks
* 🔧 package updates
* 🔧 only load cmp_dap if knob enabled
* 📦️ update packages ; switch magnet to rectangle
* 📦️ Add treesitter playground
* 📦️ update packages
* 🐛 realign local branch with remote when we've jumped onto exist local missing from remote
* 📦️ update packages
* Disable ts_rainbow due to treesitter error
* 📦️ update brew
* 📦️ update nvim packages
* Support offline mode for git batch
* Add note window for my-kitty
* closeme without neovim close
* Don't worry about closing todo in closeme
* 🔧 start rust config
* 📦️ update packages
* ✨ replace space in computer name with -
* 📦️brew and nvim package updates
  • Loading branch information
ianhomer authored Aug 26, 2023
1 parent 09a1557 commit 96841ef
Show file tree
Hide file tree
Showing 27 changed files with 1,675 additions and 1,347 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ MacOS with
**[hiddenbar](https://github.com/dwarvesf/hidden)**
: focused status bar

**[magnet](https://magnet.crowdcafe.com/)**
**[rectangle](https://rectangleapp.com/)**
: window manager

Other tools woven into these dotfiles include **ag**, **fzf**, **pandoc**,
Expand Down
4 changes: 3 additions & 1 deletion bin/backup-me
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ if [[ ! -d "$BACKUP_ROOT" ]] ; then
exit 1
fi

BACKUP_DESTINATION=$BACKUP_ROOT/backup/$(scutil --get ComputerName)-$USER
COMPUTER_NAME=$(scutil --get ComputerName)

BACKUP_DESTINATION=$BACKUP_ROOT/backup/${COMPUTER_NAME/ /-}-$USER

if [[ ! -d $BACKUP_DESTINATION ]] ; then
#
Expand Down
16 changes: 12 additions & 4 deletions bin/closeme
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,22 @@ step to free up resources.
-v close only vim processes
#or nvim, this closes all proceses without lock in the process name
Start vim with
Start vim with
nvim +lock
nvim +lock
to withstand this close process. This process of closing nvim relies on nvim
autosaving files, this process does not save files.
EOF
}

OPTIND=1
while getopts "hnv" o; do case "$o" in
while getopts "hnvV" o; do case "$o" in
h) help && exit 0 ;;
f) FORCE_CLOSE=y ;;
n) JUST_NODE=y ;;
v) JUST_VIM=y ;;
V) NOT_VIM=y ;;
*) exit 1 ;;
esac done
shift $((OPTIND-1))
Expand All @@ -41,8 +42,15 @@ BREW_PREFIX=`brew --prefix`

if [[ "$JUST_NODE" == "y" ]] ; then
applications="node $BREW_PREFIX/Cellar/node"
else
elif [[ "$JUST_VIM" == "y" ]] ; then
applications="nvim"
else
if [[ "$NOT_VIM" == "y" ]] ; then
echo "Not closing neovim"
applications=""
else
applications="nvim"
fi
applications+=" watchman $BREW_PREFIX/bin/watchman"
applications+=" node $BREW_PREFIX/Cellar/node"
applications+=" /Applications/Flipper.app prettierd eslint_d adb"
Expand Down
3 changes: 1 addition & 2 deletions bin/dotme-nvim-nightly
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
#
# Install nightly version of neovim.
#
# This is interim until v0.5 released or brew HEAD reliably works. Following
# guidance on https://github.com/neovim/neovim/releases/tag/nightly
# See https://github.com/neovim/neovim/releases/tag/nightly
#

set -e
Expand Down
40 changes: 40 additions & 0 deletions bin/dotme-rust-analyzer-nightly
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env bash

#
# Install nightly version of rust-analyzer.
#

set -e

$(shim) && cd ${ME} && . bin/i.sh

nightlyInstallation=~/local/rust-analyzer/$(date +%Y%m%d)
if [ ! -f ${nightlyInstallation}/rust-analyzer-aarch64-apple-darwin ] ; then
log:: "installing nightly rust-analyzer ${nightlyInstallation}"
nightlyRelease=~/Downloads/rust-analyzer-aarch64-apple-darwin.gz
if [ ! -f "${nightlyRelease}" ] ; then
log:: "downloading nightly"
curl -fLo $nightlyRelease \
https://github.com/rust-lang/rust-analyzer/releases/download/nightly/rust-analyzer-aarch64-apple-darwin.gz
fi

mkdir -p ${nightlyInstallation}
cd ${nightlyInstallation}
cp "${nightlyRelease}" .
gunzip rust-analyzer-aarch64-apple-darwin.gz
chmod +x rust-analyzer-aarch64-apple-darwin

[ -L ~/bin/rust-analyzer ] && rm ~/bin/rust-analyzer
ln -s ${nightlyInstallation}/rust-analyzer-aarch64-apple-darwin ~/bin/rust-analyzer
else
if [ ! -f ~/bin/rust-analyzer ] ; then
log:: "linking latest nightly to ~/bin/rust-analyzer"
if [ ! -d ~/bin ] ; then
log:: "Creating ~/bin"
mkdir ~/bin
fi
ln -s ${nightlyInstallation}/rust-analyzer-aarch64-apple-darwin ~/bin/rust-analyzer
else
log:: "nightly rust-analyzer ${nightlyInstallation} already installed"
fi
fi
36 changes: 22 additions & 14 deletions bin/git-batch
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ EOF
}

OPTIND=1
while getopts "ahn:t" o; do case "$o" in
while getopts "ahn:ot" o; do case "$o" in
a) git config core.allowbatchcompletions true ;;
h) help && exit 0 ;;
t) WITH_TIME="y" ;;
n) BATCH_NAME=$OPTARG ;;
o) OFFLINE="y" ;;
esac done
shift $((OPTIND-1))

Expand All @@ -68,22 +69,29 @@ function newBatch {
batchName=`date +%Y%m%d`
fi
batchBranchName=batch/$batchName
git ls-remote --exit-code --heads origin $batchBranchName
if [ $? -eq 0 ] ; then
log::error "Checking out existing remote batch $batchName"
git fetch origin $batchBranchName
git checkout $batchBranchName
elif [ `git rev-parse --verify $batchBranchName 2>/dev/null` ] ; then
log::error "Checking out existing local batch $batchName"
git checkout $batchBranchName
if [[ "$OFFLINE" != "y" ]] ; then
git ls-remote --exit-code --heads origin $batchBranchName
if [ $? -eq 0 ] ; then
log::error "Checking out existing remote batch $batchName"
git fetch origin $batchBranchName
git checkout $batchBranchName
elif [ `git rev-parse --verify $batchBranchName 2>/dev/null` ] ; then
log::error "Checking out existing local batch $batchName"
git checkout $batchBranchName
git branch --unset-upstream $batchBranchName
git push
git pullme
else
log::info "Creating new batch $batchName"
# Pull latest trunk before branching
git pull
git checkout -b $batchBranchName
fi
git ls-remote --heads origin | grep "/batch/"
[ $? -eq 0 ] && log::info "^ batches on remote listed above"
else
log::info "Creating new batch $batchName"
# Pull latest trunk before branching
git pull
git checkout -b $batchBranchName
fi
git ls-remote --heads origin | grep "/batch/"
[ $? -eq 0 ] && log::info "^ batches on remote listed above"
fi
}

Expand Down
10 changes: 5 additions & 5 deletions bin/git-synk
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,7 @@ function gitSynk() {
current=`pwd | sed 's|.*/||g'`
changes=$(git status --porcelain | wc -l)

if [[ "$branchName" == "main" ]] ; then
log::info "Pulling ${PWD##*/} from main, no push"
git pull
return
elif [[ "$branchName" != */* ]] ; then
if [[ "$branchName" != */* ]] ; then
if [[ $changes -gt 0 ]] ; then
if [[ "true" == `git config core.autocommit` ]] ; then
# Automatically create batch
Expand All @@ -90,6 +86,10 @@ function gitSynk() {
printf "∷ ◉ $current - set autocommit with git synk -a to enable auto branching"
return 128
fi
else
log::info "Pulling ${PWD##*/} from main, no push"
git pull
return
fi
fi

Expand Down
7 changes: 6 additions & 1 deletion bin/jwt-decode
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,15 @@
# Part 1 is Header
# Part 2 is Payload

JWT=$1
if [[ -z "$JWT" ]] ; then
JWT=$(</dev/stdin)
fi

for i in 1 2 ; do
echo
echo "Part $i"
part=$(echo $1 | cut -f$i -d .)
part=$(echo $JWT | cut -f$i -d .)
case $((${#part} % 4)) in
2) part="${part}==";;
3) part="${part}=";;
Expand Down
48 changes: 45 additions & 3 deletions bin/my-kitty
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,24 @@
import json
import os
import subprocess
import time
from functools import cached_property


class KittyState:
def __init__(self):
self.state = json.loads(subprocess.check_output(["kitty", "@", "ls"]))
self.refresh()

def print(self):
for window in self.state:
print(window)
for tab in window["tabs"]:
print(tab["title"])

def refresh(self):
self.state = json.loads(subprocess.check_output(["kitty", "@", "ls"]))


@cached_property
def tabTitles(self):
titles = []
Expand All @@ -31,20 +36,44 @@ class KittyState:

class Kitty:
def __init__(self):
self.refreshState()

def refreshState(self):
self.state = KittyState()

def action(self, action):
os.system("kitty @ " + action)

def launchTab(self, title, directory):
def launchOsWindow(self, title):
if title not in self.state.tabTitles:
kitty.action(
"launch --type os-window --keep-focus --title "
+ title
+ " --os-window-title "
+ title
)
else:
print("Tab for OS window already exists : " + title)

def waitForTab(self, title):
for _ in range(10):
self.refreshState()
if title in self.state.tabTitles:
return
time.sleep(0.1)
print("Tab " + title + " not found")

def launchTab(self, title, directory, match=None):
if title not in self.state.tabTitles:
self.action(
"launch --type=tab --tab-title "
+ title
+ (" --match " + match if match else "")
+ " --cwd "
+ directory
+ " fish"
)
return True
else:
print("Tab already exists : " + title)

Expand All @@ -55,5 +84,18 @@ kitty = Kitty()
print("Current tabs : " + ",".join(kitty.state.tabTitles))
kitty.launchTab(".", "~/.dotfiles")
kitty.launchTab("󰧮", "~/projects/things")
kitty.action("focus-tab --match 'title:^.'")

kitty.launchOsWindow("O")
kitty.action("set-background-opacity --match title:O 0.8")
kitty.action("set-spacing --match title:O margin=0")
kitty.action("set-spacing --match title:O padding=0")
kitty.action("resize-os-window --match title:O --width 100 --height 40 --self")
if kitty.launchTab("things", "~/projects/things", "title:O"):
# Only launch todo first time window initialised
kitty.waitForTab("things")
time.sleep(0.3) # give time for shell to initialise
kitty.action("send-text --match title:things 'do -ai\n'")

kitty.action("focus-tab --match 'title:^\\.'")

print("... complete")
1 change: 1 addition & 0 deletions config/brew/Brewfile
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ brew "wget"

cask "kitty"
cask "iterm2"
cask "rectangle"
cask "wezterm"

#
Expand Down
Loading

0 comments on commit 96841ef

Please sign in to comment.