def setup_prompt(self,
	                 prompt_name,
	                 prefix='default',
	                 capture_exit_code=False,
	                 loglevel=logging.DEBUG):
		"""Use this when you've opened a new shell to set the PS1 to something
		sane. By default, it sets up the default expect so you don't have to
		worry about it and can just call shutit.send('a command').

		If you want simple login and logout, please use login() and logout()
		within this module.

		Typically it would be used in this boilerplate pattern::

		    shutit.send('su - auser', expect=shutit_global.shutit_global_object.base_prompt, check_exit=False)
		    shutit.setup_prompt('tmp_prompt')
		    shutit.send('some command')
		    [...]
		    shutit.set_default_shutit_pexpect_session_expect()
		    shutit.send('exit')

		This function is assumed to be called whenever there is a change
		of environment.

		@param prompt_name:         Reference name for prompt.
		@param prefix:              Prompt prefix. Default: 'default'
		@param capture_exit_code:   Captures the exit code of the previous
		                            command into a SHUTIT_EC variable. Useful
		                            for when we want to work out whether the
		                            login worked.
		@type prompt_name:          string
		@type prefix:               string
		"""
		shutit = self.shutit
		local_prompt = prefix + ':' + shutit_util.random_id() + '# '
		shutit.expect_prompts[prompt_name] = local_prompt
		# Set up the PS1 value.
		# Override the PROMPT_COMMAND as this can cause nasty surprises in the
		# output, and we need a short pause before returning the prompt to
		# overcome an obscure bash bug (cf.
		# https://github.com/pexpect/pexpect/issues/483).
		# Set the cols value, as unpleasant escapes are put in the output if the
		# input is > n chars wide.
		# checkwinsize is required for similar reasons.
		# The newline in the expect list is a hack. On my work laptop this line hangs
		# and times out very frequently. This workaround seems to work, but I
		# haven't figured out why yet - imiell.

		# Split the local prompt into two parts and separate with quotes to protect against the expect matching the command rather than the output.
		shutit.log('Setting up prompt.', level=logging.DEBUG)
		send_str = ''
		if capture_exit_code:
			send_str = r' SHUTIT_EC=$? && '
		send_str += """ export PS1_""" + str(prompt_name) + """=$PS1 && PS1='""" + str(local_prompt[:2]) + "''" + str(local_prompt[2:]) + """' && PROMPT_COMMAND=""" + shutit_global.shutit_global_object.prompt_command
		self.send(ShutItSendSpec(self,
		                         send=send_str,
		                         expect=['\r\n' + shutit.expect_prompts[prompt_name]],
		                         fail_on_empty_before=False,
		                         echo=False,
		                         loglevel=loglevel,
		                         ignore_background=True))
		# Set default expect to new.
		shutit.log('Resetting default expect to: ' + shutit.expect_prompts[prompt_name], level=loglevel)
		self.default_expect = shutit.expect_prompts[prompt_name]

		# Sometimes stty resets to 0x0 (?), so we must override here.
		self.send(ShutItSendSpec(self, send=" stty cols 65535", echo=False, check_exit=False, loglevel=loglevel, ignore_background=True))
		self.send(ShutItSendSpec(self, send=" stty rows 65535", echo=False, check_exit=False, loglevel=loglevel, ignore_background=True))
		# Avoid dumb terminals
		self.send(ShutItSendSpec(self, send=""" if [ $TERM=dumb ];then export TERM=xterm;fi""", echo=False, check_exit=False, loglevel=loglevel, ignore_background=True))

		# Get the hostname
		# Lack of space after > is deliberate to avoid issues with prompt matching.
		hostname = shutit.send_and_get_output(""" if [ $(echo $SHELL) == '/bin/bash' ]; then echo $HOSTNAME; elif [ $(command hostname 2>/dev/null) != '' ]; then hostname -s 2>/dev/null; fi""", echo=False, loglevel=logging.DEBUG)
		local_prompt_with_hostname = hostname + ':' + local_prompt
		shutit.expect_prompts[prompt_name] = local_prompt_with_hostname
		self.default_expect = shutit.expect_prompts[prompt_name]
		# Set up a shell expect to check whether we're still in a shell later.
		self.shell_expect = self.default_expect

		# Split the local prompt into two parts and separate with quotes to protect against the expect matching the command rather than the output.
		self.send(ShutItSendSpec(self,
		                         send=""" PS1='""" + shutit.expect_prompts[prompt_name][:2] + "''" + shutit.expect_prompts[prompt_name][2:] + """'""",
		                         echo=False,
		                         loglevel=loglevel,
		                         ignore_background=True))

		# Set up history the way shutit likes it.
		self.send(ShutItSendSpec(self,
		                         send=' command export HISTCONTROL=$HISTCONTROL:ignoredups:ignorespace',
		                         echo=False,
		                         loglevel=loglevel,
		                         ignore_background=True))

		# Ensure environment is set up OK.
		_ = self.init_pexpect_session_environment(prefix)
		return True
Use this when you've opened a new shell to set the PS1 to something
		sane. By default, it sets up the default expect so you don't have to
		worry about it and can just call shutit.send('a command').

		If you want simple login and logout, please use login() and logout()
		within this module.

		Typically it would be used in this boilerplate pattern::

		    shutit.send('su - auser', expect=shutit_global.shutit_global_object.base_prompt, check_exit=False)
		    shutit.setup_prompt('tmp_prompt')
		    shutit.send('some command')
		    [...]
		    shutit.set_default_shutit_pexpect_session_expect()
		    shutit.send('exit')

		This function is assumed to be called whenever there is a change
		of environment.

		@param prompt_name:         Reference name for prompt.
		@param prefix:              Prompt prefix. Default: 'default'
		@param capture_exit_code:   Captures the exit code of the previous
		                            command into a SHUTIT_EC variable. Useful
		                            for when we want to work out whether the
		                            login worked.
		@type prompt_name:          string
		@type prefix:               string