![]() ![]() Try to correct typos when auto-completing directory names. Save multi-line commands in the shell history as single entries, rather than an entry per line. Show the status of stopped and running jobs before exiting the shell. The shell will try to fix typos to the cd command. Some of the most useful options are: OptionĮnter a directory name as a command and the shell will cd to it.Īllows you to cd into a variable, such as repos=~/repos cd repos You can list the options available to set by running shopt -p, or searching the man bash page for shopt. You can set an option using the -s ( set option) flag and unset an option with the -u ( unset option) flag. ![]() This option allows you to enter the name of a directory as if it was a command, when you press 'enter' the shell will cd into the directory. In this example we use the shopt ( set shell option) command to set the autocd option. If you find yourself typing the same series of keystrokes again and again, you might want to add some aliases to your configuration file: Let's see a few examples of what you might add to your ~/.bashrc. You can add any commands you like to the ~/.bashrc file, these commands will be run when the shell starts up. Now let's look at some of the common features you might configure in the ~/.bashrc file. Users can modify this to suit their preferences. This exactly the sort of configuration that makes sense to keep in the ~/.bashrc file. For example, the la alias is a shorthand for ls -A, which can save a few keystrokes. Later on, we can see that some aliases are defined, for user convenience. Some variables are set, such as HISTSIZE (the number of commands to store in the history), we also set some options using the shopt ( set shell option flag). The next section of the file sets up some of the configuration for the history features of the shell. If we used exit instead then the shell would close, which is definitely not what we want! If you need a reminder on sourcing, check Chapter 18 - Shell Script Essentials. It's very important to understand that this file is sourced by the shell - so we have to use return if we want to stop processing it. There is also a file that is normally at /etc/bash.bashrc that is used to configure Bash for all users.Īgain - this is a common convention for Unix and Linux systems - there is a 'global' configuration file that is used for all users, as well as a 'user' configuration file in the user's home directory that the user can edit to personalise things for themselves. The ~/.bashrc file is in your home directory - this means that it is your personal Bash configuration file. ![]() For example, the ~/.vimrc run commands file is loaded by the vim program when it starts. Many tools on Unix and Linux have files that end in 'rc' that are loaded when a program starts up. This is a convention from the early days of Unix. The 'RC' in the file name stands for 'run commands' (sometimes people will also refer to this as 'run configuration'). ![]() This is one of the 'shell startup' files. When an interactive shell starts, one of the operations it performs is to run all of the commands in the file ~/.bashrc. An interactive shell is one that is connected to your keyboard and screen. When you log into a machine using the shell, or start a shell program in a terminal emulator like the Gnome Terminal or Konsole, you are running an interactive shell. However, the file we will use most often is the ~/.bashrc file. There are a number of different files that the shell uses for configuration, and we're going to see all of them in this chapter. In this chapter we'll take a look at the different configuration files for the shell and how they work, and how you can change your shell configuration with options. There are a number of different ways to configure your shell. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |