From 9c6edd5ea0869d984f823f9f05a96b17e4f1ef66 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 15 Jul 2016 11:13:29 -0500 Subject: [PATCH] simple system for saving directories to files for later loading --- .gitignore | 1 + link_all.bash | 1 - sh/bashrc | 26 ++++++++++++++++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 027df9b..0a23465 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ colors/gen/tmp *.lock *.log *.pid +*.tmp diff --git a/link_all.bash b/link_all.bash index 207d955..d59634c 100755 --- a/link_all.bash +++ b/link_all.bash @@ -28,4 +28,3 @@ source "$DOTFILES_PATH/vim/link.bash" source "$DOTFILES_PATH/sh/link.bash" source "$DOTFILES_PATH/x/link.bash" source "$DOTFILES_PATH/wm/link.bash" - diff --git a/sh/bashrc b/sh/bashrc index 056bf52..9dd836d 100644 --- a/sh/bashrc +++ b/sh/bashrc @@ -54,6 +54,9 @@ if [ -t 0 ]; then # wm aliases alias startbar="source $DOTFILES_PATH/wm/extras/bar/start.bash" + # misc aliases + alias keyrepeat="xset r rate 250 80" + export EDITOR="vim" if command -v nvim >/dev/null 2>&1; then alias vim="nvim" @@ -66,6 +69,7 @@ if [ -t 0 ]; then PROMPT_SUCCESS_COLOR='\[\e[0;34m\]' PROMPT_FAILURE_COLOR='\[\e[0;31m\]' DIR_COLOR='\[\e[0;33m\]' + # prompt rendering functions sps() { name="$PWD" [[ "$name" =~ ^"$HOME"(/|$) ]] && name="~${name#$HOME}" @@ -97,6 +101,28 @@ if [ -t 0 ]; then alias _man="man" alias man="vman" + # save the current directory for later retrieval + scwd() { + addon="" + if [[ -n $1 ]]; then + addon="-$1" + fi + echo "$PWD" > "$DOTFILES_PATH/cwd$addon.tmp" + } + export -f scwd + bind '"\C-s"':"@\"scwd\C-m\"" + + # go to the saved current directory + gcwd() { + addon="" + if [[ -n $1 ]]; then + addon="-$1" + fi + cd $(cat $DOTFILES_PATH/cwd$addon.tmp) + } + export -f gcwd + bind '"\C-g"':"\"gcwd\C-m\"" + complete -cf sudo complete -cf man