O'Reilly logo

Korn Shell: Unix and Linux Programming Manual, Third Edition, The by Anatole Olczak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required