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 Wed 27 Aug 2014, 07:08
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 Posts_count  
Author Message
sc0ttman


Joined: 16 Sep 2009
Posts: 2376
Location: UK

PostPosted: Tue 17 Sep 2013, 09:34    Post_subject:  Improving the BASH shell
Sub_title: ...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:

Code:
# 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:

Code:
export HISTIGNORE="&"


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

Code:
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 :

Code:
# 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 :

Code:
diff <(ls dir1) <(ls dir2)


The links:

http://unix.stackexchange.com/questions/6/what-are-your-favorite-command-line-features-or-tricks

http://www.catonmat.net/blog/top-ten-one-liners-from-commandlinefu-explained/

http://www.catonmat.net/blog/the-next-ten-one-liners-from-commandlinefu-explained/

http://www.catonmat.net/blog/another-ten-one-liners-from-commandlinefu-explained/

http://www.catonmat.net/blog/yet-another-ten-one-liners-from-commandlinefu-explained/

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

Edited_times_total
Back to top
View user's profile Send_private_message 
Karl Godt


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

PostPosted: Tue 17 Sep 2013, 10:58    Post_subject:  

http://www.murga-linux.com/puppy/viewtopic.php?p=583706#583706
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 Visit_website 
L18L

Joined: 19 Jun 2010
Posts: 2505
Location: Burghaslach, Germany somewhere also known as "Hosla"

PostPosted: Tue 17 Sep 2013, 11:50    Post_subject: Improving the BASH shell
Sub_title: app starter
 

http://www.murga-linux.com/puppy/viewtopic.php?p=726200

So here just another one one liner:
Code:
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:   Sort by:   
Page 1 of 1 Posts_count  
Post_new_topic   Reply_to_topic View_previous_topic :: View_next_topic
 Forum index » House Training » HOWTO ( Solutions )
Jump to:  

Rules_post_cannot
Rules_reply_cannot
Rules_edit_cannot
Rules_delete_cannot
Rules_vote_cannot
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0578s ][ Queries: 12 (0.0074s) ][ GZIP on ]