| Line | |
|---|
| 1 | #
|
|---|
| 2 | # some usefull aliases
|
|---|
| 3 | #
|
|---|
| 4 | # WARNING:
|
|---|
| 5 | # bash aliases are not inherited to subshells,
|
|---|
| 6 | # therefore this aliases are only available at login shells.
|
|---|
| 7 | # Therefore replaced alias by exported shell functions.
|
|---|
| 8 | # Otherwise, if aliases should be available everywhere,
|
|---|
| 9 | # add following line to /etc/bash.bashrc.local:
|
|---|
| 10 | # source /etc/profile.d/dass-it.sh
|
|---|
| 11 |
|
|---|
| 12 | alias_set_real()
|
|---|
| 13 | {
|
|---|
| 14 | name=$1
|
|---|
| 15 | shift
|
|---|
| 16 | alias $name >/dev/null 2>&1 || alias $name="$@"
|
|---|
| 17 | }
|
|---|
| 18 |
|
|---|
| 19 | alias_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_real "$name" "$cmd" "$@"
|
|---|
| 33 | fi
|
|---|
| 34 | fi
|
|---|
| 35 | }
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | alias_set l "ls -la --color"
|
|---|
| 39 | alias_set ll "ls -la --color"
|
|---|
| 40 | alias_set_real .. "cd .."
|
|---|
| 41 | alias_set_real ... "cd ../.."
|
|---|
| 42 | alias_set lsst 'find -type f -printf "%T@ %T+ %P\n" | sort -n'
|
|---|
| 43 | alias_set rpm_disturl 'rpm -q --qf "%{DISTURL}\n"'
|
|---|
| 44 | alias_set rpm_sortsize 'rpm -qa --qf "%{SIZE} %{NAME}\n" | sort -n'
|
|---|
| 45 | alias_set rscp 'rsync -av --progress --compress'
|
|---|
| 46 |
|
|---|
| 47 | setproxy()
|
|---|
| 48 | {
|
|---|
| 49 | PAR="$1"
|
|---|
| 50 | if [ -z "$PAR" ]; then
|
|---|
| 51 | unset http_proxy
|
|---|
| 52 | unset https_proxy
|
|---|
| 53 | return
|
|---|
| 54 | fi
|
|---|
| 55 |
|
|---|
| 56 | if [[ "$PAR" == http* ]]; then
|
|---|
| 57 | PROXY="$PAR"
|
|---|
| 58 | else
|
|---|
| 59 | PROXY="http://$PAR"
|
|---|
| 60 | fi
|
|---|
| 61 | export http_proxy="$PROXY"
|
|---|
| 62 | export https_proxy="$PROXY"
|
|---|
| 63 | echo $http_proxy
|
|---|
| 64 | }
|
|---|
| 65 | if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then
|
|---|
| 66 | export -f setproxy
|
|---|
| 67 | fi
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.