Last active
November 9, 2021 16:55
-
-
Save jcsalterego/e6646ccbf7cf246bcb4ff6c063a378e3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/bin/bash | |
# gdz = git diff fzf | |
files=$(git status -s | grep ' M' | awk '{print $NF}') | |
if [ -n "${files}" ]; then | |
file=$(echo "$files" | fzf) | |
if [ -n "${file} " ]; then | |
root=$(git rev-parse --show-toplevel) | |
cmd="${EDITOR} ${root}/${file}" | |
echo $cmd | |
$(${cmd}) | |
fi | |
fi |
This file contains hidden or 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
get_prompt() { | |
bold_green=$(echo -e "\[\033[1;32m\]") | |
underline=$(echo -e "\[\033[4m\]") | |
reset=$(echo -e "\[\033[0m\]") | |
branch="$(git rev-parse --abbrev-ref HEAD 2>/dev/null)" | |
if [ -n "${branch}" ]; then | |
export PS1='\w '${underline}${branch}${reset}' '${bold_green}'•'${reset}' ' | |
else | |
export PS1='\w '${reset}${bold_green}'•'${reset}' ' | |
fi | |
} | |
PROMPT_COMMAND='get_prompt' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment