From d4177b26ddef38c6773116c34dfa6cb59c368bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Ko=C4=8D=C3=AD?= Date: Tue, 15 Aug 2017 10:37:49 +0200 Subject: Move some oneliners from scripts to functions --- shellrc | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) (limited to 'shellrc') diff --git a/shellrc b/shellrc index be99e18..1faa936 100644 --- a/shellrc +++ b/shellrc @@ -4,6 +4,9 @@ # Continue only if this is interactive shell [[ $- != *i* ]] && return +################################################################################# +# Aliases + if [ "$(uname -s)" = "FreeBSD" ]; then alias ls='ls -G' else @@ -42,8 +45,36 @@ if pidof systemd >/dev/null 2>/dev/null; then alias ujrn='jrn --user' fi +################################################################################# +# Utility functions + +# Generate random password (optionally takes length of password as first argument) genpasswd() { local l=$1 if [ "$l" = "" ]; then l=16; fi tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs } + +# Clip stdin to clipboard +clip() { + xclip -selection clipboard +} + +# Clip current HEAD hash to clipboard +gitclip() { + git rev-parse HEAD | clip +} + +# Make screenshot +xshot() { + import -window "$(xdotool selectwindow)" ~/xshot_$(date +%F_%H%M%S_%N).png +} + +# Run given command every second +dorepeat() { + while true; do + "$@" + sleep 1 + echo + done +} -- cgit v1.2.3