Shell: fixed all missing 'local' to variables.
parent
d64ae6e75d
commit
b62e4f01dc
|
@ -1,7 +1,5 @@
|
|||
auto-complete
|
||||
bashmount
|
||||
bustle
|
||||
cgdb
|
||||
dropbox
|
||||
dropbox-cli
|
||||
emacs-mediawiki-bzr
|
||||
|
@ -11,7 +9,9 @@ grub
|
|||
gsharkdown
|
||||
handbrake-cli-svn
|
||||
handbrake-svn
|
||||
mongoose
|
||||
movgrab
|
||||
openmw-git
|
||||
package-query
|
||||
pacman-color
|
||||
rxvt-unicode-patched
|
||||
|
|
|
@ -5,24 +5,19 @@ antiword
|
|||
asciidoc
|
||||
aspell-en
|
||||
aspell-fr
|
||||
astyle
|
||||
atool
|
||||
auctex
|
||||
auto-complete
|
||||
autoconf
|
||||
automake
|
||||
awesome
|
||||
bash
|
||||
bash-completion
|
||||
bashmount
|
||||
binutils
|
||||
bison
|
||||
bustle
|
||||
bzip2
|
||||
bzr
|
||||
calc
|
||||
catdvi
|
||||
cgdb
|
||||
cmus
|
||||
coreutils
|
||||
cpufrequtils
|
||||
|
@ -66,9 +61,9 @@ gettext
|
|||
gimp
|
||||
git
|
||||
glibc
|
||||
gnuchess
|
||||
gnu-netcat
|
||||
gnuplot
|
||||
gparted
|
||||
grep
|
||||
grub
|
||||
gsasl
|
||||
|
@ -94,7 +89,6 @@ ispell
|
|||
jansson
|
||||
jfsutils
|
||||
js
|
||||
laptop-mode-tools
|
||||
less
|
||||
libmicrohttpd
|
||||
libtool
|
||||
|
@ -104,7 +98,6 @@ links
|
|||
linux
|
||||
linux-lts
|
||||
logrotate
|
||||
lrzip
|
||||
ltrace
|
||||
luakit
|
||||
lvm2
|
||||
|
@ -114,19 +107,22 @@ man-db
|
|||
man-pages
|
||||
mdadm
|
||||
mediainfo
|
||||
mencoder
|
||||
mercurial
|
||||
mesa-demos
|
||||
midori
|
||||
mongoose
|
||||
movgrab
|
||||
mplayer2
|
||||
mtools
|
||||
mutt
|
||||
nano
|
||||
nasm
|
||||
ncdu
|
||||
net-tools
|
||||
nmap
|
||||
ntfs-3g
|
||||
numlockx
|
||||
openmw-git
|
||||
openssh
|
||||
p7zip
|
||||
package-query
|
||||
|
@ -143,7 +139,6 @@ pkgstats
|
|||
ppp
|
||||
procps-ng
|
||||
psmisc
|
||||
pwgen
|
||||
pwsafe
|
||||
pygtk
|
||||
python2-udiskie
|
||||
|
@ -165,6 +160,7 @@ syslog-ng
|
|||
sysvinit
|
||||
tar
|
||||
task
|
||||
tcc
|
||||
tcpdump
|
||||
texi2html
|
||||
texinfo
|
||||
|
@ -187,7 +183,6 @@ w3m
|
|||
weechat
|
||||
wget
|
||||
which
|
||||
wipe
|
||||
wireless_tools
|
||||
wireshark-cli
|
||||
wireshark-gtk
|
||||
|
@ -198,7 +193,6 @@ xf86-video-intel
|
|||
xf86-video-vesa
|
||||
xfsprogs
|
||||
xorg-server
|
||||
xorg-twm
|
||||
xorg-xev
|
||||
xorg-xinit
|
||||
xorg-xprop
|
||||
|
|
|
@ -11,7 +11,6 @@ asciidoc
|
|||
aspell
|
||||
aspell-en
|
||||
aspell-fr
|
||||
astyle
|
||||
atk
|
||||
atkmm
|
||||
atool
|
||||
|
@ -23,19 +22,22 @@ avahi
|
|||
awesome
|
||||
babl
|
||||
bash
|
||||
bash-completion
|
||||
bc
|
||||
binutils
|
||||
bison
|
||||
boost
|
||||
boost-libs
|
||||
bullet
|
||||
bzip2
|
||||
bzr
|
||||
ca-certificates
|
||||
cairo
|
||||
cairomm
|
||||
calc
|
||||
catdvi
|
||||
cdparanoia
|
||||
cifs-utils
|
||||
cloog
|
||||
cmake
|
||||
cmus
|
||||
colord
|
||||
compositeproto
|
||||
|
@ -102,6 +104,7 @@ foomatic-db-engine
|
|||
foomatic-filters
|
||||
fortune-mod
|
||||
freeglut
|
||||
freeimage
|
||||
freetype2
|
||||
fribidi
|
||||
fuse
|
||||
|
@ -124,17 +127,18 @@ gimp
|
|||
girara-common
|
||||
girara-gtk2
|
||||
git
|
||||
glew
|
||||
glib2
|
||||
glibc
|
||||
glibmm
|
||||
glib-networking
|
||||
glproto
|
||||
gmp
|
||||
gnuchess
|
||||
gnu-netcat
|
||||
gnupg
|
||||
gnuplot
|
||||
gnutls
|
||||
gparted
|
||||
gpgme
|
||||
gpm
|
||||
grep
|
||||
|
@ -197,7 +201,6 @@ kmod
|
|||
krb5
|
||||
ladspa
|
||||
lame
|
||||
laptop-mode-tools
|
||||
lcms
|
||||
lcms2
|
||||
ldns
|
||||
|
@ -210,6 +213,7 @@ libatasmart
|
|||
libbluray
|
||||
libcaca
|
||||
libcap
|
||||
libcap-ng
|
||||
libcdaudio
|
||||
libcddb
|
||||
libcdio
|
||||
|
@ -300,6 +304,7 @@ libva
|
|||
libvdpau
|
||||
libvorbis
|
||||
libvpx
|
||||
libwbclient
|
||||
libwebkit
|
||||
libwmf
|
||||
libx11
|
||||
|
@ -341,7 +346,6 @@ linux-firmware
|
|||
linux-lts
|
||||
lirc-utils
|
||||
logrotate
|
||||
lrzip
|
||||
lsof
|
||||
ltrace
|
||||
lua
|
||||
|
@ -349,7 +353,6 @@ luafilesystem
|
|||
luajit
|
||||
luakit
|
||||
lvm2
|
||||
lzo2
|
||||
m4
|
||||
make
|
||||
man-db
|
||||
|
@ -357,8 +360,10 @@ man-pages
|
|||
mcpp
|
||||
mdadm
|
||||
mediainfo
|
||||
mencoder
|
||||
mercurial
|
||||
mesa
|
||||
mesa-demos
|
||||
midori
|
||||
mime-types
|
||||
mjpegtools
|
||||
|
@ -372,7 +377,7 @@ mtdev
|
|||
mtools
|
||||
musicbrainz
|
||||
mutt
|
||||
nano
|
||||
mygui
|
||||
nasm
|
||||
ncdu
|
||||
ncurses
|
||||
|
@ -385,6 +390,10 @@ nspr
|
|||
nss
|
||||
ntfs-3g
|
||||
numlockx
|
||||
nvidia-cg-toolkit
|
||||
ogre
|
||||
ois
|
||||
openal
|
||||
opencore-amr
|
||||
openjpeg
|
||||
openslp
|
||||
|
@ -423,7 +432,6 @@ ppp
|
|||
procps-ng
|
||||
psmisc
|
||||
pth
|
||||
pwgen
|
||||
pwsafe
|
||||
pygobject2-devel
|
||||
pygtk
|
||||
|
@ -438,6 +446,7 @@ python-configobj
|
|||
python-dbus-common
|
||||
python-notify
|
||||
python-pycurl
|
||||
qt
|
||||
randrproto
|
||||
ranger
|
||||
raptor
|
||||
|
@ -462,6 +471,7 @@ shadow
|
|||
shared-color-profiles
|
||||
shared-mime-info
|
||||
slock
|
||||
smbclient
|
||||
soundtouch
|
||||
speex
|
||||
splint
|
||||
|
@ -475,9 +485,12 @@ syslog-ng
|
|||
systemd-tools
|
||||
sysvinit
|
||||
t1lib
|
||||
talloc
|
||||
tar
|
||||
task
|
||||
tcc
|
||||
tcpdump
|
||||
tdb
|
||||
texi2html
|
||||
texinfo
|
||||
tig
|
||||
|
@ -502,7 +515,6 @@ weechat
|
|||
wget
|
||||
which
|
||||
wildmidi
|
||||
wipe
|
||||
wireless_tools
|
||||
wireshark-cli
|
||||
wireshark-gtk
|
||||
|
@ -538,7 +550,6 @@ xorg-mkfontscale
|
|||
xorg-server
|
||||
xorg-server-common
|
||||
xorg-setxkbmap
|
||||
xorg-twm
|
||||
xorg-xauth
|
||||
xorg-xev
|
||||
xorg-xinit
|
||||
|
|
|
@ -93,12 +93,12 @@ fi
|
|||
[ -e "/etc/rc.conf" ] && alias ercc='sudo $EDITOR /etc/rc.conf'
|
||||
|
||||
## Xrandr
|
||||
alias xmulti="xrandr --output VGA1 --auto --right-of $(xrandr | grep -A1 current | sed -n 2p | awk '{print $1}')"
|
||||
alias xmulti='xrandr --output VGA1 --auto --right-of $(xrandr | grep -A1 current | sed -n 2p | awk '"'"'{print $1}'"'"')'
|
||||
alias xmultioff="xrandr --output VGA1 --off"
|
||||
alias xmorphsw="xrandr --output $(xrandr | grep -A1 current | sed -n 2p | awk '{print $1}') --transform 1.24,0.16,-124,0,1.24,0,0,0.000316,1"
|
||||
alias xmorphnone="xrandr --output $(xrandr | grep -A1 current | sed -n 2p | awk '{print $1}') --transform none"
|
||||
alias xmorphzo="xrandr --output $(xrandr | grep -A1 current | sed -n 2p | awk '{print $1}') --scale 1.2x1.2"
|
||||
alias xmorphzi="xrandr --output $(xrandr | grep -A1 current | sed -n 2p | awk '{print $1}') --scale 0.8x0.8"
|
||||
alias xmorphsw='xrandr --output $(xrandr | grep -A1 current | sed -n 2p | awk '"'"'{print $1}'"'"') --transform 1.24,0.16,-124,0,1.24,0,0,0.000316,1'
|
||||
alias xmorphnone='xrandr --output $(xrandr | grep -A1 current | sed -n 2p | awk '"'"'{print $1}'"'"') --transform none'
|
||||
alias xmorphzo='xrandr --output $(xrandr | grep -A1 current | sed -n 2p | awk '"'"'{print $1}'"'"') --scale 1.2x1.2'
|
||||
alias xmorphzi='xrandr --output $(xrandr | grep -A1 current | sed -n 2p | awk '"'"'@{print $1}'"'"') --scale 0.8x0.8'
|
||||
|
||||
##==============================================================================
|
||||
## Zsh power aliases
|
||||
|
|
|
@ -19,15 +19,15 @@ search()
|
|||
## Cut last n lines in file, 10 by default.
|
||||
cuttail()
|
||||
{
|
||||
nlines=${2:-10}
|
||||
#sed -n -e :a -e "1,${nlines}!{P;N;D;};N;ba" $1
|
||||
head $1 -n$(($(cat $1|wc -l) - $nlines))
|
||||
local nlines=${2:-10}
|
||||
sed -n -e :a -e "1,${nlines}!{P;N;D;};N;ba" $1
|
||||
# head $1 -n$(($(cat $1|wc -l) - $nlines))
|
||||
}
|
||||
|
||||
## Cut first n lines in file, 10 by default.
|
||||
cuthead()
|
||||
{
|
||||
nlines=${2:-10}
|
||||
local nlines=${2:-10}
|
||||
tail $1 -n$(($(cat $1|wc -l) - $nlines))
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,10 @@ cuthead()
|
|||
## Use ranger + bulkrename + vim/emacs (+ TwindleCase) for more interactivity.
|
||||
renamelower()
|
||||
{
|
||||
local file
|
||||
local filename
|
||||
local dirname
|
||||
|
||||
for file ; do
|
||||
filename=${file##*/}
|
||||
case "$filename" in
|
||||
|
@ -44,8 +48,8 @@ renamelower()
|
|||
dirname=.;;
|
||||
esac
|
||||
|
||||
nf=$(echo $filename | tr A-Z a-z)
|
||||
newname="${dirname}/${nf}"
|
||||
local nf=$(echo $filename | tr A-Z a-z)
|
||||
local newname="${dirname}/${nf}"
|
||||
if [ "$nf" != "$filename" ]; then
|
||||
mv "$file" "$newname"
|
||||
echo "lowercase: $file --> $newname"
|
||||
|
@ -67,7 +71,7 @@ renameswap()
|
|||
## Finds directory sizes and lists them for the current directory.
|
||||
dirsize ()
|
||||
{
|
||||
TEMPFILE="$(mktemp)"
|
||||
local TEMPFILE="$(mktemp)"
|
||||
# du -shx * .[a-zA-Z0-9_]* 2> /dev/null | \
|
||||
du -shx * 2> /dev/null | \
|
||||
egrep '^ *[0-9.]*[MG]' | sort -n > ${TEMPFILE}
|
||||
|
@ -162,8 +166,10 @@ blind-append()
|
|||
return
|
||||
fi
|
||||
|
||||
FILE="$1"
|
||||
STRING=""
|
||||
local FILE="$1"
|
||||
local STRING=""
|
||||
local DUMMY
|
||||
|
||||
if [ $# -eq 2 ]; then
|
||||
STRING="$2"
|
||||
fi
|
||||
|
@ -246,8 +252,8 @@ hlt-viewer ()
|
|||
fi
|
||||
|
||||
|
||||
LIST=$(highlight -w | grep -v "\s\|^$")
|
||||
SAMPLE="void function(char* pointer, int &ref)
|
||||
local LIST=$(highlight -w | grep -v "\s\|^$")
|
||||
local SAMPLE="void function(char* pointer, int &ref)
|
||||
{
|
||||
int integer=3;
|
||||
char* string=\"Hello!\";
|
||||
|
@ -310,14 +316,14 @@ pdfcompress ()
|
|||
if [ ! -f "$1" ]; then
|
||||
echo "$1 is not a valid PDF file!"
|
||||
fi
|
||||
INPUTFILE="$1"
|
||||
local INPUTFILE="$1"
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="${INPUTFILE%%.*}-COMPRESSED.pdf" "${INPUTFILE}"
|
||||
rm -rf "${INPUTFILE}"
|
||||
mv "${INPUTFILE%%.*}-COMPRESSED.pdf" "${INPUTFILE}"
|
||||
else
|
||||
OUTPUTFILE="$2"
|
||||
local OUTPUTFILE="$2"
|
||||
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile="${OUTPUTFILE}" "${INPUTFILE}"
|
||||
fi
|
||||
}
|
||||
|
@ -339,7 +345,8 @@ archive ()
|
|||
echo -e " -v:\t\tInclude VCS data."
|
||||
}
|
||||
|
||||
OPTION_VCS="--exclude-vcs"
|
||||
local OPTION_VCS="--exclude-vcs"
|
||||
local OPTION_METHOD=""
|
||||
|
||||
while getopts ":hm:v" opt; do
|
||||
case $opt in
|
||||
|
@ -365,6 +372,9 @@ archive ()
|
|||
esac
|
||||
done
|
||||
|
||||
local ARCEXT
|
||||
local ARCOPT
|
||||
|
||||
case $OPTION_METHOD in
|
||||
"gz")
|
||||
ARCEXT="tar.gz"
|
||||
|
@ -388,6 +398,10 @@ archive ()
|
|||
return 1
|
||||
fi
|
||||
|
||||
local ARCPATH
|
||||
local ARCSOURCE
|
||||
local ARCNAME
|
||||
|
||||
if [ $# -eq 1 ]; then
|
||||
ARCPATH="$(dirname $(readlink -f "$1"))"
|
||||
ARCSOURCE="$(basename $(readlink -f "$1"))"
|
||||
|
@ -406,7 +420,7 @@ archive ()
|
|||
tar -${ARCOPT} -cvf "$ARCNAME" "$ARCSOURCE" ${OPTION_VCS})
|
||||
|
||||
else
|
||||
FILELIST=()
|
||||
local FILELIST=()
|
||||
for i; do
|
||||
FILELIST=(${FILELIST[*]} "$i")
|
||||
done
|
||||
|
@ -443,13 +457,14 @@ function texclean ()
|
|||
## Clean current folder
|
||||
vcsclean()
|
||||
{
|
||||
local WORKDIR
|
||||
if [ -z "$1" ]; then
|
||||
WORKDIR="$PWD"
|
||||
else
|
||||
WORKDIR="$1"
|
||||
fi
|
||||
|
||||
unset CHOICE
|
||||
|
||||
local CHOICE
|
||||
echo "This will clean current folder from all VCS control files."
|
||||
echo -n "Proceed ? [y/N] "
|
||||
while [ -z "$CHOICE" ];
|
||||
|
@ -475,7 +490,7 @@ vcsclean()
|
|||
## LSOF stats. Print number of open files per process.
|
||||
lsofstat()
|
||||
{
|
||||
LSOFOUT=$(lsof|awk '{print $1}')
|
||||
local LSOFOUT=$(lsof|awk '{print $1}')
|
||||
|
||||
for i in $(echo $LSOFOUT |sort -u);do
|
||||
echo -n "$i "
|
||||
|
@ -492,6 +507,7 @@ formatc()
|
|||
return
|
||||
fi
|
||||
|
||||
local WORKDIR
|
||||
if [ -z "$1" ]; then
|
||||
WORKDIR="$PWD"
|
||||
else
|
||||
|
@ -575,10 +591,10 @@ bindatasearch()
|
|||
fi
|
||||
|
||||
## TODO: add option to config WORKDIR?
|
||||
WORKDIR=$PWD
|
||||
local WORKDIR=$PWD
|
||||
|
||||
## The awk command suppresses first column, spaces and line breaks.
|
||||
SOURCE=$(od -tx8 "$1" | awk '($1="")1 gsub ( /\s/,"") { printf ("%s", $0) }')
|
||||
local SOURCE=$(od -tx8 "$1" | awk '($1="")1 gsub ( /\s/,"") { printf ("%s", $0) }')
|
||||
|
||||
|
||||
## Solution 1
|
||||
|
@ -644,7 +660,7 @@ if [ -f "/usr/bin/pacman" ]; then
|
|||
echo -e " -n:\t\tSort by size."
|
||||
}
|
||||
|
||||
OPTION_SORT="cat"
|
||||
local OPTION_SORT="cat"
|
||||
|
||||
while getopts ":hn" opt; do
|
||||
case $opt in
|
||||
|
@ -675,8 +691,8 @@ if [ -f "/usr/bin/pacman" ]; then
|
|||
return 1
|
||||
fi
|
||||
|
||||
RESULT_HUMAN="$(du -bh $(pacman -Qlq "$@" | grep -v ".*/$" | sort -u) | eval ${OPTION_SORT})"
|
||||
RESULT="$(du -b $(pacman -Qlq "$@" | grep -v ".*/$" | sort -u))"
|
||||
local RESULT_HUMAN="$(du -bh $(pacman -Qlq "$@" | grep -v ".*/$" | sort -u) | eval ${OPTION_SORT})"
|
||||
local RESULT="$(du -b $(pacman -Qlq "$@" | grep -v ".*/$" | sort -u))"
|
||||
echo "${RESULT_HUMAN}"
|
||||
|
||||
echo "$RESULT" | awk -F "[[:alpha:]]" '{TOTAL=$1+TOTAL} END {printf("Total: %d KiB\n",TOTAL/1024)}'
|
||||
|
@ -711,9 +727,9 @@ if [ -f "/usr/bin/pacman" ]; then
|
|||
echo -e " -q:\t\tDisplay installed packages not included in FILE."
|
||||
}
|
||||
|
||||
OPTION_EXPLICIT=""
|
||||
OPTION_FOREIGN=""
|
||||
OPTION_LOCAL="-1"
|
||||
local OPTION_EXPLICIT=""
|
||||
local OPTION_FOREIGN=""
|
||||
local OPTION_LOCAL="-1"
|
||||
|
||||
while getopts ":hmqe" opt; do
|
||||
case $opt in
|
||||
|
@ -772,11 +788,11 @@ if [ -f "/usr/bin/pacman" ]; then
|
|||
echo -e " -q:\t\tUses installed packages database instead of repos database. It speeds up queries and allows displaying size of local packages not available in repos."
|
||||
}
|
||||
|
||||
CMD="pacman -Si"
|
||||
SEP=": "
|
||||
TOTAL_SIZE=0
|
||||
SORT="sort -u -k3"
|
||||
SORT_SIZE="cat"
|
||||
local CMD="pacman -Si"
|
||||
local SEP=": "
|
||||
local TOTAL_SIZE=0
|
||||
local SORT="sort -u -k3"
|
||||
local SORT_SIZE="cat"
|
||||
|
||||
while getopts ":hnq" opt; do
|
||||
case $opt in
|
||||
|
@ -812,7 +828,7 @@ if [ -f "/usr/bin/pacman" ]; then
|
|||
|
||||
_pacman_set_vars
|
||||
|
||||
RESULT=$(eval "${CMD} $@" | awk -F "$SEP" -v filter="$pacman_size" -v pkg="$pacman_name" \
|
||||
local RESULT=$(eval "${CMD} $@" | awk -F "$SEP" -v filter="$pacman_size" -v pkg="$pacman_name" \
|
||||
'$0 ~ pkg {pkgname=$2} $0 ~ filter {gsub(/\..*/,"") ; printf("%6s KiB %s\n", $2, pkgname)}' | eval "$SORT" | eval "$SORT_SIZE")
|
||||
|
||||
echo "$RESULT"
|
||||
|
@ -846,8 +862,8 @@ if [ -f "/usr/bin/pacman" ]; then
|
|||
echo -e " -q:\t\tUses installed packages database instead of repos database. It speeds up queries and allows displaying size of local packages not available in repos."
|
||||
}
|
||||
|
||||
CMD="pacman -Si"
|
||||
SEP=": "
|
||||
local CMD="pacman -Si"
|
||||
local SEP=": "
|
||||
|
||||
while getopts ":ahq" opt; do
|
||||
case $opt in
|
||||
|
|
Loading…
Reference in New Issue