Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastian Gniazdowski psprint

View GitHub Profile
View zsh.gitignore
# Zsh compiled script + zrecompile backup
*.zwc
*.zwc.old
# Zsh completion-optimization dumpfile
*zcompdump*
# Zsh zcalc history
.zcalc_history
View zsh-link-with-curses.patch
@psprint
psprint / smatch.zsh
Last active Aug 15, 2019
Zsh functions for non-greedy matching
View smatch.zsh
# 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 Sep 18, 2019
deploy-code – a Zsh function to deploy code execution for later, in Zle context
View deploy-code.zsh
# 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 Jul 12, 2021
Zsh function to display a message under prompt
View deploy-message.zsh
# 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"
View build_zsh.zsh
#
# 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
View getsegment.zsh
# 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}"