Last active
June 1, 2023 14:34
-
-
Save shaunmolloy/3b01624c98ff30abaedb367a65ac6209 to your computer and use it in GitHub Desktop.
vim-session - fzf vim session from aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
vim_session() { | |
if [ ! -f ~/.bash_aliases ]; then | |
echo "No ~/.bash_aliases file found" | |
return 1 | |
fi | |
# Source aliases | |
shopt -s expand_aliases | |
source ~/.bash_aliases | |
ALIASES="$(alias | grep 'vim -S')" | |
SESSION="$(echo "$ALIASES" | awk -F '=' '{ print $1 }' | sed 's/alias //' | fzf)" | |
if [ -z "$SESSION" ]; then | |
echo "No session selected" | |
return 1 | |
fi | |
COMMAND="$(echo "$ALIASES" | grep "$SESSION" | awk -F '=' '{ print $2 }' | sed 's/\"//g' | xargs)" | |
eval "$COMMAND" | |
} | |
vim_session |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment