![]() |
This site is currently Under Construction |
...soon to be...![]() |
|---|
|
OpenBSD Bash Shell Last updated: 2009-06-31 Bash is a better commandline shell. === To Install bash-3.2.48 # cd /usr/ports === Setting BASH as your login shell: # chsh -s bash === Create Symbolic Link to Standard Bash Location: # ln -s /usr/local/bin/bash /bin/bash === Customize the Bash Shell Prompt: Default bash prompt variable: Custom prompt string: Which will change the prompt to look like this: To make the custom prompt permanent for root we must add this variable to the dot.profile config file: Now the custom prompt variable will be executed each time the root user logs in. To do the same for all new users that are created, we must modify the default dot.profile file in /etc/skel: # echo "export PS1='\u@\h \w\\$ '" >> /etc/skel/.profile Non root (UID is not 0) will display like this: === Fixing Commandline Editing Issues: This will allow the Home, End, Ctrl-Left, and Ctrl-Right keys to work properly on the bash commandline. Create a file called .inputrc in /root: Copy this into the file and save it: # this is actually equivalent to "\C-?": delete-char # mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving # VT # kvt # rxvt and konsole (i.e. the KDE-app...) Now copy this file into the default dot.profile directory for new users as their default bash edit file: # cp ~/.inputrc /etc/skel NOTE: Close your terminal session and log back in. I've found that after the first time you install bash and create the profile file, it's best to log off and back on to initialize the changes. After that you can use the next procedure to restarting the bash shell. === Restart bash shell without logging in: For root: # . /root/.profile Other users: # . /home/<username>/.profile NOTE: The dot and space ". " before the file path is the ksh "source" command. Make sure the dot is the first character in the line and is followed by a space. === Bash History: Commandline history is stored in username root folder file: Clear history file: Execute a Specific Command from History: If you want to repeat the command #4, you can do !4 as shown below: # history | more # !4 Total Number of Lines in the History using HISTSIZE: Append the following two lines to the .bash_profile and relogin to the bash shell again to see the change. # vi ~/.bash_profile Or do this: Force History to NOT Remember a Particular Command using HISTCONTROL: # export HISTCONTROL=ignorespace Now placing a space before your command on the commandline will cause it not to be logged in the hostory file. Disable History: # export HISTSIZE=0 NOTE: If you move a script file and the file was executed from the commandline before it was moved, you may get an error saying the file can't be found. Simply clear the history file to elliminate the annoying error. === Sample Bash Script: #!/bin/bash DIR="$1" Exit and Save (:wq) To make sure that the script is executable: # chmod 700 <filename> Test the Script: # ./testdir /etc # ./testdir /etc/a === Shell Doesn't Recognize Newly Installed Binaries: If your shell doesn't recognize the installed command, flush the cache. Bash Shell: # hash -r CSH Shell: # rehash === References: Customize your Bash Shell: ===
|