mirror of
https://github.com/NaomiAmethyst/dots.git
synced 2025-08-05 16:48:38 +00:00
- fixed a bug here and there
- made it fully sh compliant (works even with solaris sh)
This commit is contained in:
parent
456dcf255d
commit
b3c9a9c6e9
8 changed files with 70 additions and 51 deletions
|
@ -1,25 +1,27 @@
|
||||||
if [[ -d /opt/local/man ]] ; then
|
#! /bin/sh
|
||||||
if [[ -z "${MANPATH}" ]] ; then
|
|
||||||
MANPATH="/opt/local/man":$(manpath)
|
if [ -d /opt/local/man ] ; then
|
||||||
|
if [ -z "${MANPATH}" ] ; then
|
||||||
|
MANPATH="/opt/local/man":`manpath`
|
||||||
else
|
else
|
||||||
MANPATH="/opt/local/man:${MANPATH}"
|
MANPATH="/opt/local/man:${MANPATH}"
|
||||||
fi
|
fi
|
||||||
export MANPATH
|
export MANPATH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d /opt/local/bin ]] ; then
|
if [ -d /opt/local/bin ] ; then
|
||||||
if [[ -z "${PATH}" ]] ; then
|
if [ -z "${PATH}" ] ; then
|
||||||
PATH="/opt/local/bin"
|
PATH="/opt/local/bin"
|
||||||
else
|
else
|
||||||
PATH="/opt/local/bin:${PATH}"
|
PATH="/opt/local/bin:${PATH}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d /opt/local/sbin ]] ; then
|
if [ -d /opt/local/sbin ] ; then
|
||||||
PATH="/opt/local/sbin:${PATH}"
|
PATH="/opt/local/sbin:${PATH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d /opt/local/libexec ]] ; then
|
if [ -d /opt/local/libexec ] ; then
|
||||||
PATH="/opt/local/libexec:${PATH}"
|
PATH="/opt/local/libexec:${PATH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,9 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
# terminal fallback stuff
|
# terminal fallback stuff
|
||||||
function fix_term ()
|
fix_term ()
|
||||||
{
|
{
|
||||||
if (infocmp $1 &> /dev/null) ; then
|
if (infocmp $1 > /dev/null 2>&1) ; then
|
||||||
echo $1
|
echo $1
|
||||||
else
|
else
|
||||||
case $1 in
|
case $1 in
|
||||||
|
@ -28,12 +30,14 @@ function fix_term ()
|
||||||
}
|
}
|
||||||
|
|
||||||
# sorta hacky, but I cannot find a better way to do this :/
|
# sorta hacky, but I cannot find a better way to do this :/
|
||||||
function fix_terminfo_db ()
|
fix_terminfo_db ()
|
||||||
{
|
{
|
||||||
if [[ `type -p infocmp` = "$1/bin/infocmp" ]] ; then
|
if [ `command -v infocmp` = "$1/bin/infocmp" ] ; then
|
||||||
export TERMINFO="$1/share/terminfo"
|
TERMINFO="$1/share/terminfo"
|
||||||
|
export TERMINFO
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# terminal surgery
|
# terminal surgery
|
||||||
case `uname -s` in
|
case `uname -s` in
|
||||||
Interix)
|
Interix)
|
||||||
|
@ -42,11 +46,19 @@ case `uname -s` in
|
||||||
SunOS)
|
SunOS)
|
||||||
fix_terminfo_db "/opt/csw"
|
fix_terminfo_db "/opt/csw"
|
||||||
;;
|
;;
|
||||||
|
Darwin)
|
||||||
|
fix_terminfo_db "/opt/local"
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
export TERM=$(fix_term $TERM)
|
TERM=`fix_term $TERM`
|
||||||
|
export TERM
|
||||||
if [[ $TERM == *256* ]] && (infocmp screen-256color-bce &> /dev/null) ; then
|
|
||||||
export SCREEN_COLOR="-256color"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
case $TERM in
|
||||||
|
*256*)
|
||||||
|
if (infocmp screen-256color-bce > /dev/null 2>&1) ; then
|
||||||
|
SCREEN_COLOR="-256color"
|
||||||
|
export SCREEN_COLOR
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
|
#! /bin/sh
|
||||||
# colors
|
# colors
|
||||||
for dircolors in gdircolors dircolors ; do
|
for dircolors in gdircolors dircolors ; do
|
||||||
if (type -p $dircolors &> /dev/null) ; then
|
if (command -v $dircolors > /dev/null 2>&1) ; then
|
||||||
[ -f /etc/DIR_COLORS ] && eval $($dircolors -b /etc/DIR_COLORS) && break
|
[ -f /etc/DIR_COLORS ] && eval `$dircolors -b /etc/DIR_COLORS` && break
|
||||||
[ -f "${HOME}/.dir_colors" ] && eval $($dircolors -b "${HOME}/.dir_colors") && break
|
[ -f "${HOME}/.dir_colors" ] && eval `$dircolors -b "${HOME}/.dir_colors"` && break
|
||||||
eval $($dircolors -b) && break
|
eval `$dircolors -b` && break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# gimmie an editor, make it a nice vi clone
|
# gimmie an editor, make it a nice vi clone
|
||||||
for EDITOR in vim elvis vile nvi vi ; do
|
for EDITOR in vim elvis vile nvi vi ; do
|
||||||
(type -p $EDITOR &> /dev/null) && break
|
(command -v $EDITOR > /dev/null 2>&1) && break
|
||||||
done
|
done
|
||||||
export EDITOR
|
export EDITOR
|
||||||
|
|
||||||
|
@ -23,7 +24,8 @@ case `uname -s` in
|
||||||
alias grep='grep -d skip --color=auto'
|
alias grep='grep -d skip --color=auto'
|
||||||
;;
|
;;
|
||||||
FreeBSD|Darwin|DragonFly)
|
FreeBSD|Darwin|DragonFly)
|
||||||
export LSCOLORS=ExGxFxDxCxDxDxHbaDacec
|
LSCOLORS=ExGxFxDxCxDxDxHbaDacec
|
||||||
|
export LSCOLORS
|
||||||
alias ls="ls -Gh"
|
alias ls="ls -Gh"
|
||||||
alias grep='grep -d skip --color=auto'
|
alias grep='grep -d skip --color=auto'
|
||||||
;;
|
;;
|
||||||
|
@ -31,18 +33,18 @@ case `uname -s` in
|
||||||
alias ls="ls --color"
|
alias ls="ls --color"
|
||||||
;;
|
;;
|
||||||
SunOS)
|
SunOS)
|
||||||
if (type -p gls &> /dev/null) ; then
|
if (command -v gls > /dev/null 2>&1) ; then
|
||||||
alias ls="gls -h --color=auto"
|
alias ls="gls -h --color=auto"
|
||||||
else
|
else
|
||||||
alias ls="ls -h"
|
alias ls="ls -h"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if (type -p ggrep &> /dev/null) ; then
|
if (command -v ggrep > /dev/null 2>&1) ; then
|
||||||
alias grep='ggrep -d skip --color=auto'
|
alias grep='ggrep -d skip --color=auto'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for locate in glocate slocate ; do
|
for locate in glocate slocate ; do
|
||||||
(type -p $locate &> /dev/null) && alias locate=$locate
|
(command -v $locate > /dev/null 2>&1) && alias locate=$locate
|
||||||
done
|
done
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
@ -52,4 +54,4 @@ alias du='du -h'
|
||||||
|
|
||||||
alias ping='ping -c4'
|
alias ping='ping -c4'
|
||||||
|
|
||||||
(type -p time &> /dev/null) && alias time='command time'
|
(command -v time > /dev/null 2>&1) && alias time='command time'
|
||||||
|
|
|
@ -1,21 +1,23 @@
|
||||||
if [[ -d /usr/local/git/man ]] ; then
|
#! /bin/sh
|
||||||
if [[ -z "${MANPATH}" ]] ; then
|
|
||||||
MANPATH="/usr/local/git/man":$(manpath)
|
if [ -d /usr/local/git/man ] ; then
|
||||||
|
if [ -z "${MANPATH}" ] ; then
|
||||||
|
MANPATH="/usr/local/git/man":`manpath`
|
||||||
else
|
else
|
||||||
MANPATH="/usr/local/git/man:${MANPATH}"
|
MANPATH="/usr/local/git/man:${MANPATH}"
|
||||||
fi
|
fi
|
||||||
export MANPATH
|
export MANPATH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d /usr/local/git/bin ]] ; then
|
if [ -d /usr/local/git/bin ] ; then
|
||||||
if [[ -z "${PATH}" ]] ; then
|
if [ -z "${PATH}" ] ; then
|
||||||
PATH="/usr/local/git/bin"
|
PATH="/usr/local/git/bin"
|
||||||
else
|
else
|
||||||
PATH="/usr/local/git/bin:${PATH}"
|
PATH="/usr/local/git/bin:${PATH}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -d /usr/local/git/libexec/git-core ]] ; then
|
if [ -d /usr/local/git/libexec/git-core ] ; then
|
||||||
PATH="/usr/local/git/libexec/git-core:${PATH}"
|
PATH="/usr/local/git/libexec/git-core:${PATH}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -1,17 +1,18 @@
|
||||||
for PAGER in less more pg ; do
|
for PAGER in less more pg ; do
|
||||||
(type -p $PAGER &> /dev/null) && break
|
(command -v $PAGER > /dev/null 2>&1) && break
|
||||||
done
|
done
|
||||||
export PAGER
|
export PAGER
|
||||||
|
|
||||||
# if we are in less, we can set some options and use lesspipe
|
# if we are in less, we can set some options and use lesspipe
|
||||||
if [[ $PAGER = "less" ]] ; then
|
if [ $PAGER = less ] ; then
|
||||||
# lesspipe can go by either lesspipe or lesspipe.sh
|
# lesspipe can go by either lesspipe or lesspipe.sh
|
||||||
for lesspipe in lesspipe lesspipe.sh ; do
|
for lesspipe in lesspipe lesspipe.sh ; do
|
||||||
if (type -p $lesspipe &> /dev/null) ; then
|
if (command -v $lesspipe > /dev/null 2>&1) ; then
|
||||||
eval $(SHELL=/bin/sh $lesspipe) && break
|
eval `SHELL=/bin/sh $lesspipe` && break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# let less be case insensitive
|
# let less be case insensitive
|
||||||
export LESS='-i -R -M'
|
LESS='-R -M'
|
||||||
|
export LESS
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
#! /bin/sh
|
||||||
for wrap in rlwrap rlfe cle ; do
|
for wrap in rlwrap rlfe cle ; do
|
||||||
(type -p $wrap &> /dev/null) && alias ocaml="$wrap ocaml" && break
|
(command -v $wrap > /dev/null 2>&1) && alias ocaml="$wrap ocaml" && break
|
||||||
done
|
done
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
|
#! /bin/sh
|
||||||
# utility.sh
|
# utility.sh
|
||||||
# Miscellaneous Utility Functions
|
# Miscellaneous Utility Functions
|
||||||
|
|
||||||
function unkey-host ()
|
unkey_host ()
|
||||||
{
|
{
|
||||||
[ ${#} -ne 1 ] && return 1
|
[ ${#} -ne 1 ] && return 1
|
||||||
sed -i -e "/$1/d" $HOME/.ssh/known_hosts
|
sed -i -e "/$1/d" $HOME/.ssh/known_hosts
|
||||||
}
|
}
|
||||||
|
|
||||||
function mkcd ()
|
mkcd ()
|
||||||
{
|
{
|
||||||
if [[ -d "$1" ]] ; then
|
if [ -d "$1" ] ; then
|
||||||
cd "$1"
|
cd "$1"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
@ -17,16 +18,14 @@ function mkcd ()
|
||||||
mkdir -p "$1" && cd "$1"
|
mkdir -p "$1" && cd "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function extract ()
|
extract ()
|
||||||
{
|
{
|
||||||
if [[ ! -f "$1" ]] ; then
|
if [ ! -f "$1" ] ; then
|
||||||
echo "The file ("$1") does not exist!"
|
echo "The file ("$1") does not exist!"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local filename
|
filename=`echo "$1" | tr '[:upper:]' '[:lower:]'`
|
||||||
|
|
||||||
filename=$(echo "$1" | tr '[:upper:]' '[:lower:]')
|
|
||||||
|
|
||||||
case "$filename" in
|
case "$filename" in
|
||||||
*.tar)
|
*.tar)
|
||||||
|
@ -42,10 +41,10 @@ function extract ()
|
||||||
unzip -qo "${1}"
|
unzip -qo "${1}"
|
||||||
;;
|
;;
|
||||||
*.gz|*.z)
|
*.gz|*.z)
|
||||||
gzip -dc "${1}" > $(basename "${1%.*}")
|
gzip -dc "${1}" > `basename "${1%.*}"`
|
||||||
;;
|
;;
|
||||||
*.bz2)
|
*.bz2)
|
||||||
bzip2 -dc "${1}" > $(basename "${1%.*}")
|
bzip2 -dc "${1}" > `basename "${1%.*}"`
|
||||||
;;
|
;;
|
||||||
*.rar)
|
*.rar)
|
||||||
unrar x -idq "${1}"
|
unrar x -idq "${1}"
|
||||||
|
@ -60,7 +59,7 @@ function extract ()
|
||||||
lzma -dc "${1}" | tar xf
|
lzma -dc "${1}" | tar xf
|
||||||
;;
|
;;
|
||||||
*.lzma)
|
*.lzma)
|
||||||
lzma -dc "${1}" > $(basename "${1%.*}")
|
lzma -dc "${1}" > `basename "${1%.*}"`
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unable to extract '"$1"'"
|
echo "Unable to extract '"$1"'"
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/sh
|
#! /bin/sh
|
||||||
# Decode file for less
|
# Decode file for less
|
||||||
case `echo "$1" | tr '[:upper:]' '[:lower:]'` in
|
case `echo "$1" | tr '[:upper:]' '[:lower:]'` in
|
||||||
# we don't handle archives, we let the big guy do it
|
# we don't handle archives, we let the big guy do it
|
||||||
|
|
Loading…
Add table
Reference in a new issue