Changeset 1202 for dass-tools


Ignore:
Timestamp:
Oct 19, 2015, 4:30:25 PM (9 years ago)
Author:
joergs
Message:

replace alias by exported function, so it must only be defined in
profile.d

File:
1 edited

Legend:

Unmodified
Added
Removed
  • dass-tools/etc/profile.d/dass-it.sh

    r1119 r1202  
    55#   bash aliases are not inherited to subshells,
    66#   therefore this aliases are only available at login shells.
    7 #   If theses aliases should be available everywhere,
     7#   Therefore replaced alias by exported shell functions.
     8#   Otherwise, if aliases should be available everywhere,
    89#   add following line to /etc/bash.bashrc.local:
    910#   source /etc/profile.d/dass-it.sh
    1011
    11 alias_set()
     12alias_set_old()
    1213{
    1314  name=$1
     
    1617}
    1718
     19alias_set()
     20{
     21  name=$1
     22  shift
     23  cmd=$1
     24  shift
     25  if ! type $name >/dev/null 2>&1; then
     26    if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
     27      eval "$name() {
     28        $cmd \"\$@\"
     29      }
     30      export -f $name"
     31    else
     32      alias_set_old "$name" "$cmd" "$@"
     33    fi
     34  fi
     35}
     36
     37
    1838alias_set l "ls -la"
    19 alias_set  .. "cd .."
    20 alias_set  ... "cd ../.."
     39alias_set .. "cd .."
     40alias_set ... "cd ../.."
    2141alias_set lsst 'find -type f -printf "%T@  %T+   %P\n" | sort -n'
    2242alias_set rpm-disturl 'rpm -q --qf "%{DISTURL}\n"'
    2343alias_set rpm-sortsize 'rpm -qa --qf "%{SIZE} %{NAME}\n" | sort -n'
    2444alias_set rscp 'rsync -av --progress --compress'
     45
     46setproxy()
     47{
     48    PAR="$1"
     49    if [ -z "$PAR" ]; then
     50        unset http_proxy
     51        unset https_proxy
     52        return
     53    fi
     54
     55    if [[ "$PAR" == http* ]]; then
     56        PROXY="$PAR"
     57    else
     58        PROXY="http://$PAR"
     59    fi
     60    export http_proxy="$PROXY"
     61    export https_proxy="$PROXY"
     62    echo $http_proxy
     63}
     64if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
     65    export -f setproxy
     66fi
Note: See TracChangeset for help on using the changeset viewer.