Just install the package "bash-completion" in archlinux und you will get extended tab completion for the following programs: http://wklej.org/id/808581
*edit: Make sure "/etc/bash.bashrc" is up-to-date otherwise it may not work.
Even tab completion for rsync and scp remote files structures works now.
Showing posts with label bash. Show all posts
Showing posts with label bash. Show all posts
Saturday, August 11, 2012
Monday, July 30, 2012
Bash prompt shortener
Add this to your ~/.bashrc
# Bash shortener
_PS1 ()
{
local PRE= NAME="$1" LENGTH="$2";
[[ "$NAME" != "${NAME#$HOME/}" || -z "${NAME#$HOME}" ]] &&
PRE+='~' NAME="${NAME#$HOME}" LENGTH=$[LENGTH-1];
((${#NAME}>$LENGTH)) && NAME="/...${NAME:$[${#NAME}-LENGTH+4]}";
echo "$PRE$NAME"
}
PS1=' \[\e[0m\]\u\[\e[0;32m\]@\[\e[0m\]\h \[\e[0;32m\]$(_PS1 "$PWD" 30) \[\e[0m\]$ 'It will shorten the path in your bash prompt to 30 chars.
Saturday, January 7, 2012
Start applications with the default app from console
Its as simple as. Add this to your ~/.bashrc
alias open='nohup xdg-open >/dev/null 2>&1'Now you can start, for example a textfile, like this "open textfile.txt". Because of nohop in the alias you can even close the console session and the text editor stays open.
Tuesday, September 13, 2011
Sync bash history between sessions on the fly
If you work with more then one bash terminal at a time, it can be annoying that the bash history is only available in the other session after you closed the terminal (default bash behavior).
You can fix it by adding this to your .bashrc
*EDIT:
I found it confusing that the history is always synced, even in the current session. This can be confusing while working, so i changed the above a bit:
Removing "history -n;" has the effect, that the history is still up to date when you open a new terminal but existing terminals will not get the changes immediately. You have to execute "history -n" manually if you need the changes in the current terminal.
You can fix it by adding this to your .bashrc
shopt -s histappendMore about it here: http://briancarper.net/blog/248/
export PROMPT_COMMAND="history -n; history -a"
*EDIT:
I found it confusing that the history is always synced, even in the current session. This can be confusing while working, so i changed the above a bit:
HISTSIZE=10000Beside the obvious changes there are some more variables changes . "HISTCONTROL=ignoreboth:ignoredups:erasedups" to prevents bash to add dups. So your .bash_history keeps clean. Beside that i have added some more fun stuff. "cdspell" fixes typos while changing directories (yeah) and HISTSIZE increases the history size to 10000 lines.
HISTCONTROL=ignoreboth:ignoredups:erasedups
shopt -s cmdhist
shopt -s cdspell
shopt -s histappend
#PROMPT_COMMAND="history -n; history -a"
PROMPT_COMMAND="history -a"
Removing "history -n;" has the effect, that the history is still up to date when you open a new terminal but existing terminals will not get the changes immediately. You have to execute "history -n" manually if you need the changes in the current terminal.
Sunday, February 6, 2011
Resetting screen resolution with xrandr
If a game or an other application messed up you resolution you can easiely reset it by executing:
$ xrandr -s 0
Sunday, December 5, 2010
how to extract archives the simple way
Its easy as this.
*edit: Or you can use "atool". A script that covers the same functionality as the code below but supports even more complex operations. http://www.nongnu.org/atool/
Add this code to your .bashrc:
*edit: Or you can use "atool". A script that covers the same functionality as the code below but supports even more complex operations. http://www.nongnu.org/atool/
Add this code to your .bashrc:
From now on you can extract the listes archives simply by calling "extract archive".extract () {if [ -f $1 ] ; thencase $1 in*.tar.bz2) tar xvjf $1 ;;*.tar.gz) tar xvzf $1 ;;*.bz2) bunzip2 $1 ;;*.rar) unrar x $1 ;;*.gz) gunzip $1 ;;*.tar) tar xvf $1 ;;*.tbz2) tar xvjf $1 ;;*.tgz) tar xvzf $1 ;;*.zip) unzip $1 ;;*.Z) uncompress $1 ;;*.7z) 7z x $1 ;;*) echo "don't know how to extract '$1'..." ;;esacelseecho "'$1' is not a valid file!"fi}
Saturday, November 20, 2010
Spped up your linux system with cgroup
Here is a way described how to speed up your linux system.
I used the ubuntu way even on archlinux and it works.
http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html
I used the ubuntu way even on archlinux and it works.
http://www.webupd8.org/2010/11/alternative-to-200-lines-kernel-patch.html
Sunday, October 24, 2010
Tuesday, March 9, 2010
Rename file with special char in filename
Sometimes you cannot rename a file cause the filename contains a special char that cannot be recognized. In this case you can rename a file by its inode.
Its as simple as this:
Its as simple as this:
ls -il (to get the inode)
find . -type f -inum "inode num goes here" -exec mv {} newfilename \; (find file by inode and rename it)
Sunday, August 9, 2009
Advanced bash history completion
To extend the bash completion add this:
If you type "man" and now press up or down on your keyboard only history entry's starting with "man" will be shown. Very useful.
bye
to /etc/inputrc or your ~/.inputrc"\e[A":history-search-backward
"\e[B":history-search-forward
bind -f .inputrcupdates your config without logout/login.
If you type "man" and now press up or down on your keyboard only history entry's starting with "man" will be shown. Very useful.
bye
Subscribe to:
Posts (Atom)