Random tools I've found interesting
Nafallo Bjälevik
nafallo at magicalforest.net
Wed Mar 18 09:19:35 UTC 2020
Hi,
Thought I would add to this with my own findings. Taken from my Ansible
playbook, but should be fairly readable :-).
On 09/03/2020 11:50, Christian Ehrhardt wrote:
<skip>
> Not my tool so I can't point to my repo.
> But also really helpful when dealing with git-repos on a daily base.
>
> https://github.com/jimeh/git-aware-prompt
>
> Lets your prompt always list in which branch you are (I also show if it
> is dirty).
> Let me know if you need help setting this up...
Display a multitude of GIT information in the prompt:
```
- name: Ensure GIT helper scripts
get_url:
url: "{{ item.url }}"
dest: "{{ item.dest | default('~/.' + item.url | basename) }}"
backup: true
loop:
- url:
https://github.com/git/git/raw/master/contrib/completion/git-prompt.sh
- name: Ensure GIT helper scripts in bashrc
blockinfile:
path: ~/.bashrc
block: |
if [ -r ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
if [ -r ~/.git-prompt.sh ]; then
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=true
GIT_PS1_SHOWSTASHSTATE=true
#GIT_PS1_SHOWUNTRACKEDFILES=true
GIT_PS1_SHOWUPSTREAM="auto"
#GIT_PS1_STATESEPARATOR="SP"
#GIT_PS1_DESCRIBESTYLE="default"
GIT_PS1_SHOWCOLORHINTS=true
GIT_PS1_HIDE_IF_PWD_IGNORED=true
SPLITPS1="\"$(echo $PS1 | awk -F\$ '{OFS="$";NF--;print $0;}'
| sed 's/\\$//')\" \"\\\$$(echo $PS1 | awk -F\$ '{OFS="$";print $NF;}') \""
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND;} __git_ps1
$SPLITPS1"
fi
marker: "# {mark} GIT HELPERS"
```
Rename your TMUX window dynamically with your current directory:
```
- name: Ensure TMUX title set to $PWD
blockinfile:
path: ~/.bashrc
block: |
if [ -n "$TMUX" ] && [ -n "$BASH" ]; then
__set_tmux_title() {
if [ "$(pwd)" == "$(echo ~)" ]; then
echo -ne "\033k$(hostname -s)\033\\"
else
title=$(pwd)
echo -ne "\033k${title/*\//}\033\\"
unset title
fi
}
PROMPT_COMMAND="${PROMPT_COMMAND:+$PROMPT_COMMAND;}
__set_tmux_title"
fi
marker: '# {mark} TMUX TITLE'
insertbefore: '^# enable programmable completion'
- name: Ensure Byobu TMUX profile
copy:
content: |
source $BYOBU_PREFIX/share/byobu/profiles/tmux
set-option -g allow-rename on
dest: ~/.byobu/profile.tmux
backup: true
```
Hopefully someone finds it useful :-)
Cheers,
Nafallo
More information about the ubuntu-server
mailing list