Last articles

Categories

Bash Jquery Linux php PluXml Raspberry Pi Tools Unix

Selector - bash history

11 december 2012

Selector is a small bash commands capture tools developed by François Fleuret. It provides a simple interface for navigating through the history of commands and paths via keyboard shortcuts. Once the tool is set up, simply use the keys (Alt + r) to navigate through the command history and (Alt + d) to find all the different paths visited.

Handy for quickly navigating through the tree and quickly find order already used. Selector supports via (Alt-r) looking at the first character (same as google), compatible with regular expressions ...


Its implementation is very simple:

  1. Repatriate sources
  2. Construction of binary
  3. Called from your ~. Bashrc


For the impatient:

cd ~
mkdir bin/
cd bin/
git clone http://fleuret.org/git/selector/ 
cd selector
make selector
sudo ln -s ~/bin/selector/selector /usr/local/bin/selector

nano ~/.bashrc
#exemple d'intégration à son bash
#if [ -f ~/bin/selector/bash-selector.sh ]; then
#   . ~/bin/selector/bash-selector.sh --hist --cd
#fi

source ~/.bashrc
selector --help
Example rendering (Alt + r)

Selector (Alt+r)

Read more Selector - bash history

Classified in : Homepage, Unix - Tags : Bash, Linux, Tools - 1 comment

bash_aliases

12 october 2012

List the active alias: alias
Disable all alias: unalias-a
Disable a particular alias: unalias aliasname

Here is a small collection of handy alias:


### Very usefull
alias ..="cd .."
alias ...="cd ../.."
alias ....="cd ../../.."
alias .....="cd ../../../.."
alias cdh='cd ~'

alias lt='ls -lhart --color=auto'
alias ll='ls -lF --color=auto'
alias la='ls -alF --color=auto'
alias ls='ls -F'

alias psgb="ps -aux | grep bash"
alias psx="ps -auxw | grep $1"

alias svi='sudo vim'
alias snan='sudo nano'

alias scr='screen -R -D'

alias hcl='history -c; clear'

#Make mount command output pretty and human readable format
alias mount='mount |column -t'

#Show open ports
alias ports='netstat -tulanp'

# if user is not root, pass all commands via sudo #
if [ $UID -ne 0 ]; then
	alias reboot='sudo reboot'
	alias poweroff='sudo poweroff'
	alias halt='sudo /sbin/halt'
	alias shutdown='sudo /sbin/shutdown'
fi

## get meminfo ## 
alias meminfo='free -m -l -t'
 
## get top process eating memory
alias psmem='ps auxf | sort -nr -k 4'
alias psmem10='ps auxf | sort -nr -k 4 | head -10'
 
## get top process eating cpu ##
alias pscpu='ps auxf | sort -nr -k 3'
alias pscpu10='ps auxf | sort -nr -k 3 | head -10'

### Debian apt
alias aptu='sudo apt-get update'
alias aptua='sudo apt-get update && sudo apt-get upgrade'
alias apti='sudo apt-get install'
alias aptr='sudo apt-get remove'
alias apts='apt-cache search'

## shortcut  for iptables and pass it via sudo#
# display all rules #
alias iptlist='sudo /sbin/iptables -L -n -v --line-numbers'
alias iptlistin='sudo /sbin/iptables -L INPUT -n -v --line-numbers'
alias iptlistout='sudo /sbin/iptables -L OUTPUT -n -v --line-numbers'
alias iptlistfw='sudo /sbin/iptables -L FORWARD -n -v --line-numbers'
alias firewall=iptlist

###   Handy Extract Program
extract () {
   ee() { # echo and execute
       echo "$@"
       $1 "$2"
   }
   for x in "$@"; do
       [[ -f $x ]] || continue
       case "$x" in
           *.tar.bz2 | *.tgz )    	ee "tar xvjf" "$x"    ;;
           *.tar.gz | *.tbz2 )    	ee "tar xvzf" "$x"    ;;
           *.bz2 )                	ee "bunzip2" "$x"     ;;
           *.rar )                	ee "unrar x" "$x"     ;;
           *.gz )                 	ee "gunzip" "$x"      ;;
           *.tar )                	ee "tar xvf" "$x"     ;;
           *.zip )                	ee "unzip" "$x"       ;;
           *.Z )                  	ee "uncompress" "$x"  ;;
           *.7z )                 	ee "7z x" "$x"        ;;
       esac
   done
}

### This piece of code lists the size of every file and subdirectory of the current directory,
### much like du -sch ./* except the output is sorted by size, 
###with larger files and directories at the end of the list. 
###Useful to find where all that space goes. 
dusa ()
{
   du -a --max-depth=1 | sort -n | awk '{
               sub("./","",$2);
               size=$1;
               $1="";
               unit="K";
               if (size >= 1024)
               {
                       size = size /1024;
                       unit="M";
               }
               if (size >= 1024)
               {
                       size = size /1024;
                       unit="G";
               }
               printf "%6.1f%s %s\n",  size, unit, $0;
       }'
}

#export
export HISTFILESIZE=5000              # Larger history
export CLICOLOR=1                     # Use colors (if possible)
export LSCOLORS=ExGxFxdxCxDxDxBxBxExEx 

Read more bash_aliases

Classified in : Homepage, Unix - Tags : Unix, Linux, Bash - 1 comment

Rss feed of the category

Last articles

Categories

Archives