Skip to content

Instantly share code, notes, and snippets.

ZSH CheatSheet

This is a cheat sheet for how to perform various actions to ZSH, which can be tricky to find on the web as the syntax is not intuitive and it is generally not very well-documented.

Strings

Description Syntax
Get the length of a string ${#VARNAME}
Get a single character ${VARNAME[index]}
@tgran2028
tgran2028 / 1-setopts.zsh
Created March 17, 2025 05:19 — forked from mattmc3/1-setopts.zsh
ZSH - options by framework
## ZSH Options
# http://zsh.sourceforge.net/Doc/Release/Options.html
# Changing Directories
# http://zsh.sourceforge.net/Doc/Release/Options.html#Changing-Directories
setopt auto_cd # if a command isn't valid, but is a directory, cd to that dir
setopt auto_pushd # make cd push the old directory onto the directory stack
setopt pushd_ignore_dups # don’t push multiple copies of the same directory onto the directory stack
setopt pushd_minus # exchanges the meanings of ‘+’ and ‘-’ when specifying a directory in the stack
@tgran2028
tgran2028 / cargo-bin-export.sh
Created February 27, 2025 09:10
Export installed bin crates metadata to JSON
#!/usr/bin/env bash
#
# export installed cargo binaries as JSON
set -euo pipefail
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
if ! command -v cargo &> /dev/null; then
if [[ -x $HOME/.cargo/bin/cargo ]]; then
[[ -r $HOME/.cargo/env ]] && source "$HOME/.cargo/env"
CMD=$HOME/.cargo/bin/cargo
else
@tgran2028
tgran2028 / path-default
Created February 26, 2025 05:35
set default $PATH
#!/usr/bin/env bash
export PIPX_HOME=$HOME/.local/python-utils
export PIPX_BIN_DIR=$HOME/.local/python-utils/bin
export DOTNET_ROOT=$HOME/.dotnet
export CARGO_HOME=$HOME/.cargo
export NVM_DIR=$HOME/.nvm
export MAMBA_ROOT_PREFIX=$HOME/.local/share/micromamba
export GOROOT=/usr/local/go
export GOPATH=$HOME/.local/go
@tgran2028
tgran2028 / json-convert.sh
Created February 26, 2025 02:36
Use yq to convert serialized formats
#!/bin/bash
# Function to parse and validate format options
parse_format() {
local -l fmt=$1
case "$fmt" in
a | auto) echo "auto" ;;
y | yaml) echo "yaml" ;;
j | json) echo "json" ;;
p | props) echo "props" ;;
@tgran2028
tgran2028 / github_render_md.py
Last active February 18, 2025 15:34
CLI program to utilize GitHub's markdown rendering API endpoint.
#!/usr/bin/env python3
import argparse
import os
import sys
from pathlib import Path
from typing import Callable
import json
import requests
@tgran2028
tgran2028 / get-vscode-commands.sh
Created February 10, 2025 17:07
Extract all vscode commands
#!/bin/bash
# manually save the default keybindings to a file
defaults="$TEMP/keybindings.vscode-default.jsonc"
mapfile -t used_commands < <(
jsonc read < "$defaults" |
jq -M '.[].command' |
xargs -n1
)
@tgran2028
tgran2028 / google-chrome-shellwrapper.sh
Created February 7, 2025 10:49
Shell wrapper around chrome executable. Actual filename is `google-chrome`
#!/bin/bash
#
# Copyright 2011 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Let the wrapped binary know that it has been run through the wrapper.
export CHROME_WRAPPER="`readlink -f "$0"`"
HERE="`dirname "$CHROME_WRAPPER"`"

An guide how to activate Windows 11 Pro for free

Why?

Because you will get some more features like an Bitlocker and host your device as an External Desktop which can be accessed through the internet

Am i also able to switch from any other edition to Pro?

The answer is yes! You can switch from almost any edition to Pro completely for free!

Note for users with unactivated Pro edition

People which already have Pro, but not activated, can skip to this step.

Getting started

What you first need to do is open CMD (Command Prompt) as Administrator using this keyboard key:

@tgran2028
tgran2028 / obsidian-local-rest-api.openapi.yaml
Created December 7, 2024 07:07
Obsidan Local Rest API plugins OPENAPI spec
components:
schemas:
Error:
properties:
errorCode:
description: |
A 5-digit error code uniquely identifying this particular type of error.
example: 40149
type: number
message: