Put this code in your ~/.inputrc file to enable nice auto-completion in the bash shell prompt.
1 2 3 4 5 6 7 8 9 10 | $include /etc/inputrc set completion-ignore-case on set completion-query-items -1 set show-all-if-unmodified on set show-all-if-ambiguous off set colored-completion-prefix on set colored-stats on set visible-stats on "\C-j": menu-complete "\C-k": menu-complete-backward |
Use the ctrl-j/ctrl-k keyboard shortcuts for the auto-completion of commands.
Add this comprehensive code to your .bashrc file to enable some very useful auto-completion of bash commands.
This code will set the history size when placed in the .bashrc file.
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) HISTSIZE=1000 HISTFILESIZE=2000 |
This code will ensure bash does not put duplicate commands in the .bash_history file.
# don't put duplicate lines or lines starting with space in the history. # See bash(1) for more options HISTCONTROL=ignoreboth |
This useful script will show some very useful system information.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | #!/bin/bash echo " My System information script." echo " " echo " " echo "The computer has: $(awk < /proc/meminfo '{ if ($1 == "MemTotal:") { print $2 }}') Kilobytes of RAM." echo "The kernel version is: $(uname -r)." echo "There is: $(df -Hla / | awk '/dev/ {print $3 " remaining of",$4 " \ on the / partition."}')" echo "The load average is: $(cut -f1 -d ' ' /proc/loadavg). The CPU has\ $(grep -c ^processor /proc/cpuinfo 2>/dev/null) cores." echo "Current CPU usage is: $(top -bn 2 -d 0.01 | grep '^%Cpu' | \ tail -n 1 | awk '{print $2+$4+$6}')%" echo "There are $(ls /var/cache/apt/archives/ | wc -l) packages in\ the /var/cache/apt/archives/ directory." echo "This is the arp table:" echo " " echo "$(cat /proc/net/arp)" echo " " |
Enable the color support in bash if your chosen terminal supports it and also enable some very useful aliases.
1 2 3 4 5 6 7 8 9 10 11 | # enable color support of ls and also add handy aliases if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" alias ls='ls --color=auto' alias dir='dir --color=auto' alias vdir='vdir --color=auto' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' fi |