X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=blobdiff_plain;f=bashrc;h=6c908f49edefe146990e35d6fb62f661aa930166;hb=f8342131f317c55351b29af45d640b007d66e754;hp=6b4d7bbb0a3edf5d57cbba60ba0f2a987ede0cd4;hpb=e7175dc5672bde26a54dad581d2614574428ff77;p=scripts.git diff --git a/bashrc b/bashrc index 6b4d7bb..6c908f4 100644 --- a/bashrc +++ b/bashrc @@ -107,6 +107,8 @@ alias ps='ps uxaf' alias df='df -hT --sync' alias grep='grep -E --mmap --color=auto' alias find='ionice -c3 find' +alias pd=pushd +alias val='valgrind --leak-check=full --show-reachable=yes --db-attach=yes ' alias s='screen -d -R -U && clear' @@ -159,6 +161,33 @@ function bak () { done } +function ua () { + while [[ "$1" ]]; do + + case "$1" in + + *.tgz|*.tar.gz) + tar zxvf "$1" + ;; + + *.rar) + unrar x "$1" + ;; + + *.zip) + unzip "$1" + ;; + + *) + echo "Unknown file extension $1" + ;; + esac + + shift + + done +} + # Create a dir and cd there function mcd () { @@ -315,7 +344,12 @@ function netup () { echo ${ARGS} > ${NETUP_HISTORY} fi - echo "${VT_GREEN_FG}Running [sudo ifup ${ARGS}]${VT_RESET}" + if [[ $(ps auxwww | grep dhclient | grep -v grep) ]]; then + echo "There is already a dhcp client running." >&2 + return 1 + fi + + echo "${VT_GREEN_FG}Executing [sudo ifup ${ARGS}]${VT_RESET}" sudo ifup ${ARGS} # Ugly hack to remove the dsl modem dns server when we add @@ -324,7 +358,7 @@ function netup () { REMOVE_LOCAL_DNS=/usr/local/bin/remove-local-dns.sh if [[ -x ${REMOVE_LOCAL_DNS} ]]; then - echo "${VT_GREEN_FG}Running [sudo ${REMOVE_LOCAL_DNS} 192.168]${VT_RESET}" + echo "${VT_GREEN_FG}Executing [sudo ${REMOVE_LOCAL_DNS} 192.168]${VT_RESET}" sudo ${REMOVE_LOCAL_DNS} 192.168 fi } @@ -338,7 +372,7 @@ function netdown () { # Otherwise, use the standard ifdown ARGS="$@" fi - echo "${VT_GREEN_FG}Running sudo [ifdown ${ARGS}]${VT_RESET}" + echo "${VT_GREEN_FG}Executing sudo [ifdown ${ARGS}]${VT_RESET}" sudo ifdown ${ARGS} } @@ -801,7 +835,7 @@ alias finddup='finddup -p' # git clone http://fleuret.org/git/selector/ function selector-history () { - selector --bash -c 7,4,0,3 -q <(history) + selector --bash -u -c 7,4,0,3 -q <(history) } # M-r puts the selected history line in place of the current one @@ -821,13 +855,6 @@ export SELECTOR_CD_HISTORY [[ "${SELECTOR_CD_HISTORY}" ]] || \ SELECTOR_CD_HISTORY=${HOME}/.selector-cd-history -function selector-cd-search () { - PATH_TEMP=$(mktemp /tmp/selector-cd-path.XXXXXX) - selector -t "cd" -l 10000 -d -i -o ${PATH_TEMP} -q ${SELECTOR_CD_HISTORY} - cd "$(cat ${PATH_TEMP} | sed -e 's!~!'${HOME}'!')" - \rm ${PATH_TEMP} -} - function selector-cd () { if [[ -z "$1" ]]; then cd @@ -837,6 +864,13 @@ function selector-cd () { echo $PWD | sed -e "s!${HOME}!~!" >> ${SELECTOR_CD_HISTORY} } +function selector-cd-search () { + PATH_TEMP=$(mktemp /tmp/selector-cd-path.XXXXXX) + selector -t "cd" -l 10000 -d -i -c 7,4,0,7 -o ${PATH_TEMP} -q ${SELECTOR_CD_HISTORY} + selector-cd "$(cat ${PATH_TEMP} | sed -e 's!~!'${HOME}'!')" + \rm ${PATH_TEMP} +} + alias cd=selector-cd # M-c provides a dynamic list of directories to cd into @@ -866,6 +900,8 @@ function prompt_command () { # save the history after every command to avoid loosing some when # multiple shells are open history -a +# load the saved history + history -n # and the local histories system defined above keep_local_history # and the history cue