Appendix B. Sample Environment File

This appendix contains a sample environment file. It sets the global functions, aliases, and prompt variable.

				#
				#     Sample env File
				#
				# Function md - make a directory and _cd to it
				function md {
				mkdir $1 && _cd $1
				}
				# Set up the echo alias
				alias -x echo='print -'
				# Set temporary prompt variable to the command number
				# followed by a colon
				PS0='!:'
				# Function _cd - changes directories, then sets the
				# command prompt to: "command-number:pathname>"
				function _cd {
				if (($# == 0))
				then
				'cd'
				PS1="$PS0$PWD> "
				fi
				if (($# == 1))
				then
				'cd' $1
				PS1="$PS0$PWD> "
				fi
				if (($# == 2))
				then
				'cd' $1 $2
				PS1="$PS0$PWD> "
				fi
				}
				# Alias the cd command to the _cd function
				alias -x cd=_cd
				# Export the _cd and md functions
				typeset -fx _cd ...

Get Korn Shell: Unix and Linux Programming Manual, Third Edition, The now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.