Skip to content

Latest commit

 

History

History
105 lines (78 loc) · 3.44 KB

File metadata and controls

105 lines (78 loc) · 3.44 KB

bin

Scripts for windows / mac / linux, and also documentation for me.

Feel free to send a PR!

Install

Clone the repo to e.g. ~/bin:

git clone https://github.com/darthwalsh/bin.git
# OR
git clone git@github.com:darthwalsh/bin.git

Quick Setup (prototype)

  1. clone repo
  2. install mise: https://mise.jdx.dev/installing-mise.html
  3. install dependencies:
mise install

$modules = @('Pester', 'posh-git', 'powershell-yaml', 'PowerShellForGitHub')
foreach ($module in $modules) {
    if (Get-Module -ListAvailable -Name $module) {
        Write-Host "$module is already installed" -ForegroundColor Green
    } else {
        Write-Host "Installing $module..." -ForegroundColor Cyan
        Install-Module $module -Scope CurrentUser -Force
    }
}

MAYBE instead use [tasks.setup-pwsh] run = "pwsh -Command \"Install-Module ModuleName\""

This will:

  • Install required dependencies (uv, oh-my-posh)
  • Provide instructions for configuring your shell profile

Then follow the manual setup instructions below to complete configuration.

One-line Linux install for SSH or docker

ssh $NAME 'git clone --depth 1 https://github.com/darthwalsh/bin.git ~/.dw-bin 2>/dev/null || git -C ~/.dw-bin pull && export PATH="$HOME/.dw-bin:$HOME/.dw-bin/lnx:$PATH" && source ~/.dw-bin/bash_aliases && exec bash -i'

# Start a new docker container from image with a volume mount
docker run --rm -it -v ~/code/bin:/usr/local/bin/.dw-bin $IMAGE bash -i -c 'export PATH="/usr/local/bin/.dw-bin:$PATH" && source /usr/local/bin/.dw-bin/bash_aliases && exec bash -i'

# Existing docker with git
docker exec -it -u 0 $NAME bash -lc 'git clone --depth 1 https://github.com/darthwalsh/bin.git /usr/local/bin/.dw-bin 2>/dev/null || git -C /usr/local/bin/.dw-bin pull && source /usr/local/bin/.dw-bin/bash_aliases && exec bash -i'

# Or without git, manually copy from host
docker cp ~/code/bin "${NAME}:/usr/local/bin/.dw-bin" && docker exec -it -u 0 "${NAME}" bash -ic 'export PATH="/usr/local/bin/.dw-bin:$PATH" && 
source /usr/local/bin/.dw-bin/bash_aliases && exec bash -i'

bash / zsh

Add this to ~/.bashrc or ~/.zshrc

source ~/bin/bash_aliases
PATH=~/bin:$PATH

Then, for OS specific-scripts add ones of these lines:

PATH=~/bin/lnx:$PATH
PATH=~/bin/mac:$PATH

powershell

Edit the file $PROFILE to start with one of these lines:

. ~/bin/lnx/Microsoft.PowerShell_profile.ps1
. ~/bin/mac/Microsoft.PowerShell_profile.ps1
. ~/bin/win/Microsoft.PowerShell_profile.ps1

Optionally, install:

Install-Module posh-git -Scope CurrentUser

cmd

There are some old commands from cmd are in Dropbox... but that's not supported here.

Language-Specific setup

python

Some scripts like gpx.py use /// script; dependencies= inline script metadata and should be run with pipx or uv.

Then format and lint with

uvx ruff check --fix && uvx ruff format

When fixing, Ruff's lint hook must be placed before formatter

Testing

The scripts are not well tested, but see tests/README.md for instructions on running tests.

Tests use Pester (PowerShell testing framework) and can be run on Linux, macOS, and Windows. See the testing documentation for installation prerequisites and usage instructions.