X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;ds=sidebyside;f=bashrc;h=5c97af04936e5e407b5d83a4bb065dfa8fcc073d;hb=13517a908c6d00644d458ccf28cdff07c69bade8;hp=a2f79873cb7549180c863b23763d924784928abd;hpb=0ac08580d5068bc343f757be0a6f8b2d8e370233;p=scripts.git diff --git a/bashrc b/bashrc index a2f7987..5c97af0 100644 --- a/bashrc +++ b/bashrc @@ -92,6 +92,8 @@ export LESS_TERMCAP_me=${VT_RESET} stty -ixon +alias ..='cd ..' +alias -- -='cd -' alias rm='rm -i' alias mv='mv -i' # alias chmod='chmod -v' @@ -189,20 +191,20 @@ function cdt () { alias t='cd /tmp' function trash () { - TRASH=$(find /tmp/ -maxdepth 1 -mmin -15 -type d -name "trash-*" | sort | tail -1) + TRASH=$(date +/tmp/trash-%Y-%b-%d-%Hh) - if [[ ${TRASH} ]]; then + if [[ -d ${TRASH} ]]; then echo "Re-use ${TRASH}" else - TRASH=$(date +/tmp/trash-%Y-%b-%d-%H_%M_%S) mkdir ${TRASH} - echo "Created ${TRASH}:" + echo "Created ${TRASH}" fi mv "$@" ${TRASH} + echo "Trashed $@" } -alias trash=trash.sh +# alias trash=trash.sh function mmsget () { mplayer $1 -dumpstream -dumpfile $(basename $1) @@ -283,21 +285,13 @@ function dt () { function ifup () { echo "${VT_BOLD}${VT_GREEN_FG}This is the bash function ifup from .bashrc${VT_RESET}" - if [[ "$1" == "-s" ]]; then - chosen_ifup=$(mktemp /tmp/chosen_ifup.XXXXXX) - selector -i -d -o ${chosen_ifup} ${IFUPRC} - ARGS=$(cat ${chosen_ifup}) - rm -f ${chosen_ifup} - echo ${ARGS} >> ${IFUPRC} + if [[ ! "$@" ]] && [[ -s ${IFUPRC} ]]; then + # If we have no argument and there is a .ifuprc, use it + ARGS=$(tail -1 ${IFUPRC}) else - if [[ ! $* ]] && [[ -s ${IFUPRC} ]]; then - # If we have no argument and there is a .ifuprc, use it - ARGS=$(tail -1 ${IFUPRC}) - else - # Otherwise uses the given arguments, and store them - ARGS=$* - echo ${ARGS} >> ${IFUPRC} - fi + # Otherwise uses the given arguments, and store them + ARGS="$@" + echo ${ARGS} >> ${IFUPRC} fi echo "${VT_GREEN_FG}Running [sudo ifup ${ARGS}]${VT_RESET}" sudo ifup ${ARGS} @@ -315,13 +309,13 @@ function ifup () { function ifdown () { echo "${VT_BOLD}${VT_GREEN_FG}This is the bash function ifdown from .bashrc${VT_RESET}" - if [[ ! $* ]] && [[ -s ${IFUPRC} ]]; then + if [[ ! "$@" ]] && [[ -s ${IFUPRC} ]]; then # If there are no arguments and there is a .ifuprc, get the # interface from it ARGS=$(tail -1 ${IFUPRC} | sed -e "s/=.*$//") else # Otherwise, use the standard ifdown - ARGS=$* + ARGS="$@" fi echo "${VT_GREEN_FG}Running sudo [ifdown ${ARGS}]${VT_RESET}" sudo ifdown ${ARGS} @@ -730,7 +724,7 @@ function keep_local_history () { # mv would replace a symbolic link, while cp keeps it \cp ${TMP} ${LOCAL_HISTORY_FILE} \rm ${TMP} - LOCAL_HISTORY_HINT=" LH " + LOCAL_HISTORY_HINT="* " else LOCAL_HISTORY_HINT="" fi @@ -766,11 +760,6 @@ alias dus='dus -f -i' # alias finddup='finddup -p0d' alias finddup='finddup -p' -###################################################################### -# This script grep messages in my mail archives - -alias gma='gma.sh' - ###################################################################### # Selector based history # @@ -790,7 +779,7 @@ function selector-cd () { if [[ "$1" == "+" ]]; then PATH_TEMP=$(mktemp /tmp/selector-cd-path.XXXXXX) selector -d -i -o ${PATH_TEMP} ${CD_HISTORY} - cd $(cat ${PATH_TEMP} | sed -e "s|~|${HOME}|") + cd "$(cat ${PATH_TEMP} | sed -e 's|~|'${HOME}'|')" \rm ${PATH_TEMP} else if [[ -z "$1" ]]; then