Recommended bash aliases

From Docswiki
Jump to navigation Jump to search

~wales/.bashalias

Copying ~wales/.inputrc to your home directory will also reduce your typing. It sets up ESC then . as the last item on the previous line and ESC then , and backward search in history matching the start of what you have already typed.

Function to remove filename extensions

Place

# rm filename extension
function rmext() {
 find . -mindepth 1 -maxdepth 1 -type f | grep $1 |\
 sed 's/\(.*\)\..*/\1/' | xargs -I {} mv {}.$1 {};
}

in ~/.bash_aliases or ~/.bashrc then

source ~/.bashrc

Usage

$ rmext <extension>

Example

$ ls -1
first.file.test
second.file.test
important.file
$ rmext test
$ ls -1
first.file
second.file
important.file

What about using the rename command?

$ ls
first.file.test  important.file  second.file.test
$ rename ".test" "" *.test
$ ls
first.file  important.file  second.file

(I'll note that different implementations of rename exist and the usage varies accordingly: check the manpage!)

xpdf

# fit width and set geometry
alias xpdf="xpdf -z width -geometry 1000x1000"