Jan 21: Configuring i3 & What are .bashrc files
Today we went over how to configure the tiling window manager, i3, by editing it's configuration file. I also explained the use of the hidden files .bashrc, .bash_aliases, .profile
, etc.
Notes
i3 config
- The config file is located at
~/.config/i3/config
.- the user guide (see this link ) is explains the syntax and gives some useful examples
- lines that start with a ‘#’ are comments. They don't affect the configuration
- how to set custom keybindings:
bindsym $mod+Shift+f exec --no-startup-id firefox
- to change the bar location, add the following line in the
bar
section (inside the curly braces):- remember to refresh i3 after editing the config file (also don't forget to save the config file before refreshing)
- Here's a link to my config file for i3 (from back when I used to use i3). Don't copy and paste it into your config file, because it won't work. I have some shortcuts to commands/programs that you don't have installed. Instead, use it as a reference and only copy the lines that you understand. (You can download it, or copy-paste it into a file, if you want, just don't blindly use it as your i3 config)
- Also, another difference between my config file and yours is that mine is for i3-gaps, not for i3, which is a slighty modified version of i3 which supports gaps in between windows. So there will be some extra lines in my config (for configuring gaps).
Feel free to email me any questions you have about my config file. There is a lot of stuff in there which I didn't go over, but I can explain it to you if you want.
position top
.bashrc, .bash_aliases, .profile, etc.
- bash is a ‘shell’, which means it's a program that interprets the commands you type into a terminal
- you can also think of bash as being a programming language
- when you start a terminal, bash is automatically started so that you can type commands and interact with your computer
.bashrc
is a shell script (written in bash) that is run every time you start a new terminal window- it is used to initialize convenient features like tab completion, colors, environment variables, aliases, etc.
- by default, some convienant aliases exist. for ex.
l
is an alias tols
- in it you will see an if block that runs the
~/.bash_alaises
file if it exists- note that the syntax for running another shell script, (or ‘sourcing’, as we call it) is the following (either of those commands work, they are synonymous):
. ~/path/to/shellScript
source ~/path/to/shellScript
- by convention, we put our custom aliases (aka shortcuts) in
.bash_aliases
- the syntax to define aliases is as follows (put this is
~/.bash_aliases
):
- the syntax to define aliases is as follows (put this is
alias 'mt=cd ~/Documents/school/math'
alias 'myShortcut=this is a long command with many words'
- The
.profile
file is similar to.bashrc
in that it's run on startup, except it's only run on the startup of so-called ‘login’ shells, which is the first shell that runs on your computer, before you login. You don't see this shell if you are using a graphical login manager (like on Ubuntu). This file is not very useful to us
Extra
- Add the following line to your
~/.bashrc
to be able to use vim shortcuts on the command line
set -o vi
- this command enables a bash feature known as ‘vi mode’ (vi was the precursor to vim)
- notice that by putting that line in
~/bashrc
, we are running it every time we start a terminal, and thus we are effectively changing a configuration setting. Now you can see how the~./bashrc
file (which is really just a shell script) acts as a configuration file for bash