From ba99140a996ba8a3ab2d159fbe48f4ede1a5866e Mon Sep 17 00:00:00 2001 From: Ambrevar Date: Tue, 11 Sep 2012 11:34:11 +0200 Subject: [PATCH] Shell: bash gets properly sourced when a non-login shell. Shell: fixed 'archive' function to work on multiple files with Zsh. Shell: minor fixes. --- .bash_profile | 28 +--------------------------- .bashrc | 27 +++++++++++++++++++++++++++ .pkg-arch-aur-edf23ads | 1 + .pkg-arch-official-edf23ads | 1 - .save | 4 ++-- .shell.d/funs_pacman | 7 +++---- .shell.d/funs_rc | 27 ++++++++++++++------------- .zshrc | 6 ------ 8 files changed, 48 insertions(+), 53 deletions(-) create mode 100644 .bashrc diff --git a/.bash_profile b/.bash_profile index df865ea5..da873cbc 100644 --- a/.bash_profile +++ b/.bash_profile @@ -1,27 +1 @@ -################################################################################ -## Shell Config -- Master File -## Date 2012-08-11 -################################################################################ - -##============================================================================== -## If not running interactively, don't do anything -##============================================================================== -[ -z "$PS1" ] && return - -##============================================================================== -## Sourcing -##============================================================================== - -SHELL_CURRENT="$(ps | awk -v shellpid=$$ '$0 ~ shellpid {print $4}')" -SHELL_DIR="$HOME/.shell.d" - -## Should be sourced first. -source "${SHELL_DIR}/main_rc" -source "${SHELL_DIR}/colors_bash" -source "${SHELL_DIR}/options_bash" - -## Source order should not matter. -source "${SHELL_DIR}/alias_rc" -source "${SHELL_DIR}/funs_rc" -source "${SHELL_DIR}/funs_bash" -source "${SHELL_DIR}/personal_rc" +[ -f "$HOME/.bashrc" ] && . .bashrc diff --git a/.bashrc b/.bashrc new file mode 100644 index 00000000..df865ea5 --- /dev/null +++ b/.bashrc @@ -0,0 +1,27 @@ +################################################################################ +## Shell Config -- Master File +## Date 2012-08-11 +################################################################################ + +##============================================================================== +## If not running interactively, don't do anything +##============================================================================== +[ -z "$PS1" ] && return + +##============================================================================== +## Sourcing +##============================================================================== + +SHELL_CURRENT="$(ps | awk -v shellpid=$$ '$0 ~ shellpid {print $4}')" +SHELL_DIR="$HOME/.shell.d" + +## Should be sourced first. +source "${SHELL_DIR}/main_rc" +source "${SHELL_DIR}/colors_bash" +source "${SHELL_DIR}/options_bash" + +## Source order should not matter. +source "${SHELL_DIR}/alias_rc" +source "${SHELL_DIR}/funs_rc" +source "${SHELL_DIR}/funs_bash" +source "${SHELL_DIR}/personal_rc" diff --git a/.pkg-arch-aur-edf23ads b/.pkg-arch-aur-edf23ads index c3684001..cd33d1d2 100644 --- a/.pkg-arch-aur-edf23ads +++ b/.pkg-arch-aur-edf23ads @@ -9,6 +9,7 @@ libpng12 movgrab package-query pacman-color +pdksh rxvt-unicode-patched submarine texlive-dummy diff --git a/.pkg-arch-official-edf23ads b/.pkg-arch-official-edf23ads index 12eafe7c..866993c4 100644 --- a/.pkg-arch-official-edf23ads +++ b/.pkg-arch-official-edf23ads @@ -417,7 +417,6 @@ patch pciutils pcmciautils pcre -pdksh perl perl-digest-sha1 perl-error diff --git a/.save b/.save index 01d419cd..d831165b 100755 --- a/.save +++ b/.save @@ -232,9 +232,9 @@ FILELIST=(${FILELIST[*]} ".Xresources") ##============================================================================== if [ "$DEBUG" = "yes" ]; then - tar ${ARCOPT} "$ARCHIVENAME" -C "$HOME" ${FILELIST[*]} -C "$SCRIPTPATH" "$(basename "$0")" --exclude-vcs + tar ${ARCOPT} "${ARCHIVENAME}.${ARCEXT}" -C "$HOME" ${FILELIST[*]} -C "$SCRIPTPATH" "$(basename "$0")" --exclude-vcs else - tar ${ARCOPT} "${ARCHIVENAME}.${ARCEXT}" -C "$HOME" ${FILELIST[*]} -C "$SCRIPTPATH" "$(basename "$0")" --exclude-vcs >/dev/null + tar ${ARCOPT} "${ARCHIVENAME}.${ARCEXT}" -C "$HOME" ${FILELIST[*]} -C "$SCRIPTPATH" "$(basename "$0")" --exclude-vcs >/dev/null fi ##============================================================================== diff --git a/.shell.d/funs_pacman b/.shell.d/funs_pacman index 509a2513..c7271213 100644 --- a/.shell.d/funs_pacman +++ b/.shell.d/funs_pacman @@ -15,9 +15,8 @@ ## This function gets the pacman variables when necessary. ## Note: some functions uses pacman localized output. It should work in any -## case. +## case. You should always call _pacman_unset_vars in the end. -## Note: you should always call _pacman_unset_vars in the end. _pacman_set_vars() { local pacman_var_list="$(pacman -Qi tzdata | cut -f1 -d':')" @@ -243,7 +242,7 @@ pacman-deps() echo echo "Usage:" echo -e " default:\tDisplay package dependencies. Output contains no double and is alphabetically sorted. It will only work for repos packages by default." - echo -e " -a:\t\tUses Yaourt queries instead of repos database. It slows down query but allow displaying size of local any packages not available in repos." + echo -e " -a:\t\tUses Yaourt queries instead of repos database. It slows down query but allow displaying size of any packages not available in repos." echo -e " -h:\t\tShow this help." 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." } @@ -296,7 +295,7 @@ pacman-rebuild () fi ## TODO: use args to tell what to rebuild. - # local PKG_LIST=() + # local PKG_LIST # if [ $# -eq 0 ]; then # for i in $(pacman -Qmq); do # PKG_LIST= diff --git a/.shell.d/funs_rc b/.shell.d/funs_rc index fc14a520..6eb70421 100644 --- a/.shell.d/funs_rc +++ b/.shell.d/funs_rc @@ -94,7 +94,8 @@ dirsize () ## Network operations if [ -e "/usr/bin/nmap" ]; then - network-map() { + network-map() + { echo "$1" for SCANIP in $( nmap -sL "$1" | grep -i "\([[:digit:]]\+\.\)\{3,\}[[:digit:]]\+" | awk '{print $5}' ); do sudo nmap -oX - -n -sT -T Normal -O -sR -I -F -P0 "$SCANIP" @@ -145,7 +146,8 @@ netspeed () ## ... (see 'man 5 proc' for further details) ## ## Only the first 4 values are interesting here. -cpuusage(){ +cpuusage() +{ local cpuarray local f1 local f2 @@ -393,7 +395,8 @@ fi ## Extractor -- Useless when using 'atool'. if [ ! -e "/usr/bin/atool" ]; then - extract () { + extract () + { if [ -f $1 ] ; then case $1 in *.tar.bz2) tar xvjf $1 ;; @@ -449,10 +452,10 @@ archive () printhelp() { echo "Synopsis:" - echo -e " $1 [-m METHOD] [-v] FILE" + echo -e " $1 [-m METHOD] [-v] FILES|FOLDERS" echo echo "Usage:" - echo -e " default:\tDisplay packages included in FILE but not installed." + echo -e " default:\tCreate an archive of specified FILES and/or FOLDERS." echo -e " -h:\t\tDisplay this help." echo -e " -m:\t\tChoose compression method." echo -e " gz\t\tgzip (default)." @@ -507,12 +510,6 @@ archive () shift $(($OPTIND - 1)) - if [ $# -eq 0 ]; then - echo "Missing argument." - echo "Use $0 -h for help." - return 1 - fi - local ARCPATH local ARCSOURCE local ARCNAME @@ -535,10 +532,13 @@ archive () tar -${ARCOPT} -cvf "$ARCNAME" "$ARCSOURCE" ${OPTION_VCS}) else - local FILELIST=() + ## Note for zsh: do NOT initialize an array with "myarray=()". + local FILELIST + for i; do FILELIST=(${FILELIST[*]} "$i") done + tar -${ARCOPT} -cvf "$ARCNAME" ${FILELIST[*]} ${OPTION_VCS} fi fi @@ -556,7 +556,8 @@ git-compare() } ## This function will clean TeX/LaTeX project folders recursively. -texclean () { +texclean () +{ if [ -z "$1" ]; then WORKDIR="$PWD" else diff --git a/.zshrc b/.zshrc index e5d035a2..c750560d 100644 --- a/.zshrc +++ b/.zshrc @@ -3,12 +3,6 @@ ## Date 2012-08-11 ################################################################################ -##============================================================================== -## If not running interactively, don't do anything -##============================================================================== -## Useless for Zsh ? -[ -z "$PS1" ] && return - ##============================================================================== ## Sourcing ##==============================================================================