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 a single character ${VARNAME[index]}
Get the string from a specific index ${VARNAME[index,-1]}
=> kodi-addon-pvr-zattoo-18.1.21_1: running do_configure ...
-- The C compiler identification is GNU 9.3.0
-- The CXX compiler identification is GNU 9.3.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
@teldra
teldra / OpenWrt detect new device and send text message.md
Created March 18, 2019 13:14 — forked from jwalanta/OpenWrt detect new device and send text message.md
Detect new network devices connecting to OpenWrt and send text message
@teldra
teldra / iptables.sh
Created August 22, 2018 21:39
Firewall configuration with sshguard/peerguardian
#!/bin/bash
######################################################################
# Firewall configuration with sshguard/peerguardian #
# Needs sshguard, pgld and ip{6}tables installed! #
# For Ubuntu 14.04, may works on Debian and older versions of Ubuntu #
# but this is not tested. #
######################################################################
# Set bash error mode
@teldra
teldra / websearch
Last active April 6, 2018 16:30
Suchmaschinen fuer i3
#!/bin/bash
function chooseBrowser() {
browser=("${@}")
for i in ${browser[@]}; do
if [[ $(pgrep $i) ]]; then
RUNNING+=( $i )
fi
done
@teldra
teldra / addbookmark
Created April 5, 2018 11:11
Add bookmarks with buku with zenity
#!/bin/bash
TAGS=0
COMMENT=0
URL="${1}"
if [[ -z "${URL}" ]]; then
exit
fi
@teldra
teldra / set-input
Last active April 5, 2018 11:10
Set pointerspeed with gui
#!/bin/bash
actval1=$(cat /sys/devices/platform/i8042/serio1/serio2/sensitivity)
actval2=$(cat /sys/devices/platform/i8042/serio1/serio2/speed)
actval3=$(cat /sys/devices/platform/i8042/serio1/serio2/inertia)
opt=$(zenity --list --text "Set What?" --column "Opinion" sensitivity ${actval1} speed ${actval2} inertia ${actval3} --column "Value")
case $opt in
sensitivity)
std=128
@teldra
teldra / gettemp.sh
Created September 11, 2017 00:59 — forked from tastytea/gettemp.sh
Get temperature and store in file, openweathermap
#!/bin/sh
API_KEY=""
CITY="Hamburg,de"
OUTPUT_FILE="/run/user/$(id -u)/gettemp.temperature"
RESULT=""
RETRY=0
if [ "${1}" != "" ]; then
CITY="${1}"
@teldra
teldra / .gpg-mime-end
Created September 11, 2017 00:59 — forked from tastytea/.gpg-mime-end
procmail auto-encrypt
--MfFXiAuoTsnnDAfX
@teldra
teldra / wintime
Created September 11, 2017 00:59 — forked from tastytea/wintime
Display time in window title
#!/bin/sh
if [ -z "${1}" ]; then
echo "usage: ${0} <Window Title>" >&2
exit 1
fi
WINTITLE="${1}"
WINID=$(wmctrl -l | grep ${WINTITLE} | cut -d' ' -f1)
if [ -z "${WINID}" ]; then