Skip to content

Instantly share code, notes, and snippets.

View lebensterben's full-sized avatar
🤌
Never half-ass two things, whole-ass one thing.

Lucius Hu lebensterben

🤌
Never half-ass two things, whole-ass one thing.
View GitHub Profile

Keybase proof

I hereby claim:

  • I am lebensterben on github.
  • I am doctorhu (https://keybase.io/doctorhu) on keybase.
  • I have a public key ASCqlYgp9MYT0PG2_mQlVjNw0ctqsonHMYdTmbhQqJDWzQo

To claim this, I am signing this object:

@lebensterben
lebensterben / colortest
Last active June 18, 2019 00:59
[DEPRECATED ]A simple zsh function to output term colors
## color-test
colortest () {
colortest_usage () {
echo -e "Usage: colortest [[-v|--verbose] | [-a|--all] | [-h|--help]]\n\nPrint out colors available in this terminal emulator. The default output is a short list of colors. If -v or --verbose is specified, a table containing all combination of background and foreground colors is displayed. Alternatively, if -a or -all is specified, then both short list and the detailed table would be displayed.\n\nNote that there should be no argument to this programme.\n -v, --verbose\t displays a table with detailed table of combinations of colors.\n -a, --all \t displays both brief and detailed results.\n -h, --help \t displays this help."
}
if [[ "$#" > 1 ]]; then
echo -e "$0: Error(1): At most one flag is allowed." >&2 | logger
colortest_usage
@lebensterben
lebensterben / strace
Created February 28, 2019 01:12
strace -f gpg --card-status &> strace
execve("/usr/bin/gpg", ["gpg", "--card-status"], 0x7ffdc48d8000 /* 88 vars */) = 0
brk(NULL) = 0x22f0000
arch_prctl(0x3001 /* ARCH_??? */, 0x7fff89e59800) = -1 EINVAL (Invalid argument)
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/var/cache/ldconfig/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3</var/cache/ldconfig/ld.so.cache>
fstat(3</var/cache/ldconfig/ld.so.cache>, {st_mode=S_IFREG|0644, st_size=251626, ...}) = 0
mmap(NULL, 251626, PROT_READ, MAP_PRIVATE, 3</var/cache/ldconfig/ld.so.cache>, 0) = 0x7f7d26dba000
close(3</var/cache/ldconfig/ld.so.cache>) = 0
openat(AT_FDCWD, "/usr/lib64/haswell/libz.so.1", O_RDONLY|O_CLOEXEC) = 3</usr/lib64/haswell/libz.so.1.2.11.1-motley>
read(3</usr/lib64/haswell/libz.so.1.2.11.1-motley>, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0`1\0\0\0\0\0\0"..., 832) = 832
@lebensterben
lebensterben / 50-prompt.sh
Created June 12, 2019 08:09
50-prompt.sh
# Set prompt and title (for interactive shells only)
if [ "$(expr $- : '.*i')" -ne 0 ]; then
# this works for sh and bash
if [ -z "$ZSH_VERSION" ]; then
# first get exit code of last command, and set colors
PS1="\$(\
EXIT=\"\$?\" ; \
BLUE=\"\[\e[38;5;39m\]\" ; \
RED=\"\[\e[31m\]\" ; \
#-*- mode: shell-script -*-
# list Clear Linux clone_* targets
#clr_ls() {
if [[ $# -ne 0 ]]; then
make_ls | command grep 'clone_' | sort | uniq -u | command grep $1
else
make_ls | command grep 'clone_' | sort | uniq -u
fi
#}
#-*- mode: shell-script -*-
# lscolor () {
emulate -RL zsh
setopt extendedglob
local myname usage opt lscolor_short
local -a lscolor_long
local b f s i
#-*- mode: shell-script -*-
# Get Unicode Representation of Given String(s)
#2utf() {
if [[ $# -eq 0 ]]; then
cat << EOF
Usage: to_unicode String [...]
Print the unicode representation of one or multiple strings.
At least one argument should be given, and if multiple arguments are given, they should be seperated by whitespaces.
Examples:
#-*- mode: shell-script -*-
# Print Strings Given Their Unicode Representation
#from_unicode() {
if [[ $# -eq 0 ]]; then
cat << EOF
Usage: from_unicode Unicode [...]
Print one or multiple strings according to their unicode representation.
At least one argument should be given, and each argument shall be quoted if it contains whitespaces.
Examples:
#-*- mode: shell-script -*-
# list make targets
#make_ls () {
make -qp | awk -F':' '/^[a-zA-Z0-9][^$#\/\t=]*:([^=]|$)/ {split($1,A,/ /);for(i in A)print A[i]}' | sort | uniq -u
#}
# -*- mode: shell-script -*-
# Reload ZSH shell
#reload () {
exec "${SHELL}" "$@"
#}