Puppy Linux Discussion Forum Forum Index Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Sun 16 Dec 2018, 20:42
All times are UTC - 4
 Forum index » House Training » HOWTO ( Solutions )
Improving the BASH shell
Moderators: Flash, Ian, JohnMurga
Post new topic   Reply to topic View previous topic :: View next topic
Page 1 of 1 [3 Posts]  
Author Message

Joined: 16 Sep 2009
Posts: 2621
Location: UK

PostPosted: Tue 17 Sep 2013, 09:34    Post subject:  Improving the BASH shell
Subject description: ...making a little easier on typos, and so on...

Improving the BASH shell

My brother keeps mentioning zsh.. Here's my answer, for now..

Settings created in your shell:

- share ~/.history across terminal windows
- auto remove duplicates from ~/.history
- add multi-line cmds to a single entry in ~/.history
- your ~/.history always saved, no need hit Ctrl-D or type 'exit'
- auto correct small typos and case mis-match in file and dir matching and TAB completions
- case insensitive file/dir matching and TAB completions
- add SHIFT-TAB completion: uses an alternate, inline, cycle-through-options style TAB completion

Add the following into your BASH settings file /root/.bashrc:

# allow shortcuts to directories
# usage example:   cd $docs
shopt -s cdable_vars
# example shortcuts
export docs="/usr/share/docs"
export menufiles="/usr/share/applications"

# better typo support
#enable spell checking of files and dirs in the shell
shopt -s cdspell
#make file/dir matching case insensitive
shopt -s nocaseglob
#make TAB completion of file/dir names case insensitive
bind 'set completion-ignore-case on'

# fix cmd typos
alias ehco='echo'
alias ehoc='echo'
alias ehcp='echo'
alias dinf='find'
alias fidn='find'
alias findf='find'
alias gerp='grep'
alias gepr='grep'
alias egrp='grep'

#  better history management
#ignore adding duplicates to the history list, erase them too
export HISTCONTROL=erasedups
# enabled shared history across terminal windows .. histappend not needed below
#shopt -s histappend
#keep multi lines commands together on one line
shopt -s cmdhist
# the magic bit, does a few things, basically keeps your history tidy and up to date
export PROMPT_COMMAND="history -n; history -w; history -c; history -r; $PROMPT_COMMAND"

Note, adding the above to ~/.bashrc will also mean, if you're running BASH4, then you won't have to
type 'exit' or hit Ctr-D in order to save your history.. it will get saved each time you execute a command.

However, using the PROMPT_COMMAND method as above will mess up the reported line number by the history command..

Also, here's another, simpler way to filter out duplicates:

export HISTIGNORE="&"

Or, to filter out duplicates and the plain 'ls' and 'exit' commands:

export HISTIGNORE="&:ls:exit"

To get inline TAB completion, where you press Shft-Tab to cycle through possible file/dir matches in place, just add this to your /etc/inputrc file :

# enable a second inline style of auto completion with SHIFT-TAB:
"\e[Z": menu-complete

...And here are a load of interesting, one line shell commands you might not know about,
such as comparing the output of two commands :

diff <(ls dir1) <(ls dir2)

The links:






Akita Linux, VLC-GTK, Pup Search, Pup File Search

Last edited by sc0ttman on Tue 17 Sep 2013, 11:11; edited 2 times in total
Back to top
View user's profile Send private message 
Karl Godt

Joined: 20 Jun 2010
Posts: 4208
Location: Kiel,Germany

PostPosted: Tue 17 Sep 2013, 10:58    Post subject:  

myself wrote:
for /bin/bash you could have an internet lookup for " man bash "

the file /etc/inputrc i have altered much for testing purposes and on one installation

set match-hidden-files on
set show-all-if-ambiguous on
set completion-ignore-case on
Back to top
View user's profile Send private message 

Joined: 19 Jun 2010
Posts: 3431
Location: www.eussenheim.de/

PostPosted: Tue 17 Sep 2013, 11:50    Post subject: Improving the BASH shell
Subject description: app starter


So here just another one one liner:
rxvt -title "Type in initial letters of your app and the press TAB key"  -e ash
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 1 of 1 [3 Posts]  
Post new topic   Reply to topic View previous topic :: View next topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum

Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0684s ][ Queries: 11 (0.0087s) ][ GZIP on ]