Skip to content

Commit 459e2b4

Browse files

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

tmux-hints.sh

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,55 @@
1414
# though loads of txt/md notes.
1515
#
1616

17+
export PATH=/usr/local/bin:/bin:/usr/bin
18+
tag=${0##*/}
19+
20+
say () { echo "$tag: $@" ; }
21+
die () { say "FATAL: $@" ; exit 1; }
22+
23+
# sanity check
24+
case "$TMUX" in
25+
"") die "You need to be running tmux to use tmux-hints!" ;;
26+
*) ;;
27+
esac
28+
29+
30+
header_init="# $tag\n"
31+
1732
viewer="cat"
1833
extension=".txt"
1934
hint_path="$HOME/hints/"
2035
verbose=false
2136
quiet=false
22-
header_init="# tmux-hints.sh\n"
2337
repo="https://github.com/hozza/tmux-hints"
24-
version="0.2"
38+
version="0.3"
39+
40+
# help doc
41+
help () {
42+
echo -e "$header_init"
43+
44+
cat <<EndHelp
45+
$tag version $version usage:
46+
47+
Synopsis:
48+
49+
$tag [SHORT-OPTION]
50+
51+
Option [default] Description:
52+
53+
-h this help text
54+
-o [cat] hint file opener e.g. less|markdown
55+
-p [$HOME/hints/] /path/to/hint/files/
56+
-q quiet mode, hint only
57+
-v verbose
58+
-x [txt] hint file extension
59+
60+
By default, it will try to cat $HOME/hints/tmux.txt, make sure this exists! :)
61+
For more help visit $repo
62+
EndHelp
63+
}
64+
65+
2566

2667
while getopts 'o:x:p:vhq' flag; do
2768
case "${flag}" in
@@ -30,10 +71,7 @@ while getopts 'o:x:p:vhq' flag; do
3071
p) hint_path="${OPTARG}" ;;
3172
v) verbose=true ;;
3273
q) quiet=true ;;
33-
h)
34-
echo -e "$header_init\ntmux-hints.sh version $version Usage:\n\nSynopsis:\n\n\ttmux-hints.sh [SHORT-OPTION]\n\nOption [default] Description:\n\n\t-o\t[cat] hint file opener e.g. less|markdown\n\t-x\t[txt] hint file extension\n\t-p\t[$HOME/hints/] /path/to/hint/files/\n\t-v\tverbose\n\t-q\tquiet mode, hint only\n\t-h\tthis help text\n\nFor more help visit the repo: $repo"
35-
exit 2
36-
;;
74+
h) help; exit 2 ;;
3775
*) break ;;
3876
esac
3977
done
@@ -47,10 +85,10 @@ tmux set-option focus-events on
4785
tmux set-hook pane-focus-in "run 'echo #{pane_current_command} > $temp_file'"
4886

4987

50-
clear_term="\ec"
88+
clear_term="$(tput clear)"
5189
[ "$verbose" == true ] && clear_term=''
5290

53-
default="\nCreate a default hint file:\n\n"$hint_path"default"$extension"\n\nExit:\tCtrl+c\n\nUpdate:\t'git pull' in tmux-hint directory.\n\nHelp:\ttmux-hints.sh -h\n\nRepo:\t$repo\n"
91+
default="\nCreate a default hint file:\n\n"$hint_path"tmux"$extension"\n\nExit:\tCtrl+c\n\nUpdate:\t'git pull' in tmux-hint directory.\n\nHelp:\ttmux-hints.sh -h\n\nRepo:\t$repo\n"
5492

5593
# init
5694
if [ "$quiet" == true ]; then

0 commit comments

Comments
 (0)