diff --git a/.bash_aliases b/.bash_aliases index c7c0bd0..bd98848 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,6 +1,6 @@ # General alias 'clear=echo "No more clear for you"' -alias 'e=$EDITOR' +# alias 'e=$EDITOR' alias 'ec=$EDITOR ~/.bashrc' alias 'sc=source ~/.bashrc' diff --git a/.bashrc b/.bashrc index 3336dd9..e7d584d 100644 --- a/.bashrc +++ b/.bashrc @@ -9,6 +9,7 @@ export EDITOR=nvim export PATH="$HOME/.local/bin:$HOME/.cargo/bin:$PATH" export INPUTRC="$HOME/.inputrc" +export HISTCONTROL=ignorespace # =====FUNCTIONS===== diff --git a/.local/bin/e b/.local/bin/e new file mode 100755 index 0000000..8f9b90f --- /dev/null +++ b/.local/bin/e @@ -0,0 +1,23 @@ +#!/usr/bin/env bash + +create_session() { + tmux new -ds "$1" + + tmux send-keys -t "$1" 'nvim' Enter +} + +# Use Git repo root as dir if we're in one +dir=`git rev-parse --show-toplevel 2> /dev/null || pwd` +dir_hash=`echo "$dir" | shasum | grep -o '^[^ ]\+'` +dir_name=`basename "$dir" | sed 's/[^a-zA-Z0-9]/_/g'` +session_name="${dir_name}-${dir_hash}" + +tmux has -t "$session_name" 2> /dev/null || \ + create_session "$session_name" + +# Attach to the session +if [ -n "$TMUX" ]; then + tmux switch-client -t "$session_name" +else + tmux attach -t "$session_name" +fi