1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
|
#+date: <2022-07-31 Sun 00:00:00>
#+title: Boost Your Bash Shell with Bash-It and ble.sh
#+description: Enhance your Linux terminal experience by upgrading bash with Bash-It plugins, themes, and the powerful autosuggestions from ble.sh for improved productivity.
#+slug: bash-it
#+filetags: :bash:shell:linux:
* Bash
For those who are not familiar,
[[https://en.wikipedia.org/wiki/Bash_(Unix_shell)][Bash]] is a Unix
shell that is used as the default login shell for most Linux
distributions. This shell and command processor should be familiar if
you've used Linux (or older version of macOS) before.
However, bash is not the only option. There are numerous other shells
that exist. Here are some popular examples:
- [[https://en.wikipedia.org/wiki/Z_shell][zsh]]
- [[https://en.wikipedia.org/wiki/Fish_(Unix_shell)][fish]]
- [[https://github.com/ibara/oksh][oksh]]
- [[https://wiki.gentoo.org/wiki/Mksh][mksh]]
- [[https://en.wikipedia.org/wiki/Debian_Almquist_shell][dash]]
While each shell has its differences, bash is POSIX compliant and the
default for many Linux users. Because of this, I am going to explore a
program called =bash-it= below that helps bash users increase the
utility of their shell without installing a completely new shell.
** Installation
First, if bash is not already installed on your system, you can
[[https://www.gnu.org/software/bash/][download bash from GNU]] or use
your package manager to install it.
For example, this is how you can install bash on Fedora Linux:
#+begin_src sh
sudo dnf install bash
#+end_src
If you are not using bash as your default shell, use the =chsh= command
to change your shell:
#+begin_src sh
chsh
#+end_src
You should see a prompt like the one below. If the brackets (=[]=)
contain =bash= already, you're done, and you can simply continue by
hitting the Enter key.
If the brackets contain another shell path (e.g. =/usr/bin/zsh=), enter
the path to the bash program on your system (it's most likely located at
=/usr/bin/bash=).
#+begin_src sh
Changing shell for <user>.
New shell [/usr/bin/bash]:
#+end_src
You must log out or restart the machine in order for the login shell to
be refreshed. You can do it now or wait until you're finished
customizing the shell.
#+begin_src sh
sudo reboot now
#+end_src
* Bash-it
As noted on the [[https://github.com/Bash-it/bash-it][Bash-it]]
repository:
#+begin_quote
Bash-it is a collection of community Bash commands and scripts for Bash
3.2+. (And a shameless ripoff of oh-my-zsh 😃)
#+end_quote
Bash-it makes it easy to install plugins, set up aliases for common
commands, and easily change the visual theme of your shell.
** Installation
To install the framework, simply copy the repository files and use the
=install.sh= script provided. If you want, you can (and should!) inspect
the contents of the installation script before you run it.
#+begin_src sh
git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it
~/.bash_it/install.sh
#+end_src
If you didn't restart your session after making bash the default, and
are currently working within another shell, be sure to enter a bash
session before using =bash-it=:
#+begin_src sh
bash
#+end_src
** Aliases
Bash-it contains a number of aliases for common commands to help improve
efficiency in the terminal. To list all available options, use the
following command:
#+begin_src sh
bash-it show aliases
#+end_src
This will provide you a list that looks like the following text block.
Within this screen, you will be able to see all available options and
which ones are currently enabled.
#+begin_src txt
Alias Enabled? Description
ag [ ] the silver searcher (ag) aliases
ansible [ ] ansible abbreviations
apt [ ] Apt and dpkg aliases for Ubuntu and Debian distros.
atom [ ] Atom.io editor abbreviations
bash-it [ ] Aliases for the bash-it command (these aliases are automatically included with the "general" aliases)
bolt [ ] puppet bolt aliases
bundler [ ] ruby bundler
clipboard [ ] xclip shortcuts
composer [ ] common composer abbreviations
curl [x] Curl aliases for convenience.
...
#+end_src
To enable an alias, do:
#+begin_src sh
bash-it enable alias <alias name> [alias name]... -or- $ bash-it enable alias all
#+end_src
To disable an alias, do:
#+begin_src sh
bash-it disable alias <alias name> [alias name]... -or- $ bash-it disable alias all
#+end_src
** Plugins
Similar to aliases, plugins are available with bash-it. You can find a
complete list of plugins in the same way as aliases. Simply execute the
following:
#+begin_src sh
bash-it show plugins
#+end_src
You will see the following output showing enabled and disabled plugins:
#+begin_src txt
Plugin Enabled? Description
alias-completion [ ]
autojump [ ] Autojump configuration, see https://github.com/wting/autojump for more details
aws [ ] AWS helper functions
base [x] miscellaneous tools
basher [ ] initializes basher, the shell package manager
battery [x] display info about your battery charge level
blesh [ ] load ble.sh, the Bash line editor!
boot2docker [ ] Helpers to get Docker setup correctly for boot2docker
browser [ ] render commandline output in your browser
#+end_src
To enable a plugin, do:
#+begin_src sh
bash-it enable plugin <plugin name> [plugin name]... -or- $ bash-it enable plugin all
#+end_src
To disable a plugin, do:
#+begin_src sh
bash-it disable plugin <plugin name> [plugin name]... -or- $ bash-it disable plugin all
#+end_src
** Themes
There are quite a few pre-defined
[[https://bash-it.readthedocs.io/en/latest/themes-list/#list-of-themes][themes]]
available with bash-it.
To list all themes:
#+begin_src sh
ls ~/.bash_it/themes/
#+end_src
To use a new theme, you'll need to edit =.bashrc= and alter the
=BASH_IT_THEME= variable to your desired theme. For example, I am using
the =zork= theme.
#+begin_src sh
nano ~/.bashrc
#+end_src
#+begin_src sh
export BASH_IT_THEME='zork'
#+end_src
Once you save your changes, you just need to exit your terminal and
create a new one in order to see your changes to the =.bashrc= file. You
can also =source= the file to see changes, but I recommend starting a
completely new shell instead.
*** ble.sh
One big feature I was missing in Bash that both =zsh= and =fish= have is
an autosuggestion feature. To explain: as you type, an autosuggestion
feature in the shell will offer suggestions in a lighter font color
beyond the characters already typed. Once you see the command you want,
you can click the right arrow and have the shell auto-complete that line
for you.
Luckily, the [[https://github.com/akinomyoga/ble.sh][Bash Line Editor]]
(ble.sh) exists! This program provides a wonderful autosuggestions
feature perfectly, among other features that I haven't tested yet.
In order to install ble.sh, execute the following:
#+begin_src sh
git clone --recursive https://github.com/akinomyoga/ble.sh.git
make -C ble.sh install PREFIX=~/.local
echo 'source ~/.local/share/blesh/ble.sh' >> ~/.bashrc
#+end_src
Again, exit the terminal and open a new one in order to see the
newly-configured shell.
* Restart the Session
Finally, as mentioned above, you'll need to restart the session to
ensure that your user is using bash by default.
You will also need to exit and re-open a shell (e.g., terminal or
terminal tab) any time you make changes to the =.bashrc= file.
#+begin_src sh
sudo reboot now
#+end_src
|