Browse Source

now shrc can be invoked as a script

pull/1/head
10sr 11 years ago
parent
commit
59ba52e2b5
1 changed files with 24 additions and 9 deletions
  1. +24
    -9
      shrc

+ 24
- 9
shrc View File

@@ -1,13 +1,7 @@
#!/bin/bash
#!/bin/sh


# TODO: use tput # TODO: use tput


# If not running interactively, don't do anything
alias isinteractive=false
expr "$-" : '^.*i' >/dev/null && alias isinteractive=true

isinteractive || return

########################################## ##########################################
null(){ null(){
"$@" >/dev/null 2>&1 "$@" >/dev/null 2>&1
@@ -17,11 +11,16 @@ __try_exec(){
} }


__match(){ __match(){
# __match str1 str2
# return 0 if str2 is found in str1
# __match str word
# return 0 if word is found in str
expr "$1" : ".*$2.*" >/dev/null expr "$1" : ".*$2.*" >/dev/null
} }


alias isinteractive=false
__match "$-" i >/dev/null && alias isinteractive=true
alias issourced=true
expr "$0" : "^.*shrc$" >/dev/null && alias issourced=false # invoked as script

########################## ##########################
# system type # system type


@@ -55,6 +54,18 @@ fi


################################# #################################


if inbash
then
shrc="$BASH_SOURCE"
elif inzsh
then
shrc="$0"
fi

dotdir="`dirname "$shrc"`"

#################################

alias firstload=false alias firstload=false
__match "$PATH" "$HOME/.local/bin" || alias firstload=true __match "$PATH" "$HOME/.local/bin" || alias firstload=true


@@ -175,6 +186,10 @@ fi


####################### #######################


# If not running interactively, don't do anything
issourced || exit
isinteractive || return

iswindows && alias tty="echo cmd.exe" iswindows && alias tty="echo cmd.exe"
type fortune >/dev/null 2>&1 && { type fortune >/dev/null 2>&1 && {
fortune fortune


Loading…
Cancel
Save