Skip to content

Instantly share code, notes, and snippets.

@jcsalterego
Last active November 9, 2021 16:55
Show Gist options
  • Save jcsalterego/e6646ccbf7cf246bcb4ff6c063a378e3 to your computer and use it in GitHub Desktop.
Save jcsalterego/e6646ccbf7cf246bcb4ff6c063a378e3 to your computer and use it in GitHub Desktop.
#!/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
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