0

I have work multiple directory location and sometime delete directory which should not be deleted.

Is it possible to run pwd command before execute any command. and if I remove any file should I have warning or any message info

Blisskarthik
  • 1,246
  • 8
  • 20
user765443
  • 1,856
  • 7
  • 31
  • 56
  • http://stackoverflow.com/questions/4585397/bash-run-some-command-before-or-after-every-command-entered-from-console – Luca Davanzo Jul 08 '14 at 09:25

2 Answers2

1

To receive warning use -i option of rm:

$ rm -i test.file

Instead of running pwd before any command just put current directory path into your prompt. Add \w to $PS1 wariable. For example set it like this:

PS1="[\w]\$ "
Nykakin
  • 8,657
  • 2
  • 29
  • 42
0

Another solution, is to create an alias like this:

alias rm="pwd; /bin/rm -rfi"

With '-i' option you have to confirm the removing.

If you want that alias is loaded on startup you can add on the bottom of file:

~/.bashrc
Luca Davanzo
  • 21,000
  • 15
  • 120
  • 146