From 9eaf9b2832dbc88ab11246065eb2e821fa76730d Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Sat, 15 Aug 2015 22:49:59 -0700 Subject: [PATCH] Add ~/.lib/bin Made pager.sh and editor.sh accesible from anywhere in the shell. Also made pager.sh smart in that it will use emacsclient when INSIDE_EMACS environment variable is set. --- dotfiles/gitconfig | 2 +- dotfiles/lib/{ => bin}/editor.sh | 0 dotfiles/lib/bin/pager.sh | 7 +++++++ dotfiles/lib/pager.sh | 3 --- dotfiles/lib/shellenv.sh | 2 ++ dotfiles/lib/shellenv/emacs.sh | 4 ++-- 6 files changed, 12 insertions(+), 6 deletions(-) rename dotfiles/lib/{ => bin}/editor.sh (100%) create mode 100755 dotfiles/lib/bin/pager.sh delete mode 100755 dotfiles/lib/pager.sh diff --git a/dotfiles/gitconfig b/dotfiles/gitconfig index b9bb2c67..bace8997 100644 --- a/dotfiles/gitconfig +++ b/dotfiles/gitconfig @@ -49,7 +49,7 @@ # Use custom `.gitignore` and `.gitattributes` excludesfile = ~/.gitignore attributesfile = ~/.gitattributes - # pager = less -FXr # set with environment variable so that pager can be different when inside emacs + pager = pager.sh # set with environment variable so that pager can be different when inside emacs [color] # Use colors in Git commands that are capable of colored output when diff --git a/dotfiles/lib/editor.sh b/dotfiles/lib/bin/editor.sh similarity index 100% rename from dotfiles/lib/editor.sh rename to dotfiles/lib/bin/editor.sh diff --git a/dotfiles/lib/bin/pager.sh b/dotfiles/lib/bin/pager.sh new file mode 100755 index 00000000..9ecb528d --- /dev/null +++ b/dotfiles/lib/bin/pager.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env zsh +if environment_variable_exists INSIDE_EMACS; then + emacs_pager "$@" +else + less -FXr +fi +return 0 diff --git a/dotfiles/lib/pager.sh b/dotfiles/lib/pager.sh deleted file mode 100755 index 9ea93738..00000000 --- a/dotfiles/lib/pager.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env zsh -emacs_pager "$@" -return 0 diff --git a/dotfiles/lib/shellenv.sh b/dotfiles/lib/shellenv.sh index fd0fe916..192aea5e 100644 --- a/dotfiles/lib/shellenv.sh +++ b/dotfiles/lib/shellenv.sh @@ -58,6 +58,8 @@ function _setup_env { idem_add_to_front_of_path "$HOME/.rbenv/bin" hash rbenv 2> /dev/null && eval "$(rbenv init -)" hash brew 2>/dev/null && idem_add_to_front_of_path "$(brew --prefix coreutils)/libexec/gnubin" + + idem_add_to_front_of_path "$HOME/.lib/bin" export ENVIRONMENT_SETUP_DONE="$(date)" } diff --git a/dotfiles/lib/shellenv/emacs.sh b/dotfiles/lib/shellenv/emacs.sh index cd8890fc..afde9567 100644 --- a/dotfiles/lib/shellenv/emacs.sh +++ b/dotfiles/lib/shellenv/emacs.sh @@ -128,14 +128,14 @@ function emacs_pager { } # Make emacs the default editor. -export EDITOR="$HOME/.lib/editor.sh" +export EDITOR="$HOME/.lib/bin/editor.sh" export ALTERNATE_EDITOR="" export VISUAL="$EDITOR" export GIT_EDITOR="$EDITOR" # This actually gets executed in dotfiles/lib/shellrc.sh to make sure that it takes precedence over other settings function inside_emacs_hook { - export PAGER="$HOME/.lib/pager.sh" + export PAGER="$HOME/.lib/bin/pager.sh" export GITPAGER="$PAGER" export MANPAGER="$PAGER" }