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


# If there is an ssh connections, current machine name.
function __sf_section_host -d "Display the current hostname if connected over SSH"

	# ------------------------------------------------------------------------------
	# Configuration
	# ------------------------------------------------------------------------------

	__sf_util_set_default SPACEFISH_HOST_SHOW true
	__sf_util_set_default SPACEFISH_HOST_PREFIX "at "
	__sf_util_set_default SPACEFISH_HOST_SUFFIX $SPACEFISH_PROMPT_DEFAULT_SUFFIX
	__sf_util_set_default SPACEFISH_HOST_COLOR blue
	__sf_util_set_default SPACEFISH_HOST_COLOR_SSH green

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

	[ "$SPACEFISH_HOST_SHOW" = false ]; and return

	if test "$SPACEFISH_HOST_SHOW" = "always"; or set -q SSH_CONNECTION;

		# Determination of what color should be used
		set -l host_color
		if set -q SSH_CONNECTION;
			set host_color $SPACEFISH_HOST_COLOR_SSH
		else
			set host_color $SPACEFISH_HOST_COLOR
		end

		__sf_lib_section \
			$host_color \
			$SPACEFISH_HOST_PREFIX \
			(hostname) \
			$SPACEFISH_HOST_SUFFIX
		end
end