QuestionsCategory: BIOSTARAsking before deleting
pastrand@nih.gov asked 6 months ago

Hi, during the last session the instructor showed that her Terminal would confirm before deleting a directory or file.  I thought the instructions for how to set up our environment to do the same were going to be posted here.
Thanks for your help
Diana

1 Answers
tillodc@nih.gov Staff answered 6 months ago

Hi Diana,

After you have done Part 1 of the computer set up described in the biostar handbook (https://www.biostarhandbook.com/computer-setup.html#computer-setup) the book has instructions for setting up the terminal here: https://www.biostarhandbook.com/terminal-init.html#terminal-init

Following the instructions on this page will get your environment set up such that the commands rm, cp, mv, will prompt before overwriting files.

Basically, this step creates two files that are processed each time you initialize (open) your shell/terminal.  In this case, one of the files (.bashrc) is the one that has the settings (also known as aliases)  to make the mv/rm/cp  commands always ask before overwriting files.  If you open the file ~/.bashrc in a text editor, you will find the following:

alias rm='rm -i'

alias mv='mv -i'

alias cp='cp -i'

Details about customizing your bash settings can also be found in the biostar handbook:  https://www.biostarhandbook.com/bash-profile.html#bash-profile