ED:
#!/usr/bin/env bash

# ED: change between $EDITORs
#
# Toggles your $EDITOR between your different editors.
# To install add `source path/to/ED.sh` to your shell's rc file.

ED() {
	local new
	if [[ "$1" != "" ]]; then
		new="$1"
	elif [[ $EDITOR == "vim" ]]; then
		new="emacs"
	else
		new="vim"
	fi

	echo "Setting \$EDITOR to $new"
	EDITOR=$new
}
ed:
#!/usr/bin/env bash

# ed: edit files with your $EDITOR
#
# Opens a file with your $EDITOR. If no argument is given then it opens the
# whole directory into a tree view, or if there is only a few files in the
# current directly then it just opens all of them.

if [[ "$@" == "" ]]; then
	if [[ $(ls -l | wc -l) -le 5 ]]; then
		$EDITOR ./*
	else
		$EDITOR .
	fi
else
	$EDITOR "$@"
fi