[Home] Zsh logo

export

Zsh Wizard

Download export Return to Examples
  1. setopt magic_equal_subst # for `export foo=~/bar`
  2. function export() { EXPORT=${1%%\=*} ; typeset -Ux $* }
  3. function +() { eval builtin export ${EXPORT}=\$\{$EXPORT\}:\$1 }
  4. # now you can do
  5. #
  6. # export PATH=/home/$USER/bin/$OSTYPE # arch dependent binaries
  7. # + /home/$USER/bin # arch independent scripts
  8. # + /usr/local/bin # local apps
  9. # + /opt/gnu/bin # gnu tools
  10. # + ...
  11. #
  12. # or even stuff like:
  13. #
  14. # export PATH=~/bin/$OSTYPE # arch dependent binaries
  15. # + ~/bin # arch independent scripts
  16. # case $OSTYPE in
  17. # sun*)
  18. # + $OPENWINHOME/bin # openwindows applications
  19. # + /usr/ccs/bin # compiler tools
  20. # + /opt/bin # optional packages
  21. # ;;
  22. # *)
  23. # + /usr/bin/X11 # X11 applications
  24. # ;;
  25. # esac
  26. # + /usr/local/bin # local apps
  27. # + /opt/gnu/bin # gnu tools
  28. # + ...
  29. unfunction export +