{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Aliases (PowerShell users, skip this section)\n", "\n", "Since we saw that `rm` is a wrecking ball, we should temper it using the `-i` flag. For safety, we would like `rm` to *always* ask us about deletion. We can instruct `bash` or `zsh` to do this for us by creating an **alias**.\n", "\n", " alias rm=\"rm -i\"\n", "\n", "After executing this, any time we use `rm`, our shell will instead execute `rm -i`, thereby keeping us out of trouble.\n", "\n", "Another useful alias, often implemented by default, is to make `ls` list things more prettily.\n", "\n", "For macOS:\n", "\n", " alias ls=\"ls -FG\"\n", " \n", "For Linux:\n", "\n", " alias ls=\"ls -F --color\"\n", "\n", "The `-F` flag makes `ls` put a slash at the end of directories. This helps us tell the difference between files and directories. The `-G` or `--color` flag enables coloring of the output, also useful for differentiating file types.\n", "\n", "Furthermore, if you decide to use `rsync`, you may want to alias `rsync -avzP` to `rsync`:\n", " \n", " alias rsync=\"rsync -avzP\"\n", " \n", "Aliases will usually be forgotten when you close the current terminal. To make them persistent, add the command to `~/.bashrc` (on most Linux or old macOS) or `~/.zshrc` (on macOS). If these files do not exist, you can create them. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "\n", "*Copyright note: In addition to the copyright shown below, this recitation was developed based on materials from Axel Müller.*" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.9.13" } }, "nbformat": 4, "nbformat_minor": 4 }