0

When I run terminal within Pathfinder, typing exit is just a mistake (blocks the Window for nothing).

How may I

  1. Figure out I'm in Pathfinder
  2. Suppress exit in Zshell if I am in Pathfinder?
Dan Rosenstark
  • 6,388
  • 13
  • 59
  • 95
  • The hard part here is 1. First thing I would do is compare the output of `env | sort` between when it is run from within Pathfinder's terminal and some other terminal. There could be some environment variables that are only set by Pathfinder or set to a value that indicates Pathfinder. – Adaephon Mar 12 '15 at 11:46
  • @Adaephon what if we ignore #1... I could run a script with "Run command:" on startup (Path Finder preferences).... what command would I run? – Dan Rosenstark Mar 12 '15 at 14:42
  • You can disable `exit` by running `alias exit=` inside the shell or the shells configuration. If this works with "Run command" depends on how the command there is executed. – Adaephon Mar 12 '15 at 15:23
  • This actually works! http://i.imgur.com/JkCY0g8.png If you want to place an answer, please, I can mark it as accepted etc. THANKS! – Dan Rosenstark Mar 12 '15 at 16:29

1 Answers1

2

exit is a built-in of zsh. The easiest way to disable it - or any other command - is to create an alias with the same name that does nothing:

alias exit=

or maybe prints a short message to be a bit more informative:

alias exit='echo "Sorry, but I cannot do that."'

To run this automatically for shell sessions inside Pathfinder, set it in the "Run command" field in Pathfinder's settings.


Note: an alias is always scoped to the session of zsh in which it was defined. It will not carry over to any other zsh session you start from there, so exit will still work normally these other sessions. Also, aliases set in a child session of zsh will not carry over to the parent session.

That also means that you cannot just run a script to set aliases or make any other changes to the current shell environment. But you can use the source command to execute commands from a script in the current shell session.

Instead of setting alias exit= in "Run command" you can then set the following (as noted in a comment by the OP):

source /path/to/some/script_with_settings

with /path/to/some/script_with_settings containing:

alias exit=

possibly among other things.

Adaephon
  • 5,634
  • 3
  • 20
  • 25