From 52e20aca38dc6b678d66ce7a123e680968ce84b5 Mon Sep 17 00:00:00 2001 From: Loic Nageleisen Date: Tue, 6 Jul 2021 15:01:05 +0200 Subject: [PATCH] Add direnv support --- bash/ext | 2 ++ bash/rc | 1 + shell/direnv | 21 +++++++++++++++++++++ shell/docker | 2 ++ zsh/rc | 2 ++ 5 files changed, 28 insertions(+) create mode 100755 shell/direnv diff --git a/bash/ext b/bash/ext index abce399..4df0923 100644 --- a/bash/ext +++ b/bash/ext @@ -4,6 +4,8 @@ # Hooks # derived from http://glyf.livejournal.com/63106.html +# TODO: support precmd_functions and chpwd_functions arrays + # default: NOOPs function preexec { :; } function precmd { :; } diff --git a/bash/rc b/bash/rc index 3e80c11..817567e 100644 --- a/bash/rc +++ b/bash/rc @@ -20,6 +20,7 @@ GIT_PS1_SHOWUNTRACKEDFILES=1 precmd() { LAST_CMD_RC=$? + _direnv_hook #clear_incomplete_line set_prompt update_terminal_cwd diff --git a/shell/direnv b/shell/direnv new file mode 100755 index 0000000..51ac750 --- /dev/null +++ b/shell/direnv @@ -0,0 +1,21 @@ +if command -v direnv 2>&1 >/dev/null; then + if [[ -n $BASH_VERSION ]]; then + # eval "$(direnv hook bash)" + _direnv_hook() { + local previous_exit_status=$?; + trap -- '' SIGINT; + eval "$("${HOME}/.nix-profile/bin/direnv" export bash)"; + trap - SIGINT; + return $previous_exit_status; + }; + fi + if [[ -n $ZSH_VERSION ]]; then + # eval "$(direnv hook zsh)" + _direnv_hook() { + trap -- '' SIGINT; + eval "$("${HOME}/.nix-profile/bin/direnv" export zsh)"; + trap - SIGINT; + } + fi +fi + diff --git a/shell/docker b/shell/docker index 0c9e333..f8ff3ca 100755 --- a/shell/docker +++ b/shell/docker @@ -5,4 +5,6 @@ #export DOCKER_CERT_PATH="/Users/lloeki/.docker/machine/machines/default" #export DOCKER_MACHINE_NAME="default" +export DOCKER_HOST=ssh://172.16.50.2 + # vim: ft=bash diff --git a/zsh/rc b/zsh/rc index 2b17273..935fed9 100644 --- a/zsh/rc +++ b/zsh/rc @@ -13,6 +13,7 @@ source $DOTFILES_ZSH_DIR/completion source $DOTFILES_ZSH_DIR/prompt source $DOTFILES_ZSH_DIR/fzf source $DOTFILES_SHELL_DIR/go +source $DOTFILES_SHELL_DIR/direnv set -o ignoreeof unsetopt BEEP @@ -24,6 +25,7 @@ GIT_PS1_SHOWUNTRACKEDFILES=1 precmd() { LAST_CMD_RC=$? + _direnv_hook psvar=() set_prompt set_term_title