Skip to content

Commit

Permalink
start moving stuff out to .shared_env.d/
Browse files Browse the repository at this point in the history
  • Loading branch information
aspiers committed May 16, 2018
1 parent a0834dd commit 98f689b
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 71 deletions.
71 changes: 0 additions & 71 deletions .shared_env
Original file line number Diff line number Diff line change
Expand Up @@ -98,24 +98,6 @@ export ZDOTUSER

# }}}

# {{{ HOST / HOSTNAME

: ${HOST:=${HOSTNAME:-`hostname`}}
: ${HOSTNAME:=$HOST}

# Let's not make this *too* sticky because dhcp might change the host
#export HOST HOSTNAME

# }}}
# {{{ USER / USERNAME

# zsh sets USERNAME, GROUPS, and E?[UG]ID
# bash only sets E?UID
USER=${USERNAME:-`id -un`}
: ${USERNAME:=$USER}
export USER USERNAME

# }}}
# {{{ PATH

# Don't trust system-wide PATH? Remember what it was, for reference.
Expand Down Expand Up @@ -154,59 +136,6 @@ PATH=$newpaths:$PATH

# In order to avoid forks here, this is done in .zshrc

# }}}
# {{{ Perl libraries

export PERL5LIB

add_perl5lib_path () {
new_path="$1"
case "$PERL5LIB" in
'')
PERL5LIB=$new_path
;;

$new_path|*:$new_path|$new_path:*|*:$new_path:*)
: #echo "$newpaths already in \$PERL5LIB"
;;
*)
PERL5LIB=$new_path:$PERL5LIB
;;
esac
}

for dir in $ZDOTDIRREVPATH; do
add_perl5lib_path $dir/lib/perl5
add_perl5lib_path $dir/lib/perl5/site_perl

# # Use a cache to avoid invoking Perl during startup of every single
# # shell (even non-interactive ones).
# cachedir=$dir/.config/perl
# cache=$cachedir/pmdir_relative_path
# if [ -e $cache ]; then
# pmdir_relative_path=$(<$cache)
# else
# # This trick comes from Stow's configure.ac
# pmdir_relative_path=`
# perl -MConfig \
# -wle '($_ = $Config{installsitelib})
# =~ s!^\Q$Config{siteprefix}/!!; \
# print'`
# mkdir -p $cachedir
# echo "$pmdir_relative_path" > $cache
# fi
#
# if [ -n "$pmdir_relative_path" ]; then
# add_perl5lib_path $dir/$pmdir_relative_path
# fi
done

# }}}
# {{{ OSTYPE

# Can come in handy too, if the shell sets it (bash and zsh do).
export OSTYPE

# }}}

. $ZDOT_RUN_HOOKS .shared_env.d
Expand Down
7 changes: 7 additions & 0 deletions .shared_env.d/00-hostname
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: sh -*-

: ${HOST:=${HOSTNAME:-`hostname`}}
: ${HOSTNAME:=$HOST}

# Let's not make this *too* sticky because dhcp might change the host
#export HOST HOSTNAME
4 changes: 4 additions & 0 deletions .shared_env.d/00-ostype
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# -*- mode: sh -*-

# Can come in handy too, if the shell sets it (bash and zsh do).
export OSTYPE
7 changes: 7 additions & 0 deletions .shared_env.d/00-user
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- mode: sh -*-

# zsh sets USERNAME, GROUPS, and E?[UG]ID
# bash only sets E?UID
USER=${USERNAME:-`id -un`}
: ${USERNAME:=$USER}
export USER USERNAME
45 changes: 45 additions & 0 deletions .shared_env.d/10-Perl
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# -*- mode: sh -*-

export PERL5LIB

add_perl5lib_path () {
new_path="$1"
case "$PERL5LIB" in
'')
PERL5LIB=$new_path
;;

$new_path|*:$new_path|$new_path:*|*:$new_path:*)
: #echo "$newpaths already in \$PERL5LIB"
;;
*)
PERL5LIB=$new_path:$PERL5LIB
;;
esac
}

for dir in $ZDOTDIRREVPATH; do
add_perl5lib_path $dir/lib/perl5
add_perl5lib_path $dir/lib/perl5/site_perl

# # Use a cache to avoid invoking Perl during startup of every single
# # shell (even non-interactive ones).
# cachedir=$dir/.config/perl
# cache=$cachedir/pmdir_relative_path
# if [ -e $cache ]; then
# pmdir_relative_path=$(<$cache)
# else
# # This trick comes from Stow's configure.ac
# pmdir_relative_path=`
# perl -MConfig \
# -wle '($_ = $Config{installsitelib})
# =~ s!^\Q$Config{siteprefix}/!!; \
# print'`
# mkdir -p $cachedir
# echo "$pmdir_relative_path" > $cache
# fi
#
# if [ -n "$pmdir_relative_path" ]; then
# add_perl5lib_path $dir/$pmdir_relative_path
# fi
done

0 comments on commit 98f689b

Please sign in to comment.