Skip to content

Instantly share code, notes, and snippets.

@Ipsum
Ipsum / screenshot
Created July 12, 2019 21:32
Screenshot script
#!/bin/sh
t=$(date +%s)
filename="screenshot-"$t".jpg"
import /home/dtyler/Screenshots/$filename
@Ipsum
Ipsum / config
Created July 12, 2019 21:30
vimb
nnoremap ga :sh bash -c "gcalcli --nocolor --nostarted agenda \"`date`\""<CR>
nnoremap gt :sh! xdotool key --window $VIMB_XID ctrl+shift+l<CR><Esc>
nnoremap gT :sh! xdotool key --window $VIMB_XID ctrl+shift+h<CR><Esc>
nnoremap 1gt :sh! xdotool key --window $VIMB_XID ctrl+1<CR><Esc>
nnoremap 2gt :sh! xdotool key --window $VIMB_XID ctrl+2<CR><Esc>
nnoremap 3gt :sh! xdotool key --window $VIMB_XID ctrl+3<CR><Esc>
nnoremap 4gt :sh! xdotool key --window $VIMB_XID ctrl+4<CR><Esc>
nnoremap 5gt :sh! xdotool key --window $VIMB_XID ctrl+5<CR><Esc>
nnoremap 6gt :sh! xdotool key --window $VIMB_XID ctrl+6<CR><Esc>
nnoremap 7gt :sh! xdotool key --window $VIMB_XID ctrl+7<CR><Esc>
@Ipsum
Ipsum / hosts
Created July 12, 2019 21:10
hosts
[dtyler@wimpy systemd]$ ls
update-adblock-hosts updatehosts.service updatehosts.timer
[dtyler@wimpy systemd]$ cat *
#!/bin/sh
/bin/gethostszero
hosts-gen
[Unit]
Description=Update Hosts file for adblock
[Service]
@Ipsum
Ipsum / git-reattach
Last active May 20, 2022 19:41
Reattach git wrapper
#!/bin/sh
if [ $(git rev-parse --git-common-dir) = $(git rev-parse --git-dir) ]; then
echo "Trying to reattach from inside a non-worktree is not possible" 1>&2
echo "${PWD}"
exit 1
fi
if [ ! -z "$(git status --porcelain)" ]; then
echo "Working directory not clean, aborting" 1>&2
echo "${PWD}"
@Ipsum
Ipsum / git-detach
Last active May 20, 2022 19:33
Detach git wrapper
#!/bin/sh
if [ $(git rev-parse --git-common-dir) != $(git rev-parse --git-dir) ]; then
echo "Trying to detach from inside a worktree is not possible" 1>&2
echo "${PWD}"
exit 1
fi
branchname="${@}"
if [ -z $branchname ]; then
echo "No branch specified" 1>&2
@Ipsum
Ipsum / stats.sh
Created July 12, 2019 17:16
Turn numbers into stats
#!/bin/sh
# sum, data count, minimum datum, maximum datum, mean and median of a single column of numeric data
sort -n | awk '
BEGIN {
c = 0;
sum = 0;
}
$1 ~ /^[0-9]*(\.[0-9]*)?$/ {
a[c++] = $1;
sum += $1;
@Ipsum
Ipsum / git-prompt.sh
Created January 8, 2019 13:26
Git bash prompt
_git_branch() {
git symbolic-ref --short HEAD 2>/dev/null
}
git_branch() {
# Tweak branch displayed info here
branch=$(_git_branch)
branch="${branch#*-*-*}"
echo "${branch::12}"
}
git_status() {