mirror of
https://github.com/webgefrickel/dotfiles
synced 2024-11-11 07:10:40 +00:00
61 lines
1.4 KiB
Plaintext
61 lines
1.4 KiB
Plaintext
# a small function for finding stuff
|
|
function fname() {
|
|
find . -iname "*$@*";
|
|
}
|
|
|
|
|
|
function take() {
|
|
mkdir -p $1
|
|
cd $1
|
|
}
|
|
|
|
|
|
# find process by name and kill them
|
|
function grepkill() {
|
|
ps -axf | grep -v grep | grep "$@" | awk '{print $2}' | xargs kill
|
|
}
|
|
|
|
|
|
# open changed files in git index
|
|
function gch () {
|
|
vim `git status | grep modified | awk '{print $3}'`
|
|
}
|
|
|
|
|
|
function current_branch() {
|
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
|
|
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
|
|
echo ${ref#refs/heads/}
|
|
}
|
|
|
|
|
|
# creates an archive from given directory
|
|
mktar() { tar cvf "${1%%/}.tar" "${1%%/}"; }
|
|
mktgz() { tar cvzf "${1%%/}.tgz" "${1%%/}"; }
|
|
mktbz() { tar cvjf "${1%%/}.tbz" "${1%%/}"; }
|
|
mkzip() { zip -r "${1%%/}" "${1%%/}"; }
|
|
|
|
|
|
# easy extract
|
|
extract () {
|
|
if [ -f $1 ] ; then
|
|
case $1 in
|
|
*.tar.bz2) tar xvjf $1 ;;
|
|
*.tar.gz) tar xvzf $1 ;;
|
|
*.bz2) bunzip2 $1 ;;
|
|
*.rar) rar x $1 ;;
|
|
*.gz) gunzip $1 ;;
|
|
*.tar) tar xvf $1 ;;
|
|
*.tgz) tar xvzf $1 ;;
|
|
*.tbz2) tar xvjf $1 ;;
|
|
*.tbz) tar xvjf $1 ;;
|
|
*.zip) unzip $1 ;;
|
|
*.Z) uncompress $1 ;;
|
|
*.7z) 7z x $1 ;;
|
|
*) echo "don't know how to extract '$1'..." ;;
|
|
esac
|
|
else
|
|
echo "'$1' is not a valid file!"
|
|
fi
|
|
}
|