diff --git a/zsh/.zshenv b/zsh/.zshenv new file mode 100644 index 0000000..e97c192 --- /dev/null +++ b/zsh/.zshenv @@ -0,0 +1,47 @@ +# Create XDG basedir settings if not set +if [ -z $XDG_CONFIG_HOME ]; then + export XDG_CONFIG_HOME="$HOME/.config" +fi +if [ -z $XDG_CACHE_HOME ]; then + export XDG_CACHE_HOME="$HOME/.cache" +fi +if [ -z $XDG_DATA_HOME ]; then + export XDG_DATA_HOME="$HOME/.local/share" +fi + +# Some systems do not set XDG_RUNTIME_DIR, create an alternative. +if [ -z $XDG_RUNTIME_DIR ]; then + if [ -n $TMPDIR ]; then + XDG_RUNTIME_DIR = "$TMPDIR/$USERNAME/" + else + XDG_RUNTIME_DIR = "/tmp/$USERNAME/" + fi + + chmod 700 "$XDG_RUNTIME_DIR" + export XDG_RUNTIME_DIR +fi + +# Set up less +export LESS='-x4 -SR' +export LESSHISTFILE="$XDG_DATA_HOME/less/history" +test -d $(dirname $LESSHISTFILE) || mkdir -p $(dirname $LESSHISTFILE) + +# Set up editor and vim +if hash vim &> /dev/null; then + export EDITOR=vim +fi + +# Set up compoer +export COMPOSER_HOME="$XDG_CONFIG_HOME/composer" +export COMPOSER_CACHE_DIR="$XDG_CACHE_HOME/composer" + +if [ -d "$COMPOSER_HOME/vendor/bin" ]; then + path+="$COMPOSER_HOME/vendor/bin" +fi + +# Set up wine +export WINEPREFIX="$XDG_DATA_HOME/wine" + +# Setup tmux +test -f "$XDG_CONFIG_HOME/tmux/tmux.conf" && alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf" +export TMUX_TMPDIR="$XDG_RUNTIME_DIR"/tmux diff --git a/zsh/.zshrc b/zsh/.zshrc index 9fc3698..99ea70f 100644 --- a/zsh/.zshrc +++ b/zsh/.zshrc @@ -20,8 +20,6 @@ then alias fuck='$(thefuck $(fc -ln -1))' fi -export EDITOR=$(which vim) - # Initialize the prompt autoload -U promptinit promptinit @@ -56,15 +54,6 @@ alias help=run-help # Set sensible tab width tabs -4 -# Add Composer binaries -if [ -d "$HOME/.composer/vendor/bin" ]; then - path+=("$HOME/.composer/vendor/bin") -fi - -if [ -d "$HOME/.config/composer/vendor/bin" ]; then - path+=("$HOME/.config/composer/vendor/bin") -fi - # No matches found for "*" unsetopt nomatch @@ -88,25 +77,6 @@ fi bindkey "${terminfo[khome]}" beginning-of-line bindkey "${terminfo[kend]}" end-of-line -# XDG Base directory support -export XDG_CONFIG_HOME="$HOME/.config" -export XDG_CACHE_HOME="$HOME/.cache" -export XDG_DATA_HOME="$HOME/.local/share" - -# Additional XDG Base directory files, with partial support. -export COMPOSER_HOME="$XDG_CONFIG_HOME"/composer -export COMPOSER_CACHE_DIR="$XDG_CACHE_HOME"/composer - -export WINEPREFIX="$XDG_DATA_HOME"/wine - -export LESSHISTFILE="$XDG_DATA_HOME/less/history" -if [ ! -d $(dirname $LESSHISTFILE) ] -then - mkdir -p $(dirname $LESSHISTFILE) -fi - -alias tmux="tmux -f $XDG_CONFIG_HOME/tmux/tmux.conf" - # Transfer.sh plugin transfer() { if [ $# -eq 0 ]; then echo "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md"; return 1; fi tmpfile=$( mktemp -t transferXXX ); if tty -s; then basefile=$(basename "$1" | sed -e 's/[^a-zA-Z0-9._-]/-/g'); curl --progress-bar --upload-file "$1" "https://transfer.sh/$basefile" >> $tmpfile; else curl --progress-bar --upload-file "-" "https://transfer.sh/$1" >> $tmpfile ; fi; cat $tmpfile; rm -f $tmpfile; }; alias transfer=transfer