summaryrefslogtreecommitdiff
path: root/.config/fisher/github.com/matchai/spacefish/functions/__sf_section_jobs.fish
blob: cfa91e2a0f00907ebf6d8bca554c7c829544e218 (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
# Jobs
#

function __sf_section_jobs -d "Show icon, if there's a working jobs in the background."
	# ------------------------------------------------------------------------------
	# Configuration
	# ------------------------------------------------------------------------------

	__sf_util_set_default SPACEFISH_JOBS_SHOW true
	__sf_util_set_default SPACEFISH_JOBS_PREFIX ""
	__sf_util_set_default SPACEFISH_JOBS_SUFFIX " "
	__sf_util_set_default SPACEFISH_JOBS_SYMBOL ✦
	__sf_util_set_default SPACEFISH_JOBS_COLOR blue
	__sf_util_set_default SPACEFISH_JOBS_AMOUNT_PREFIX ""
	__sf_util_set_default SPACEFISH_JOBS_AMOUNT_SUFFIX ""
	__sf_util_set_default SPACEFISH_JOBS_AMOUNT_THRESHOLD 1

	# ------------------------------------------------------------------------------
	# Section
	# ------------------------------------------------------------------------------

	[ $SPACEFISH_JOBS_SHOW = false ]; and return

	set jobs_amount (jobs | wc -l | xargs) # Zsh had a much more complicated command.

	if test $jobs_amount -eq 0
		return
	end

	if test $jobs_amount -le $SPACEFISH_JOBS_AMOUNT_THRESHOLD
		set jobs_amount ''
		set SPACEFISH_JOBS_AMOUNT_PREFIX ''
		set SPACEFISH_JOBS_AMOUNT_SUFFIX ''
	end

	set SPACEFISH_JOBS_SECTION "$SPACEFISH_JOBS_SYMBOL$SPACEFISH_JOBS_AMOUNT_PREFIX$jobs_amount$SPACEFISH_JOBS_AMOUNT_SUFFIX"

	__sf_lib_section \
		$SPACEFISH_JOBS_COLOR \
		$SPACEFISH_JOBS_PREFIX \
		$SPACEFISH_JOBS_SECTION \
		$SPACEFISH_JOBS_SUFFIX
end