Skip to content

Commit

Permalink
add useful bash_aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
tpo committed Jul 11, 2013
1 parent 18651f5 commit 5e3c125
Show file tree
Hide file tree
Showing 2 changed files with 150 additions and 0 deletions.
48 changes: 48 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,54 @@

Here's the --help for each shell script:

### bash_aliases

These bash_aliases need to be called from ~/.bashrc or similar like this:

. /path/to/this/bash_aliases

They provide to following commands:

They provide to following commands:

df - execute "df -h"
du - execute "du -h"
bc - allow for calculations with decimal places by default in bc
psa - show all processes but not kernel threads
hg - grep shell history
hl - page shell history
pg - grep processes

Shortcuts to put firefox or thunderbird to rest.
Requires firefox-sleep/wake and thunderbird-sleep/wake

ffs, ffw, ths, thw

git shortcuts

g - status
gd - diff
ga - add
gc - commit
gca - commit -a
gcam - commit -a -m
gci - commit --interactive

chmod shortcuts

+x file
+r file
+w file
a+x file
a+r file
a+w file

change directory

cdreal file - chdir to wherever the file is located
cdwhich file - chdir to wherever the executable is located
mcd file - make directory and cd into it

### brightness

usage: brightness [--show|percent]
Expand Down
102 changes: 102 additions & 0 deletions bash_aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
#!/bin/bash

help() {
echo 'These bash_aliases need to be called from ~/.bashrc or similar like this:'
echo
echo ' . /path/to/this/bash_aliases'
echo
echo 'They provide to following commands:'
echo
echo 'They provide to following commands:'
echo
echo ' df - execute "df -h"'
echo ' du - execute "du -h"'
echo ' bc - allow for calculations with decimal places by default in bc'
echo ' psa - show all processes but not kernel threads'
echo ' hg - grep shell history'
echo ' hl - page shell history'
echo ' pg - grep processes'
echo
echo 'Shortcuts to put firefox or thunderbird to rest.'
echo 'Requires firefox-sleep/wake and thunderbird-sleep/wake'
echo
echo ' ffs, ffw, ths, thw'
echo
echo 'git shortcuts'
echo
echo ' g - status'
echo ' gd - diff'
echo ' ga - add'
echo ' gc - commit'
echo ' gca - commit -a'
echo ' gcam - commit -a -m'
echo ' gci - commit --interactive'
echo
echo 'chmod shortcuts'
echo
echo ' +x file'
echo ' +r file'
echo ' +w file'
echo ' a+x file'
echo ' a+r file'
echo ' a+w file'
echo
echo 'change directory'
echo
echo ' cdreal file - chdir to wherever the file is located'
echo ' cdwhich file - chdir to wherever the executable is located'
echo ' mcd file - make directory and cd into it'
echo
exit
}

if [ "$1" == "--help" ]; then
help
fi

alias df="df -h"
alias du="du -h"
# bc: scale=20
alias bc="bc -l"

# firefox/thunderbird
alias ffs=firefox-sleep
alias ffw=firefox-wake
alias ths=thunderbird-sleep
alias thw=thunderbird-wake

# do not show kernel threads:
# omit lines with "0:00 [kworker/6:0]" or similar
alias psa="ps auxw|grep -v -P '\d:\d\d \['"

hg() { history | grep "$1"; }
hl() { history | less +G; }
pg() { ps auxw | grep "$1"; }
mcd() { mkdir "$1"; cd "$1"; }

# chmod
alias +x='chmod +x'
alias +r='chmod +r'
alias +w='chmod +w'
alias a+x='chmod a+x'
alias a+r='chmod a+r'
alias a+w='chmod a+w'

cdreal() {
if [ ! "$1" ]; then
dst=.
else
dst="$1"
fi
dst=`realpath "$dst"`
if [ ! -d "$1" ]; then
dst=`dirname "$dst"`
fi
cd "$dst"
}

cdwhich() {
cd $( dirname $( which $1 ))
}


0 comments on commit 5e3c125

Please sign in to comment.