Skip to content

Instantly share code, notes, and snippets.

View romkatv's full-sized avatar

Roman Perepelitsa romkatv

View GitHub Profile
@romkatv
romkatv / install_meslo_wsl.sh
Last active September 9, 2023 08:53
Install Meslo Powerline font family on Windows
#!/bin/bash
#
# This script installs patched Meslo Powerline font family on Windows.
# The fonts are installed for the current user only. The script must be
# run from WSL.
#
# bash -c "$(curl -fsSL https://gist.githubusercontent.com/romkatv/aa7a70fe656d8b655e3c324eb10f6a8b/raw/install_meslo_wsl.sh)"
#
# If you just want the font files, they are in
# https://github.com/romkatv/dotfiles-public/tree/master/.local/share/fonts/NerdFonts.
@romkatv
romkatv / p10k-bar.zsh
Created September 23, 2019 12:08
p10k-bar.zsh
# Config for Powerlevel10k ZSH theme (https://github.com/romkatv/powerlevel10k/) that emulates
# the appearance of Bar ZSH theme (https://github.com/anki-code/zsh-bar-theme).
() {
emulate -L zsh
setopt no_unset
# Unset all configuration options.
unset -m 'POWERLEVEL9K_*'
typeset -g POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(
@romkatv
romkatv / p10k-portable.zsh
Created November 12, 2019 08:14
p10k-portable.zsh
# Powerlevel10k configuration file restricted to 8-color ASCII. Produced by
# running `p10k configure` while at 1387763f2719661dc7e43e86a5bfd24cc357d6a0
# and then editing ~/.p10k.zsh. Configuration wizard header follows.
#
# Generated by Powerlevel10k configuration wizard on 2019-11-12 at 08:45 CET.
# Based on romkatv/powerlevel10k/config/p10k-lean.zsh, checksum 11792.
# Wizard options: compatible, lean, 2 lines, disconnected, no frame, sparse, concise.
# Type `p10k configure` to generate another config.
# Temporarily change options.
@romkatv
romkatv / run-command.zsh
Last active February 9, 2024 12:48
Zsh function to run a command and capture its status, stdout and stderr
# Runs "$@" in a subshell with the caller's options, sets reply=(stdout stderr)
# and returns the status of the executed command. Both stdout and stderr are
# captured completely, including NUL bytes, incomplete UTF-8 characters and
# trailing LF, if any.
#
# Example:
#
# % zsh-run-command ls -d ~ /garbage
# % printf 'status: %s\nstdout: %s\nstderr: %s\n' $? "${(q+)reply[@]}"
# status: 2
@romkatv
romkatv / instant-zsh.zsh
Last active February 17, 2024 10:59
Make zsh start INSTANTLY with this one weird trick
# Make zsh start INSTANTLY with this one weird trick.
#
# https://asciinema.org/a/274255
#
# HOW TO USE
#
# 1. Download this script.
#
# curl -fsSL -o ~/instant-zsh.zsh https://gist.github.com/romkatv/8b318a610dc302bdbe1487bb1847ad99/raw
#
@romkatv
romkatv / two-line-prompt.zsh
Last active February 17, 2024 11:00
Two-line ZSH prompt
# Example of two-line ZSH prompt with four components.
#
# top-left top-right
# bottom-left bottom-right
#
# Components can be customized by editing set-prompt function.
#
# Installation:
#
# (cd && curl -fsSLO https://gist.githubusercontent.com/romkatv/2a107ef9314f0d5f76563725b42f7cab/raw/two-line-prompt.zsh)
@romkatv
romkatv / prompt-wave.zsh
Created March 3, 2024 15:14
Zsh prompt wave
function metronome() {
local -rF tick_sec=0.3
while true; do
zselect -t $((int(ceil(tick_sec * 100))))
print 2>/dev/null || break
done
}
function update-prompt() {
local -ri period=7
function prompt_my_msa() {
p10k segment -e -t '$my_msa_content' -b black -f white
(( $+my_msa_content )) && return
typeset -g my_msa_content
local -r msa=~/minimal_spectrum_analyzer/build/analyzer
[[ -x $msa ]] || return
local fd
exec {fd}< <("$msa" --line_feed LF -a off -c 16 0<&- 2>&- &!) || return
@romkatv
romkatv / srand32.zsh
Last active May 4, 2024 05:04
srand32.zsh
# Returns a random 32-bit number.
# If /dev/urandom is cryptographically secure, so is srand32.
#
# If zsh is compiled with 64-bit number support, the result
# is non-negative. Otherwise it may be negative and the value
# is governed by the rules of unsigned-to-signed conversion in C.
#
# Examples:
#
# % print -r -- $(( srand32() ))
@romkatv
romkatv / Pure style for Powerlevel10k.md
Last active May 4, 2024 16:34
Pure style for Powerlevel10k

Powerlevel10k can generate the same prompt as Pure.

pure

Installation

git clone https://github.com/romkatv/powerlevel10k.git ~/powerlevel10k
echo 'source ~/powerlevel10k/powerlevel10k.zsh-theme' >>! ~/.zshrc