summaryrefslogtreecommitdiff
path: root/install-fish-integration.fish
blob: 90024d89be43779642c8e545e35372f2d8723689 (plain)
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
#!/usr/bin/env fish

set -l fish_config_dir (set -q XDG_CONFIG_HOME; and echo "$XDG_CONFIG_HOME/fish"; or echo "$HOME/.config/fish")
set -l fish_conf_d "$fish_config_dir/conf.d"
set -l integration_file "$fish_conf_d/timesamurai.fish"

echo "Installing timesamurai fish shell integration..."

# Create fish config directory if it doesn't exist
if not test -d "$fish_conf_d"
    mkdir -p "$fish_conf_d"
    echo "Created directory: $fish_conf_d"
end

# Write the integration file
echo "\
function timesamurai_prompt -d \"Display timesamurai timesamurai_status in the prompt\"
    if command -v timesamurai >/dev/null
        set -l timesamurai_status (timesamurai prompt)
        if test -n \"\$timesamurai_status\"
            set -l icon (string sub -l 1 -- \"\$timesamurai_status\")
            set -l time (string sub -s 2 -- \"\$timesamurai_status\")
            if test \"\$icon\" = \"▶\"
                set_color green
            else
                set_color yellow
            end
            printf '%s' \"\$icon\"
            set_color normal
            printf ' %s' \"\$time\"
        end
    end
end

complete -c timesamurai -n __fish_use_subcommand -a start -d \"Start the timer\"
complete -c timesamurai -n __fish_use_subcommand -a stop -d \"Stop the timer\"
complete -c timesamurai -n __fish_use_subcommand -a pause -d \"Pause the timer\"
complete -c timesamurai -n __fish_use_subcommand -a continue -d \"Continue the timer\"
complete -c timesamurai -n __fish_use_subcommand -a cont -d \"Continue the timer\"
complete -c timesamurai -n __fish_use_subcommand -a status -d \"Show the timer status\"
complete -c timesamurai -n __fish_use_subcommand -a reset -d \"Reset the timer\"
complete -c timesamurai -n __fish_use_subcommand -a track -d \"Save time with description\"
complete -c timesamurai -n __fish_use_subcommand -a live -d \"Show the live timer\"
complete -c timesamurai -n __fish_use_subcommand -a prompt -d \"Show the prompt status\"

# Font completions for live mode
complete -c timesamurai -n \"__fish_seen_subcommand_from live\" -s f -l font -d \"Font style\" -a \"doom mono12 rebel ansi ansiShadow\"
" > "$integration_file"

echo "Created: $integration_file"
echo ""
echo "Installation complete!"
echo ""
echo "To display timesamurai in your prompt, add this to your fish_prompt or fish_right_prompt:"
echo ""
echo "  function fish_prompt"
echo "      # ... your existing prompt ..."
echo "      printf '%s ' (timesamurai_prompt)"
echo "  end"
echo ""
echo "Restart your fish shell or run 'source $integration_file' to apply changes."