Skip to content

Instantly share code, notes, and snippets.

View hedzr's full-sized avatar
🎯
Focusing

hz hedzr

🎯
Focusing
View GitHub Profile
@hedzr
hedzr / vm.sh
Last active January 20, 2023 03:32
function `vm` - manage VMs from command-line - chs post at https://hedzr.com/devops/linux/manage-vms-from-command-line/
#
# `vm`: To run it, vmware_run.sh & vagrant_run.sh should be integrated
# into this script, or you have a zshrc import framework to make
# them work together.
# And, `bash.sh` (https://github.com/hedzr/bash.sh) should be
# imported for `strip_r`, `commander`, `tip`, `err`, and so on.
# But you can always cut them from original.
#
# - bash.sh - https://github.com/hedzr/bash.sh
# - vm.sh - https://gist.github.com/hedzr/ea2626fb290e5ca74687967d0d768cdb
@hedzr
hedzr / vmware_run.sh
Created January 18, 2023 06:12
run a vmware VM from command-line - chs post at https://hedzr.com/devops/linux/run-vmware-vm-from-command-line/
vmware_run() {
local VMDIR="${VMWARE_DIR:-$HOME/Downloads/VMs/vmware}"
local VMTYPE="${VMWARE_TYPE:-fusion}" # or "ws"
# local VMDIR="$HOME/Documents/Virtual Machines.localized"
which vmrun >/dev/null 2>&1 || ln -s "/Applications/VMware Fusion.app/Contents/Library/vmrun" /usr/local/bin/vmrun
vmware_run_usage() {
cat <<-EOF
Usage:
$(basename $0) <VM-name> <start|up|stop|halt|suspend|reset|pause|unpause>
__vms_reg() {
# hash -d | grep -qE '^vhost.ub20a=' || hash -d vhost.ub20a="$HOME/work/ops.work/ub20a.local"
hash -d | grep -qE '^vhost.hello=' || hash -d vhost.hello="$HOME/hack/work/hello-1-cxx"
# Or modified tabbed entries in ~/.vagrant.vhosts. A sample entry is:
# ub20a $HOME/work/ops.work/ub20a.local
if [ -f "$HOME/.vagrant.vhosts" ]; then
local name1 name2
while IFS=$'\t' read -r name1 name2; do
if [[ "$name1" != "" ]]; then
@hedzr
hedzr / 97.A-Typesetter-independent-TROFF.ps
Created December 25, 2021 04:33
A Typesetter-independent TROFF
%!PS
%%Version: 3.3.1
%%DocumentFonts: (atend)
%%Pages: (atend)
%%EndComments
%
% Version 3.3.1 prologue for troff files.
%
/#copies 1 store
@hedzr
hedzr / vmware_run.md
Last active September 1, 2022 06:29
Bash/Zsh script for running VM in headless mode (VMWare Fusion or VMWare)

Paste the content into your .zshrc or .bashrc, and relogin.

# $ vmware_run help
# Usage:
#  vmware_run <VM-name> <start|stop|suspend|reset|pause|unpause>
#  vmware_run <VM-name> <start_with_gui|start-with-gui>
#
# Examples:
#  vmware_run start u20.local.new
function docker-rmi-none() {
for i in `docker-images-none-cids`; do
echo $i
#local cid=$(docker-cid "$i")
#[ "$cid" != "" ] &&
local pid=$(docker-pid "$i" 2>/dev/null)
[ "$pid" != "" ] && echo "-------- Cleaning the stopped container: $i, $pid" && docker rm -f $pid
[ "$i" != "" ] && echo "-------- Erasing the container: $i, $pid" && docker rmi -f $i
done
}

the logos in my jodl projects

@hedzr
hedzr / git-submodule-rm
Last active August 30, 2019 09:14
Bundle to remove a git submodule
#!/bin/bash
# AUTHOR: Hedzr Yeh
# LICENSE: MIT
# PREREQUISITES:
# 1. install ini-op tool:
# i. via `go install`
# `go get github.com/hedzr/ini-op`
# ii. download ini-op bianry release and put the unzipped executable file into a location which is $PATH searchable
@hedzr
hedzr / docker-fn-save-load.sh
Last active August 27, 2022 00:26
This script give a set of commands to save/load [all] docker containers as/from .tgz file(s).
#!/usr/bin/env bash
# # docker-fn series
# docker-fn-save-load.sh:
#
# This script give a set of commands to save/load [all] docker containers as/from .tgz file(s).
# > While you would plan to reset docker disk image file.
#
# Author: Hedzr Yeh
# LICENSE: MIT
https://press.one/p/v?s=4f4e8d9e3ef52a3af3324d1b6650798f99f72a035a9540ac4203d6c044208b920dffa74f09a761803365b6c1f0b27f15f8e4f64fd22adf0fc8a227792a56010601&h=70c1880b5a2db11f79b4778340b304b52dd8307abee071c3d5ff5719fa37b21a&a=4db0ad2a817858508cee91e7ca898f70bb4b05b1&f=P1&v=3