From c392e53db5152155094a0bf02c392491833ba880 Mon Sep 17 00:00:00 2001 From: Xavier Logerais Date: Wed, 26 Jun 2019 18:29:51 +0200 Subject: [PATCH] Some changes for macos --- aliases.d/colors | 2 +- bashrc | 2 +- completion.d/ssh | 14 +++++++------- libs/virtualization.bash | 2 ++ profile.d/lang | 2 +- rc.d/direnv | 6 ++++++ rc.d/prompt | 20 ++++++++++++++++---- 7 files changed, 34 insertions(+), 14 deletions(-) create mode 100644 rc.d/direnv diff --git a/aliases.d/colors b/aliases.d/colors index e0d5739..67f2abc 100644 --- a/aliases.d/colors +++ b/aliases.d/colors @@ -1,7 +1,7 @@ #!/bin/bash # Colors -alias ls='ls --color=auto' +alias ls='ls -G' alias grep='grep --color=auto' alias fgrep='fgrep --color=auto' alias egrep='egrep --color=auto' diff --git a/bashrc b/bashrc index ba90a24..9d23f57 100644 --- a/bashrc +++ b/bashrc @@ -24,7 +24,7 @@ if [ -d $HOME/.bash/aliases ]; then for file in $(ls $HOME/.bash/aliases/*); do if [ -d $HOME/.bash/aliases.d ]; then for file in $(ls $HOME/.bash/aliases.d/*); do source $file; done; fi # Source bash completion definitions -for file in /etc/bash*completion /etc/profile.d/bash*completion* ; do source $file ; done +#for file in /etc/bash*completion /etc/profile.d/bash*completion* ; do source $file ; done if [ -f $HOME/.bash_completion ]; then source $HOME/.bash_completion; fi if [ -f $HOME/.bash/completion ]; then source $HOME/.bash/completion; fi diff --git a/completion.d/ssh b/completion.d/ssh index 790bb6e..38793aa 100644 --- a/completion.d/ssh +++ b/completion.d/ssh @@ -1,10 +1,10 @@ #!/bin/bash #SSH -if [ -e ~/.ssh/config ]; then - complete -W "$(cat ~/.ssh/config | egrep -i "^\s*host\s+[a-zA-Z]" | sed -e "s/^host\s*//i")" ssh -fi - -if [ -e ~/.ssh/known_hosts ]; then - complete -W "$(cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\[")" ssh -fi +#if [ -e ~/.ssh/config ]; then +# complete -W "$(cat ~/.ssh/config | egrep -i "^\s*host\s+[a-zA-Z]" | sed -e "s/^host\s*//i")" ssh +#fi +# +#if [ -e ~/.ssh/known_hosts ]; then +# complete -W "$(cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e s/,.*//g | uniq | grep -v "\[")" ssh +#fi diff --git a/libs/virtualization.bash b/libs/virtualization.bash index bf8b5c0..cd1a723 100755 --- a/libs/virtualization.bash +++ b/libs/virtualization.bash @@ -1,5 +1,7 @@ #!/bin/bash +which virsh || return &> /dev/null + hypervisor_connect() { if [ -e "${1}" ]; then echo "Usage : $0 hypervisor_name_or_ip"; return 1; fi diff --git a/profile.d/lang b/profile.d/lang index 3b455dc..8989d67 100644 --- a/profile.d/lang +++ b/profile.d/lang @@ -1,4 +1,4 @@ #!/bin/bash # Define prefered LANG -export LANG=fr_FR.utf8 +export LANG=fr_FR.UTF-8 diff --git a/rc.d/direnv b/rc.d/direnv new file mode 100644 index 0000000..7758b1b --- /dev/null +++ b/rc.d/direnv @@ -0,0 +1,6 @@ +#!/bin/bash + +if (which -s direnv) +then + eval "$(direnv hook bash)" +fi diff --git a/rc.d/prompt b/rc.d/prompt index a882c4c..54c5592 100755 --- a/rc.d/prompt +++ b/rc.d/prompt @@ -2,9 +2,24 @@ # Customize the prompt +# Limit the path to 3 levels +PROMPT_DIRTRIM=3 + + +# Use powerline-go if availaible + +# -modules string +# The list of modules to load, separated by ',' +# (valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load, newline, nix-shell, node, perlbrew, perms, root, shell-var, ssh, svn, termtitle, terraform-workspace, time, user, venv, vgo) +# (default "nix-shell,venv,user,host,ssh,cwd,perms,git,hg,jobs,exit,root,vgo") +# -modules-right string +# The list of modules to load anchored to the right, for shells that support it, separated by ',' +# (valid choices: aws, cwd, docker, dotenv, duration, exit, git, gitlite, hg, host, jobs, kube, load + if (which powerline-go &> /dev/null); then function _update_ps1() { - PS1="$(powerline-go -error $?)" + #eval $(powerline-go -shell bash -mode patched -modules "nix-shell,cwd,perms,jobs,git,venv,docker,kube,aws" -modules-right "exit,ssh,user,host" -newline -error $? -eval) + eval $(powerline-go -shell bash -mode patched -modules "nix-shell,cwd,perms,jobs,git,venv,aws,docker,kube,exit" -newline -error $? -eval) } if [ "$TERM" != "linux" ] ; then export PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND" @@ -17,9 +32,6 @@ else fi fi -# Limit the path to 3 levels -PROMPT_DIRTRIM=3 - # Add a smiley at end of prompt showing last command status code #smiley() { # ret_val=$?