Thursday, September 3, 2026

Break a long text line up in MacVim

 Put your cursor in the text line/paragraph you want to format and enter the command:

gqap

Monday, March 30, 2026

Laptop battery level from Linux CLI

upower --enumerate
 
# note battery entry, i.e. /org/freedesktop/UPower/devices/battery_BAT0
 
upower -i /org/freedesktop/UPower/devices/battery_BAT0
 
or 
 
acpi -b
 
or
 
inxi -B

Monday, March 23, 2026

Clone gitlab repo with access token

 When cloning a repo, you may get an error like:

remote: HTTP Basic: Access denied. If a password was provided for Git authentication...

 Go to GitLab and create a Personal Access Token if you don't already have one.  Copy that token use it to clone the repo

git clone https://<user>:<token>@gitlab.com/<repo_name>.git

Where <token> is the token. 

If the token expires or is revoked, you will need to generate a new token and add a new remote for the repo

git remote add origin https://sbargabus:<token>@gitlab.com/<repo_name>.git

And set up remote tracking

git branch --set-upstream-to=origin/main main

 

Wednesday, February 25, 2026

MacOS: create a password encrypted zip file

 To create a password-protected ZIP file on macOS, open iTerm and use the command  

zip -er filename.zip ./path/to/folder. 

Replace filename.zip with your preferred name and ./path/to/folder with the path to the folder you want to compress, then enter a password when prompted.

Wednesday, October 15, 2025

MariaDB database location

 Location can be found in the database itself:

select @@datadir; 

Thursday, October 9, 2025

How to Fix 'No Matching Host Key Type Found' on Mac

Add the following to your .ssh/config with the appropriate IP address 

Host 123.123.123.123
HostKeyAlgorithms +ssh-rsa

 https://www.iclarified.com/87910/how-to-fix-no-matching-host-key-type-found-on-mac

Tuesday, September 16, 2025

Diff of two pdf files

 Install on MacOS

 brew install diff-pdf

I used the follow for a visual diff:

diff-pdf --view earthscope-org-chart-2025-09_03_posted.pdf earthscope-org-chart-2025-09_12_posted.pdf

Wednesday, April 9, 2025

rsync screensaver pics

 Commands to rsync pics to my private server and back.

rsync -avz --checksum --dry-run --ignore-existing saver/ sbargy@bargabus.com:~/saver 

  • -a archive (lots of things including recursive)
  • -v verbose
  • -z compress on sync
  • --checksum use checksum for file comparison, not just size/date
The trailing / in first directory indicates use all files in that directory. 

Wednesday, April 2, 2025

Key-repeat suddenly stopped working in VSCode

 I had just fired up copilot and thought that was the cause.  I was editing a file in VSCode and had the Vim extension installed.  I use HJKL to move around a file, often holding down the key to move multiple lines.  It stopped working.  The K key would also pop up an Apple press and hold autocomplete suggestion that just contained a single k.

I removed the CoPilot extension and this behavior continued.  After much search, found this SO question.

This command turns off ApplePressAndHold for the VSCode application...

defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false

Set True to re-enable.

UPDATE:

Had the same issue with Windsurf/Codeium.  Tried the following

defaults write --app Windsurf.app ApplePressAndHoldEnabled -bool false

 The --app flag threw an error.  To find the Bundle ID of an application:

codesign -dr - /Applications/Windsurf.app

Executable=/Applications/Windsurf.app/Contents/MacOS/Electron
designated => identifier "com.exafunction.windsurf" and anchor apple generic and certificate 1[field.1.2.840.113635.100.6.2.6] /* exists */ and certificate leaf[field.1.2.840.113635.100.6.1.13] /* exists */ and certificate leaf[subject.OU] = "83Z2LHX6XW"


So, the following worked for Windsurf...

defaults write com.exafunction.windsurf ApplePressAndHoldEnabled -bool false

Monday, November 28, 2022

vi style line editing in csh

 This is the csh version of the "set -o vi" in bash...

bindkey -v

Thursday, July 7, 2022

Search for a filename in GitHub

 Search for a filename in GitHub (all repos in an account or a single repo) with:

filename:user.rb

Wednesday, February 9, 2022

Ignore whitespace in vimdiff

 Add the following to the vimdiff command line...

-c 'set diffopt+=iwhite'

Sunday, May 17, 2020

Mount OS/X samba share on Linux

sudo mount.cifs --verbose //192.168.1.11/scott bargamac/ -o user=scott,rw,vers=1.0

Thursday, April 23, 2020

datediff bash function

Datediff function to return the number of days between two dates.  It's not too robust, but I got it working on MacOS and Linux, mostly to accommodate the differences between GNU Util date and HomeBrew BSD date...

datediff() {
    date --version >> /dev/null 2>&1
    RETVAL=$?
    if [ -e /usr/local/bin/gdate ] && [ $RETVAL -ne 0 ] ;
    then
        DATEBIN=/usr/local/bin/gdate
    else
        DATEBIN=`which date`
    fi

    d1=$($DATEBIN -d "$1" +%s)
    d2=$($DATEBIN -d "$2" +%s)
    echo $(( (d1 - d2) / 86400 )) days
}

GNU date in MacOS

The GNU date utility is provided in the HomeBrew package coreutils as gdate.  Install with HomeBrew.

[~]
scott@bargamac$ HOMEBREW_NO_AUTO_UPDATE=1 brew install coreutils
==> Downloading https://homebrew.bintray.com/bottles/coreutils-8.32.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/5d/5da6cb9dbc0a8144480dde2fb78eb0a5a1710490afc3697174f7e261ec69763f?__gda__=exp=1587689482~hmac=42c0483b851c
######################################################################## 100.0%
==> Pouring coreutils-8.32.mojave.bottle.tar.gz
==> Caveats
Commands also provided by macOS have been installed with the prefix "g".
If you need to use these commands with their normal names, you
can add a "gnubin" directory to your PATH from your bashrc like:
  PATH="/usr/local/opt/coreutils/libexec/gnubin:$PATH"
==> Summary
🍺  /usr/local/Cellar/coreutils/8.32: 476 files, 8.8MB


Note the path to all the coreutils which can be added to your system $PATH

Tuesday, December 17, 2019

Remove tab bar from Firefox

As of FF 71.0 on macOS Mojave, edit the following file (creating it and its directory if they don't exist)...

Library/Application Support/Firefox/Profiles///chrome/userChrome.css

and add this snippet...

/* hides the native tabs
 */
#TabsToolbar {
  visibility: collapse;
}


Restart FF

Thursday, November 14, 2019

Installing and Updating Node.js

Install node.js and manage versions with nvm

Add to .bash_profile...

#---
## Replaces current node with latest, keeping installed global packages
#---
function nvm-upgrade {
    CURR=$(nvm current)
    nvm install node --reinstall-packages-from=node
    nvm uninstall $CURR
}

Wednesday, October 23, 2019

Running vim in "vanilla" mode

vim -u x --noplugin     where x is an empty file

Thursday, October 10, 2019

Docker CLI commands, most used by me

Docker command docker, used when managing individual containers on a docker engine. It is the client command line to access the docker daemon API

docker build - build an image from Dockerfile
docker container - manage one or more docker containers, takes a second argument (ps, rm, etc...)
docker exec - run a command in a running container
docker images - list all docker images
docker info - display a ton of system info for all docker containers
docker port - list port mappings, possibly for a single container
docker ps - list all docker containers
docker rm - remove one or more docker containers
docker rmi - remove one or more docker images
docker run - run d command in a new docker container

Docker command docker-compose, used to manage a multi-container application. It also moves many of the options you would enter on the docker run CLI into the docker-compose.yml file for easier reuse. It works as a front end "script" on top of the same docker API used by docker, so you can do everything docker-compose does with docker commands and a lot of shell scripting

docker-compose build - build or rebuild services
docker-compose exec - execute a command in a running container
docker-compose help - get help in
docker-compose images - list images
docker-compose ps - list containers
docker-compose up - build and start containers
docker-compose version - docker-compose version number

Docker command docker-machine, uses containerization to manage multiple images and containers and volumes and such: a container is basically a lightweight virtual machine

docker-machine create - create a new virtual machine
docker-machine env - display the commands to set up the environment for the Docker client
docker-machine kill - kill a machine
docker-machine ls - list all machines
docker-machine regenerate-certs - regenerate TLS certs for a machine
docker-machine restart - restart a machine
docker-machine rm - remove a machine
docker-machine ssh - log into or run a command on a machine with ssh
docker-machine start - start a machine
docker-machine version - show the docker machine version number

Monday, July 22, 2019

Removing an application manually from OS/X

After looking this up a million times, time to add it here...

  • rm -rf /Applications/APPNAME
  • rm -rf ~/Library/Preferences/APPFILES
  • rm -rf ~/Library/Caches/APPFILES
  • rm -rf ~/Library/Application\ Support/APPFILES
  • rm -rf ~/Library/Logs/APPFILES