-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.funcs
91 lines (76 loc) · 2.51 KB
/
.funcs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/usr/bin/env bash
# c00kiemon5ter ([email protected]) ~ under c00kiez License
# the prompt
prompt() {
s=$? && [ $s -eq 0 ] && sc="$fggrn" s="─" || sc="$fgred" s="─|$s|─"
g="$(git symbolic-ref --short HEAD 2>/dev/null)" && \
g="\[$fgwht\]:\[$bfgred\]$g\[$bfgylw\]$(git status -s \
| awk '!q&&$1=="??"{q="?"} !e&&$1!="??"{e=":±"} q&&e{exit} END{printf e q}')"
PS1="\n\[$bfgblk\]┐$sc\[$fggrn\]\w$g\n\[$bfgblk\]└\[$sc\]$s \[$normal\]"
unset g s sc
}
# display a random quote on top of every new shell
wazaaa() {
local qdb="$HOME/.archquotes" # quotes database
local arch="Arch" nix="Linux" # the logo
local say="$(shuf -n1 $qdb)" # pick a random quote
local spc="$(( COLUMNS - ${#arch} - ${#nix} ))"
clear # ohai, kthnxbye
printf "$mkbold$fgwht%s$bfgblu%s$fgwht%${spc}s$normal\n" "$arch" "$nix" "$say"
}
# cd helper
cd() {
{ [ -z "$1" ] && builtin cd "$HOME"; } || \
{ [ -d "$1" ] && builtin cd "$1"; } || \
{ [ -f "$1" ] && builtin cd "$(dirname "$1")"; } || \
builtin cd "$1"
}
# copy and follow
cpf() { cp "$@" && cd "$_"; }
# move and follow
mvf() { mv "$@" && cd "$_"; }
# make dir and follow
mkf() { mkdir -vp "$1" && cd "$_"; }
# funny quotes from bash.org @irc
bashfortune() {
curl -s http://bash.org/?random1 \
| grep -oE "<p class=\"quote\">.*</p>.*</p>" \
| grep -oE "<p class=\"qt.*?</p>" \
| sed -e 's/<\/p>/\n/g' -e 's/<p class=\"qt\">//g' -e 's/<p class=\"qt\">//g' \
| perl -ne 'use HTML::Entities;print decode_entities($_),"\n"' \
| head -1
}
# slow output
slow_output() { while IFS= read -r -N1; do printf "%c" "$REPLY"; sleep ${1:-.02}; done; }
# change terminal title
tname() { printf "%b" "\e]0;${1:-$TERM}\a"; }
# alternative clear
cls() { printf "%b" "\ec"; }
# pastebin
sprunge() {
curl -sF "sprunge=<${1:--}" 'http://sprunge.us' | tee -a /tmp/saved.urls \
| { [ -n "$DISPLAY" ] && xclip && xclip -o || cat; }
}
# a tree alternative
t() {
path="$(readlink -m "${1:-$PWD}")"
[[ -n $1 ]] && shift
find "$path" "$@" -print | sed "2,\$s;${path%/*}/;;;2,\$s;[^/]*/; |- ;g;s;- |; |;g"
}
irc() { while true; do notifiii.sh; done; }
ircon() {
[ -e "/tmp/.stunnel.pid" ] || stunnel "$HOME/.stunnel/stunnel.conf"
local passwd=
read -rsp "enter passwd: " passwd
freenode="$passwd" oftc="$passwd" connect.sh
unset passwd
spawnchannels.sh
irc
}
ircoff() {
ps -C sh -opid,cmd \
| awk 'index($3, "connect.sh") || index($3, "notifiii.sh") {print $1}' \
| xargs kill
}
d() { dtach -A ~/.term.sock -r winch bash; }
# vim: nospell