-
Notifications
You must be signed in to change notification settings - Fork 10
/
gist.sh
61 lines (53 loc) · 2.32 KB
/
gist.sh
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
#!/bin/bash
PREF_DIR="$HOME/Library/Application Support/Alfred 2/Workflow Data/pjkh.gist"
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
source functions.sh
load_settings
parse_cli $*
if [[ -z "$token" && "$action" != "configure" && "$action" != "help" ]]; then
echo "You need to setup and configure Gist. Type 'gist help' for details."
exit
fi
case $action in
help)
open "https://github.com/phallstrom/AlfredGist#usage"
exit
;;
configure)
newvalue=$(pbpaste | head -1 | iconv -c -t ASCII)
if [[ -z "$key" && -z "$val" ]]; then
echo_start_items
if [[ "$public" = "true" ]]; then
echo_item "gist_config_public" "configure public false" "yes" "" "Your gists are public by default." "Select to change the default to private."
else
echo_item "gist_config_public" "configure public true" "yes" "" "Your gists are private by default." "Select to change default to public."
fi
if [[ "$copy_url" = "true" ]]; then
echo_item "gist_config_copy_url" "configure copy_url false" "yes" "" "The Gist URL is copied to your clipboard." "Select to not copy the URL."
else
echo_item "gist_config_copy_url" "configure copy_url true" "yes" "" "The Gist URL is not copied to your clipboard." "Select to copy the URL."
fi
if [[ "$open_url" = "true" ]]; then
echo_item "gist_config_open_url" "configure open_url false" "yes" "" "The Gist URL is opened in a browser." "Select to not open the URL."
else
echo_item "gist_config_open_url" "configure open_url true" "yes" "" "The Gist URL is not opened in a browser." "Select to open the URL."
fi
echo_item "gist_config_token" "configure token $newvalue" "yes" "" "Your API access token is '$token'" "Select to change to '$newvalue'."
echo_item "gist_config_server" "configure server $newvalue" "yes" "" "Your API server is '$server'" "Select to change to '$newvalue'."
echo_item "gist_config_shared_config_dir" "configure shared_config_dir $newvalue" "yes" "" "Your shared config directory is '$shared_config_dir'" "Select to change to '$newvalue'."
echo_end_items
exit
fi
set_option "$key" "$val"
save_settings
echo "Gist configuration has been updated."
exit
;;
gist)
create_gist
;;
*)
echo "ERROR: Unknown action '$action'."
;;
esac