Cleaning up alias files

This commit is contained in:
Alexander Gehrke 2014-06-27 07:42:56 +02:00
parent 97fecce66f
commit 19e604450c
3 changed files with 40 additions and 66 deletions

View file

@ -10,16 +10,14 @@ alias lll="ls -hla"
alias ds="du -sh" alias ds="du -sh"
alias :q="exit" alias :q="exit"
alias rget="rsync -avP --rsh=ssh --append-verify --inplace" alias rget="rsync -rvP --rsh=ssh --append-verify --inplace"
alias 7zu="7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on" alias 7zu="7z a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on"
alias sudo="sudo "
alias S='sudo $(history -n -1)' alias S='sudo $(history -n -1)'
alias rm="rm -I" alias rm="rm -I"
alias v="xdg-open"
gg() {
paragrep "$@" -- **/*
}
fork() { fork() {
( $* &>/dev/null & ) ( $* &>/dev/null & )
@ -54,41 +52,13 @@ cd(){
#}}} #}}}
#################################################################################
# administration and init scripts
##############################################################################{{{
toggle() {
if [ -z $2 ]; then
/etc/init.d/$1 status |
grep started &&
sudo /etc/init.d/$1 stop ||
sudo /etc/init.d/$1 start
else
sudo /etc/init.d/$1 $2
fi
}
#}}}
################################################################################# #################################################################################
# filesystem stuff # filesystem stuff
##############################################################################{{{ ##############################################################################{{{
alias mkinitramfs='find . -print0 | cpio --null -ov --format=newc | gzip -9'
# bidirectional rsync
brsync() {
rsync -ur --progress $1 $2/..
rsync -ur --progress $2 $1/..
}
# count files in current or given directory # count files in current or given directory
count() { count() {
if [ -z $1 ]; then find $1 \( ! -path '*/.*' \) | wc -l
ls ./**/*(.) | wc -l
else
ls $1/**/*(.) | wc -l
fi
} }
pumount() { pumount() {
@ -98,9 +68,9 @@ pumount() {
shift shift
done done
if [[ "${1[1]}" == "/" ]]; then if [[ "${1[1]}" == "/" ]]; then
=pumount "${params[@]}" "$1" command pumount "${params[@]}" "$1"
else else
=pumount "${params[@]}" "/media/$1" command pumount "${params[@]}" "/media/$1"
fi fi
} }
@ -140,22 +110,6 @@ suffix() {
#}}} #}}}
#################################################################################
# wrappers
##############################################################################{{{
lesswrap() {
out=$("$@")
((lim=$LINES-1))
numlines=$(echo $out | wc -l)
if (( $numlines > $lim )); then
echo $out | less
else
echo $out
fi
}
#}}}
################################################################################# #################################################################################
# audio video photo # audio video photo
##############################################################################{{{ ##############################################################################{{{
@ -217,15 +171,6 @@ alias :attachw="tdetachprep; tmux movew -t : -s"
# global and suffix aliases # global and suffix aliases
##############################################################################{{{ ##############################################################################{{{
# mplayer dvd drives
alias -g DSR1="-dvd-device /dev/sr1"
alias -g DSR0="-dvd-device /dev/sr0"
alias -g SR1="/dev/sr1"
alias -g SR0="/dev/sr0"
# mplayer activate softvol
alias -g SOFTVOL="-softvol -softvol-max 1000"
# lazy shortcuts # lazy shortcuts
alias -g G="| grep" alias -g G="| grep"
alias -g L="| less" alias -g L="| less"
@ -238,4 +183,33 @@ alias -g XC='$(xclip -o -selection clipboard)'
alias -s log=vimpager alias -s log=vimpager
#}}} #}}}
#################################################################################
# various small scripts
##############################################################################{{{
urlencode() {
local input
setopt extendedglob
if [ -n "$1" ]; then
input="$*"
else
input=$(</dev/stdin)
fi
# by jkramer, source: http://stackoverflow.com/a/187853/928769
echo "${${(j: :)input}//(#b)(?)/%$[[##16]##${match[1]}]}"
}
#}}}
fasel-tunnel() {
if [[ -z "$1" || -z "$2" || "$1" == "-h" || "$1" == "--help" ]]; then
echo "Usage: fasel-tunnel <host> <port> [remote_port]"
return
fi
local host="$1";
local port="$2";
local remote_port="${3:-$2}"
ssh -L $port:$host:$remote_port fasel -N &
}
# vim: foldmethod=marker # vim: foldmethod=marker

View file

@ -2,7 +2,7 @@
alias eud="emerge -vabuDN -j4 --keep-going world" alias eud="emerge -vabuDN -j4 --keep-going world"
alias fetchlog="tail -f /var/log/emerge-fetch.log" alias fetchlog="tail -f /var/log/emerge-fetch.log"
alias emerge="sudo emerge" alias emerge="noglob sudo emerge"
nolto() { nolto() {
pkgenvconf $1 nolto nolto pkgenvconf $1 nolto nolto
@ -50,7 +50,3 @@ pkgenvconf() {
*) ;; *) ;;
esac esac
} }
alias eix="lesswrap /usr/bin/eix -F"

4
zshrc
View file

@ -22,6 +22,8 @@ autoload -Uz zmv
zmodload zsh/zftp zmodload zsh/zftp
function exists { command -v "$@" >/dev/null }
for i in ${ZDOTDIR:-/etc/zsh}/aliases/*~${ZDOTDIR:-/etc/zsh}/aliases/*.zwc; do for i in ${ZDOTDIR:-/etc/zsh}/aliases/*~${ZDOTDIR:-/etc/zsh}/aliases/*.zwc; do
. $i . $i
done done
@ -38,3 +40,5 @@ zstyle ':completion:*' verbose yes
zstyle ':completion:*:descriptions' format %B%d%b zstyle ':completion:*:descriptions' format %B%d%b
zstyle ':completion:*:messages' format %d zstyle ':completion:*:messages' format %d
zstyle ':completion:*:warnings' format No matches for: %d zstyle ':completion:*:warnings' format No matches for: %d
exists todo && todo