Skip to content

Instantly share code, notes, and snippets.

Avatar

Roman Perepelitsa romkatv

View GitHub Profile
@romkatv
romkatv / migrate-zsh-dotfiles.zsh
Last active Apr 10, 2022
Migrate zsh dotfiles from the home directory to another directory on the same machine
View migrate-zsh-dotfiles.zsh
# This command moves your zsh dotfiles (.zshrc, .zsh_history, etc.)
# from the home directory to ~/.config/zsh. It's been verified to
# work correctly if you are using zsh4humans. With other zsh configs
# your mileage may vary.
#
# How to:
#
# 1. Close all terminals except one.
# 2. Copy-paste this command into the only remaining terminal.
() {
@romkatv
romkatv / run-command.zsh
Last active Dec 10, 2021
Zsh function to run a command and capture its status, stdout and stderr
View run-command.zsh
# 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 / srand32.zsh
Last active Jan 17, 2021
srand32.zsh
View 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() ))
View p10k-bubbles.zsh
# Generated by Powerlevel10k configuration wizard on 2020-04-12 at 20:28 CEST.
# Based on romkatv/powerlevel10k/config/p10k-classic.zsh, checksum 30399.
# Wizard options: nerdfont-complete + powerline, small icons, classic, unicode, dark,
# 24h time, round separators, round heads, round tails, 2 lines, disconnected, no frame,
# sparse, many icons, concise, instant_prompt=quiet.
# Type `p10k configure` to generate another config.
#
# Config for Powerlevel10k with classic powerline prompt style. Type `p10k configure` to generate
# your own config based on it.
#
@romkatv
romkatv / README.md
Created Feb 14, 2020
Anecdote: gitstatus performance in a large Git repository
View README.md
  • Source: starship/starship#921.
  • Timing for git status: between 12 and 15 seconds.
    • Method of timing: likely time git status.
    • Reported time: probably wall time.
    • Cold or hot: unknown.
  • Timing for gitstatus_query: between 3 and 4 seconds.
    • Method of timing: unknown.
    • Reported time: probably wall time.
    • Cold or hot: unknown.
  • gitstatusd command-line arguments: unknown.
@romkatv
romkatv / Advent of Code 2019.md
Last active Dec 31, 2019
Advent of Code 2019
View Advent of Code 2019.md
@romkatv
romkatv / omz-prompt-bench.zsh
Last active Nov 30, 2019
Measure zsh prompt latency with various themes
View omz-prompt-bench.zsh
# Measure zsh prompt latency with various themes:
#
# 1. Run the docker command.
# 2. Type `ZSH_THEME=XXX exec zsh` where `XXX` is a theme name such as
# `agnoster` or `powerlevel10k/powerlevel10k`.
# 3. Type `zsh-prompt-benchmark` and press and hold ENTER until benchmark
# results appear. It takes about 10 seconds.
docker run -e TERM -it --rm archlinux/base bash -uexc '
pacman -Sy --noconfirm zsh git
git clone --depth=1 https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
View 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 / monochrome-powerlevel10k.md
Last active Jan 13, 2022
monochrome-powerlevel10k.zsh
View monochrome-powerlevel10k.md

Here's how it looks with White on Black color scheme:

white-on-black

Tango Dark

tango-dark

Solarized Light

@romkatv
romkatv / instant-zsh.zsh
Last active Nov 24, 2021
Make zsh start INSTANTLY with this one weird trick
View instant-zsh.zsh
# 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
#