114 lines
2.2 KiB
Bash
114 lines
2.2 KiB
Bash
# -*- shell-script -*-
|
|
#
|
|
# Trace libraries load by first argument (ELF only)
|
|
# (note: exactly same result with ldd)
|
|
tracelib () {
|
|
LD_TRACE_LOADED_OBJECTS=1 $1
|
|
}
|
|
|
|
srm() {
|
|
if [ ! -z $1 ]; then
|
|
echo "Deleting `find "$1" -type l | wc -l` symbolic links"
|
|
find "$1" -type l -exec rm {} +
|
|
rm -r "$1"
|
|
fi
|
|
}
|
|
|
|
cp_p() {
|
|
strace -q -ewrite cp -- "${1}" "${2}" 2>&1 \
|
|
| awk '{
|
|
count += $NF
|
|
if (count % 10 == 0) {
|
|
percent = count / total_size * 100
|
|
printf "%3d%% [", percent
|
|
for (i=0;i<=percent;i++)
|
|
printf "="
|
|
printf ">"
|
|
for (i=percent;i<100;i++)
|
|
printf " "
|
|
printf "]\r"
|
|
}
|
|
}
|
|
END { print "" }' total_size=$(stat -c '%s' "${1}") count=0
|
|
}
|
|
|
|
lsperm () {
|
|
echo $1 | perl -e 'chomp($s=<>);$p=(stat($s))[2] & 07777;printf "$s -> %04o\n",$p'
|
|
}
|
|
|
|
findnosecure () {
|
|
find / -perm +2000 -o -perm +4000 -print 2>/dev/null
|
|
}
|
|
|
|
function cd () {
|
|
if [[ -z $2 ]]; then
|
|
if [[ -f $1 ]]; then
|
|
builtin cd $1:h
|
|
else
|
|
builtin cd $1
|
|
fi
|
|
else
|
|
if [[ -z $3 ]]; then
|
|
builtin cd $1 $2
|
|
else
|
|
echo cd: too many arguments
|
|
fi
|
|
fi
|
|
}
|
|
|
|
# display the NTTP message (wait a Message-Id)
|
|
mid () {
|
|
( echo "mode reader"; echo "article <$*>" | sed 's/%40/@/ ; s/%24/\$/g ; s/<<*/</g ; s/>>*/>/g') |
|
|
tee /proc/self/fd/2 | nc $NNTPSERVER 119 | tail +3 }
|
|
|
|
set_title () {
|
|
[ $TERM = "screen" ] && print -nR $'\033k'$1$'\033'\\
|
|
}
|
|
|
|
# update screen caption, use the last argument as hostname
|
|
ssh () {
|
|
[[ "$*" == *"BatchMode=yes"* ]] && USE_XTABS="False"
|
|
if [[ $USE_XTABS = "True" ]]; then
|
|
open_new_tab ssh $@
|
|
else
|
|
target=$_
|
|
target=${target//*@/}
|
|
set_title $target
|
|
command ssh $@
|
|
fi
|
|
}
|
|
|
|
# same for telnet
|
|
telnet () {
|
|
if [[ $USE_XTABS = "True" ]]; then
|
|
open_new_tab telnet "$*"
|
|
else
|
|
target=$1
|
|
set_title $target
|
|
command telnet $*
|
|
fi
|
|
}
|
|
|
|
|
|
|
|
# utf8
|
|
utf8 () {
|
|
if [[ $COLORTERM == "gnome-terminal" ]]; then
|
|
echo -e '\e%G'
|
|
fi
|
|
export LC_CTYPE=fr_FR.UTF8
|
|
unalias vi
|
|
if [[ ! -x $(which -p vim) ]] ; then
|
|
echo "utf8() Warning, vim not found !"
|
|
else
|
|
alias vi='vim "+set enc=utf8"'
|
|
fi
|
|
}
|
|
|
|
# Update the config
|
|
update_zsh_config () {
|
|
cd ~/.zsh
|
|
echo "Updating ZSH configuration…"
|
|
git pull
|
|
cd $OLDPWD
|
|
} |