aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <karel.koci@nic.cz>2017-08-15 10:37:49 +0200
committerKarel Kočí <karel.koci@nic.cz>2017-08-15 10:37:49 +0200
commitd4177b26ddef38c6773116c34dfa6cb59c368bb9 (patch)
treeab743db726542ea685d56bb852dca32c5a2f380d
parent629a867c5dff7c50a7cd0803957de4b9bbfae756 (diff)
downloadmyconfigs-d4177b26ddef38c6773116c34dfa6cb59c368bb9.tar.gz
myconfigs-d4177b26ddef38c6773116c34dfa6cb59c368bb9.tar.bz2
myconfigs-d4177b26ddef38c6773116c34dfa6cb59c368bb9.zip
Move some oneliners from scripts to functions
-rwxr-xr-xinstall3
-rwxr-xr-xlocal/bin/clip2
-rwxr-xr-xlocal/bin/xshot2
-rw-r--r--shellrc31
4 files changed, 31 insertions, 7 deletions
diff --git a/install b/install
index 30de1bb..b6a26db 100755
--- a/install
+++ b/install
@@ -89,9 +89,6 @@ if ask "Install desktop (i3..)"; then
inst config/i3blocks/ ~/.config/i3blocks
inst config/dunst/ ~/.config/dunst
inst local/bin/mxrandr ~/.local/bin/
- # Some small Xserver tools
- inst local/bin/clip ~/.local/bin/
- inst local/bin/xshot ~/.local/bin/
# Theme
inst gtk-2.0/gtkrc ~/.gtkrc-2.0
inst gtk-3.0/ ~/.config/gtk-3.0/
diff --git a/local/bin/clip b/local/bin/clip
deleted file mode 100755
index 1281090..0000000
--- a/local/bin/clip
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-xclip -selection clipboard
diff --git a/local/bin/xshot b/local/bin/xshot
deleted file mode 100755
index 90f91af..0000000
--- a/local/bin/xshot
+++ /dev/null
@@ -1,2 +0,0 @@
-#!/bin/sh
-import -window "$(xdotool selectwindow)" ~/xshot_$(date +%F_%H%M%S_%N).png
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
+}