Skip to content

Instantly share code, notes, and snippets.

View psprint's full-sized avatar

Sebastian Gniazdowski psprint

View GitHub Profile
# Zsh compiled script + zrecompile backup
*.zwc
*.zwc.old
# Zsh completion-optimization dumpfile
*zcompdump*
# Zsh zcalc history
.zcalc_history
@psprint
psprint / smatch.zsh
Last active August 15, 2019 18:44
Zsh functions for non-greedy matching
# Usage:
# if .smatch "axx" "a*x"; then
# print $REPLY
# fi
# Output:
# ax
# The parameters $match, etc. are also normally available
.smatch() {
local str="$1" pat="$2" retval=1
match=()
@psprint
psprint / deploy-code.zsh
Last active September 18, 2019 08:48
deploy-code – a Zsh function to deploy code execution for later, in Zle context
# This Zshell function will execute the given code from a Zle context.
# It has an optional delay first argument: "@sleep:<secnods with fractions>".
# If given, then the code will wait in background before being executed, for
# the specified amount of time.
# The limit of the code length is 25 lines and can be easily extended by
# changing the "repeat 25" line
#
# Usage:
# deploy-code "echo Hello world"
# deploy-code "BUFFER[-1]=''"
@psprint
psprint / deploy-message.zsh
Last active April 1, 2023 07:46
Zsh function to display a message under prompt
# The Zshell function will display the given message under-prompt (as a kind of notification).
# It has an optional delay first argument: "@sleep:<secnods with fractions>". If given, then
# the message will wait in background before showing for the specified time.
#
# Usage:
# deploy-message @msg "Hello world"
# deploy-message "Hello world"
# deploy-message @msg 1234 # I.e. the "@msg" is needed for number-only messages, otherwise optional
# deploy-message @sleep:5.5 "Hello world"
#
# Definition of a service that builds Zsh located at
# ~/github/sfzsh3, with -O2 and pointers to libgdbm.
#
# This file is for configure script. File sfzsh3make
# is for running make, and is triggered automatically
# by this file
#
integer disabled=0
# Return n-th (z) segment of given text
# $1 - text
# $2 - segment (default is 1)
# $3 - destination variable name (default is "REPLY")
#
# Can use e.g. 'reply[1]' for $3
function -zui_stdlib_get_segment() {
local -a segs
segs=( "${(z@)1}" )
local varname="${3-REPLY}"