Compare commits

1 Commits
Author SHA1 Message Date
xavier c392e53db5 Some changes for macos 2019-06-26 18:29:51 +02:00
104 changed files with 511 additions and 869 deletions
-6
View File
@@ -1,6 +0,0 @@
[submodule "3rd-party/complete-alias"]
path = 3rd-party/complete-alias
url = https://github.com/cykerway/complete-alias.git
[submodule "3rd-party/junegunn/fzf-git.sh"]
path = 3rd-party/junegunn/fzf-git.sh
url = https://github.com/junegunn/fzf-git.sh
-44
View File
@@ -1,44 +0,0 @@
function _source_file_if_exists() {
if [ -r "$1" ]; then
test -n "${DEBUG_BASHRC}" && echo "-- Sourcing file $1"
source "$1"
fi
}
function _source_dir_files() {
if [ -d "$1" ]; then
test -n "${DEBUG_BASHRC}" && echo "-- Sourcing files in directory $1"
# Safe loops for empty dirs
shopt -s nullglob
for file in "$1"/*; do
if [ -e "${file}" ]; then
test -n "${DEBUG_BASHRC}" && echo " * sourcing file ${file}"
source "${file}"
fi
done
# Restore option nullglob to normal
shopt -u nullglob
fi
}
# Source : https://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there
_path_append() {
if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
PATH="${PATH:+"${PATH}:"}$1"
fi
}
_path_prepend() {
if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
PATH="$1${PATH:+":${PATH}"}"
fi
}
_prompt_command_add() {
if [ -n "$1" ] && [[ ":${PROMPT_COMMAND}:" != *":$1:"* ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND:+"${PROMPT_COMMAND};"}$1"
fi
}
-3
View File
@@ -1,3 +0,0 @@
if (command -v bat &>/dev/null); then
alias cat=bat
fi
+6 -7
View File
@@ -1,7 +1,6 @@
alias cdrepo='cd ~/Repositories/'
alias cdgithub='cd ~/Repositories/Github'
alias cdgitlab='cd ~/Repositories/Gitlab'
alias cdgitea='cd ~/Repositories/Gitea'
alias cdgh=cdgithub
alias cdgl=cdgitlab
alias cdgt=cdgitea
alias cdrepo='cd ~/repositories/'
alias cddns='cd ~/repositories/dns && git pull'
alias cdfai='cd ~/repositories/fai && git pull'
alias cdpuppet='cd ~/repositories/puppet && git pull'
alias cdhiera='cd ~/repositories/hiera && git pull'
alias cdshinken='cd ~/repositories/shinken && git pull'
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
if (which colordiff &> /dev/null)
then
alias diff=colordiff
+3 -1
View File
@@ -1,5 +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'
+5 -6
View File
@@ -1,7 +1,6 @@
# Fun
alias matrix='tr -c "[:digit:]" " " < /dev/urandom | dd cbs=${COLUMNS} conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"'
#!/bin/bash
if (command -v beep &> /dev/null)
then
alias starwars='beep -l 350 -f 392 -D 100 --new -l 350 -f 392 -D 100 --new -l 350 -f 392 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 350 -f 392 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 700 -f 392 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 250 -f 622.26 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 350 -f 369.99 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 700 -f 392 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 392 -D 100 --new -l 25 -f 392 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 739.98 -D 100 --new -l 25 -f 698.46 -D 100 --new -l 25 -f 659.26 -D 100 --new -l 25 -f 622.26 -D 100 --new -l 50 -f 659.26 -D 400 --new -l 25 -f 415.3 -D 200 --new -l 350 -f 554.36 -D 100 --new -l 250 -f 523.25 -D 100 --new -l 25 -f 493.88 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 25 -f 440 -D 100 --new -l 50 -f 466.16 -D 400 --new -l 25 -f 311.13 -D 200 --new -l 350 -f 369.99 -D 100 --new -l 250 -f 311.13 -D 100 --new -l 25 -f 392 -D 100 --new -l 350 -f 466.16 -D 100 --new -l 250 -f 392 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 700 -f 587.32 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 392 -D 100 --new -l 25 -f 392 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 739.98 -D 100 --new -l 25 -f 698.46 -D 100 --new -l 25 -f 659.26 -D 100 --new -l 25 -f 622.26 -D 100 --new -l 50 -f 659.26 -D 400 --new -l 25 -f 415.3 -D 200 --new -l 350 -f 554.36 -D 100 --new -l 250 -f 523.25 -D 100 --new -l 25 -f 493.88 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 25 -f 440 -D 100 --new -l 50 -f 466.16 -D 400 --new -l 25 -f 311.13 -D 200 --new -l 350 -f 392 -D 100 --new -l 250 -f 311.13 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 300 -f 392.00 -D 150 --new -l 250 -f 311.13 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 700 -f 392'
fi
# Fun
alias matrix='tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"'
alias starwars='beep -l 350 -f 392 -D 100 --new -l 350 -f 392 -D 100 --new -l 350 -f 392 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 350 -f 392 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 700 -f 392 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 350 -f 587.32 -D 100 --new -l 250 -f 622.26 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 350 -f 369.99 -D 100 --new -l 250 -f 311.1 -D 100 --new -l 25 -f 466.2 -D 100 --new -l 700 -f 392 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 392 -D 100 --new -l 25 -f 392 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 739.98 -D 100 --new -l 25 -f 698.46 -D 100 --new -l 25 -f 659.26 -D 100 --new -l 25 -f 622.26 -D 100 --new -l 50 -f 659.26 -D 400 --new -l 25 -f 415.3 -D 200 --new -l 350 -f 554.36 -D 100 --new -l 250 -f 523.25 -D 100 --new -l 25 -f 493.88 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 25 -f 440 -D 100 --new -l 50 -f 466.16 -D 400 --new -l 25 -f 311.13 -D 200 --new -l 350 -f 369.99 -D 100 --new -l 250 -f 311.13 -D 100 --new -l 25 -f 392 -D 100 --new -l 350 -f 466.16 -D 100 --new -l 250 -f 392 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 700 -f 587.32 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 392 -D 100 --new -l 25 -f 392 -D 100 --new -l 350 -f 784 -D 100 --new -l 250 -f 739.98 -D 100 --new -l 25 -f 698.46 -D 100 --new -l 25 -f 659.26 -D 100 --new -l 25 -f 622.26 -D 100 --new -l 50 -f 659.26 -D 400 --new -l 25 -f 415.3 -D 200 --new -l 350 -f 554.36 -D 100 --new -l 250 -f 523.25 -D 100 --new -l 25 -f 493.88 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 25 -f 440 -D 100 --new -l 50 -f 466.16 -D 400 --new -l 25 -f 311.13 -D 200 --new -l 350 -f 392 -D 100 --new -l 250 -f 311.13 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 300 -f 392.00 -D 150 --new -l 250 -f 311.13 -D 100 --new -l 25 -f 466.16 -D 100 --new -l 700 -f 392'
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
# Cd
alias cdup='cd ..'
+1 -1
View File
@@ -1,4 +1,4 @@
if [ -f /etc/gentoo-release -a "${UID}" -ne 0 ]
if [ -f /etc/gentoo-release -a "$UID" -ne 0 ]
then
alias emerge='sudo emerge'
alias etc-update='sudo etc-update'
+4 -2
View File
@@ -1,10 +1,12 @@
#!/bin/bash
# Git
if [ -x /usr/bin/git ]; then
if [ -x /usr/bin/git ]
then
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gca='git commit -a'
alias gf='git fetch'
alias gu='git pull'
alias gp='git pull && git push'
alias gd='git diff'
-4
View File
@@ -1,4 +0,0 @@
if (command -v 'gopass' && ! command -v pass ) &> /dev/null
then
alias pass='gopass'
fi
-5
View File
@@ -1,5 +0,0 @@
# [ "$TERM" = "xterm-kitty" ] && alias ssh="kitty +kitten ssh"
if [ -n "${KITTY_INSTALLATION_DIR}" ]; then
alias ssh="kitty +kitten ssh"
alias icat="kitty +kitten icat"
fi
-19
View File
@@ -1,19 +0,0 @@
if (command -v kubectl &>/dev/null); then
# create some usefull aliases
alias k="kubectl"
alias kg="kubectl get"
alias kd="kubectl describe"
alias ks="kubectl --namespace kube-system"
alias ksg="kubectl --namespace kube-system get"
alias ksd="kubectl --namespace kube-system describe"
alias kga="kubectl get --all-namespaces"
alias kuc="kubectl config unset current-context"
alias kun="kubectl config set-context --current --namespace="
alias kgnodes="kubectl get nodes --label-columns topology.kubernetes.io/region,topology.kubernetes.io/zone"
alias kgmasters="kubectl get nodes --selector 'node-role.kubernetes.io/control-plane' --label-columns topology.kubernetes.io/region,topology.kubernetes.io/zone"
alias kgworkers="kubectl get nodes --selector '!node-role.kubernetes.io/control-plane' --label-columns topology.kubernetes.io/region,topology.kubernetes.io/zone"
alias kgtaints="kubectl get nodes --output custom-columns=NAME:.metadata.name,TAINTS:.spec.taints"
fi
-6
View File
@@ -1,6 +0,0 @@
#/bin/bash
if (command -v lazygit &> /dev/null)
then
alias lg=lazygit
fi
-5
View File
@@ -1,5 +0,0 @@
if (command -v lsd &> /dev/null)
then
alias ls='lsd'
alias lt='lsd --tree'
fi
+4 -2
View File
@@ -1,5 +1,7 @@
if (command -v mc &> /dev/null); then
if [ "${TERM}" = "rxvt-unicode" ]; then
#!/bin/bash
if (which mc &> /dev/null); then
if [ "$TERM" = "rxvt-unicode" ]; then
alias mc="TERM=rxvt-unicode-256color mc"
fi
fi
+9
View File
@@ -0,0 +1,9 @@
#!/bin/bash
if (which mutt &> /dev/null); then
if [ "$TERM" = "rxvt-unicode" ]; then
alias mutt="TERM=rxvt-unicode-256color SOCKS_SERVER=10.181.176.208:1080 socksify mutt"
else
alias mutt="SOCKS_SERVER=10.181.176.208:1080 socksify mutt"
fi
fi
-5
View File
@@ -1,5 +0,0 @@
# Vim Editor
if [ -x ~/AppImages/nvim.appimage ]
then
alias nvim='~/AppImages/nvim.appimage'
fi
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
if (which ovs-appctl &> /dev/null); then alias appctl='sudo ovs-appctl'; fi
if (which ovs-vsctl &> /dev/null); then alias vsctl='sudo ovs-vsctl'; fi
if (which ovs-ofctl &> /dev/null); then alias ofctl='sudo ovs-ofctl'; fi
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
# Power
alias reboot='sudo reboot'
alias halt='sudo halt'
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
# Security
alias rm='rm -i'
alias mv='mv -i'
+2
View File
@@ -1,2 +1,4 @@
#!/bin/bash
# SSH
alias ssh!='ssh -q -oStrictHostKeyChecking=no -oIdentitiesOnly=yes'
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
# System tools
if [ -f /sbin/ifconfig ] && [ -x /sbin/ifconfig ]; then alias ifconfig='/sbin/ifconfig'; fi
if [ -f /sbin/ip ] && [ -x /sbin/ip ]; then alias ip='/sbin/ip'; fi
+1 -7
View File
@@ -1,7 +1,6 @@
#
# Aliases for taskwarrior
#
if (command -v task &> /dev/null)
if (which task &> /dev/null)
then
alias t='task'
alias tl='task list'
@@ -9,8 +8,3 @@ then
alias td='task done'
alias ts='task sync'
fi
if (command -v taskwarrior-tui &> /dev/null)
then
alias tu='taskwarrior-tui'
fi
+2
View File
@@ -1 +1,3 @@
#!/bin/bash
alias tree='tree -A -C'
+6 -15
View File
@@ -1,18 +1,9 @@
#!/bin/bash
# Vim Editor
if (command -v nvim &> /dev/null)
if [ -x /usr/bin/vim ]
then
alias vim=nvim
alias vi='vim -p'
alias view='vim -R'
alias vless='vim -u /usr/share/vim/vim74/macros/less.vim -c "colorscheme mustangpp"'
fi
# if (command -v lvim &>/dev/null); then
# alias vim=lvim
# elif (command -v nvim &>/dev/null); then
# alias vim=nvim
# fi
# if [ -x /usr/bin/vim ]
# then
# alias vi='vim -p'
# alias view='vim -R'
# alias vless='vim -u /usr/share/vim/vim*/macros/less.vim'
# fi
+2
View File
@@ -1,2 +1,4 @@
#!/bin/bash
if (which zfs &> /dev/null); then alias zfs='sudo zfs'; fi
if (which zpool &> /dev/null); then alias zpool='sudo zpool'; fi
+4 -44
View File
@@ -1,48 +1,8 @@
if [ -f "${HOME}"/.nix-profile/etc/profile.d/hm-session-vars.sh ]; then
source "${HOME}"/.nix-profile/etc/profile.d/hm-session-vars.sh
fi
#!/bin/bash
# Define the path to the directory of this file if not already set
if [ -z "${BASH_CONFIG_DIR}" ]; then
# Define a function to get the real path of a script
# (works for most cases : either sourced script or executed script, posix shells)
get_script_dir() {
local target
# Si appelé depuis un script (Bash), on regarde qui a appelé la fonction (${BASH_SOURCE[1]})
# Si la fonction est exécutée directement dans le terminal, on se rabat sur ${BASH_SOURCE[0]} ou ${0}
if [ -n "${BASH_SOURCE}" ]; then
if [ "${#BASH_SOURCE[@]}" -gt 1 ]; then
target="${BASH_SOURCE[1]}"
else
target="${BASH_SOURCE[0]}"
fi
elif [ -n "${ZSH_VERSION}" ]; then
target="${(%):-%x}"
else
target="${0}"
fi
# Résolution des liens symboliques POSIX
while [ -L "${target}" ]; do
local link
link=$(readlink "${target}")
case "${link}" in
/*) target="${link}" ;;
*) target="$(dirname "${target}")/${link}" ;;
esac
done
(cd "$(dirname "${target}")" && pwd -P)
}
BASH_CONFIG_DIR=$(get_script_dir)
fi
# Source some helpers functions
source "${BASH_CONFIG_DIR}/_helpers.bash"
_source_file_if_exists "${BASH_CONFIG_DIR}/profile"
_source_dir_files "${BASH_CONFIG_DIR}/profile"
_source_dir_files "${BASH_CONFIG_DIR}/profile.d"
if [ -f $HOME/.bash/profile ]; then source $HOME/.bash/profile; fi
if [ -d $HOME/.bash/profile ]; then for file in $(ls $HOME/.bash/profile/*); do source $file; done; fi
if [ -d $HOME/.bash/profile.d ]; then for file in $(ls $HOME/.bash/profile.d/*); do source $file; done; fi
# This file is sourced by bash for login shells. The following line
# runs your .bashrc and is recommended by the bash info pages.
+12 -90
View File
@@ -6,106 +6,28 @@
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
# outputting anything in those cases.
if [[ $- != *i* ]]; then
if [[ $- != *i* ]] ; then
# Shell is non-interactive. Be done now!
return
fi
# DEBUG_BASHRC=true
# Define the path to the directory of this file if not already set
if [ -z "${BASH_CONFIG_DIR}" ]; then
# Define a function to get the real path of a script
# (works for most cases : either sourced script or executed script, posix shells)
get_script_dir() {
local target
# Si appelé depuis un script (Bash), on regarde qui a appelé la fonction (${BASH_SOURCE[1]})
# Si la fonction est exécutée directement dans le terminal, on se rabat sur ${BASH_SOURCE[0]} ou ${0}
if [ -n "${BASH_SOURCE}" ]; then
if [ "${#BASH_SOURCE[@]}" -gt 1 ]; then
target="${BASH_SOURCE[1]}"
else
target="${BASH_SOURCE[0]}"
fi
elif [ -n "${ZSH_VERSION}" ]; then
target="${(%):-%x}"
else
target="${0}"
fi
# Résolution des liens symboliques POSIX
while [ -L "${target}" ]; do
local link
link=$(readlink "${target}")
case "${link}" in
/*) target="${link}" ;;
*) target="$(dirname "${target}")/${link}" ;;
esac
done
(cd "$(dirname "${target}")" && pwd -P)
}
BASH_CONFIG_DIR=$(get_script_dir)
fi
# Source some helpers functions
source "${BASH_CONFIG_DIR}/_helpers.bash"
# Source custom libs
_source_dir_files "${BASH_CONFIG_DIR}"/libs
# Source 3rd party libs if they exists
_source_file_if_exists "${BASH_CONFIG_DIR}/3rd-party/complete-alias/complete_alias"
_source_file_if_exists "${BASH_CONFIG_DIR}/3rd-party/junegunn/fzf-git.sh/fzf-git.sh"
# Early customization
_source_dir_files "${BASH_CONFIG_DIR}"/rc.before.d
if [ -d $HOME/.bash/libs ]; then for lib in $(ls $HOME/.bash/libs/*.bash); do source $lib; done; fi
# Source rc.d/*
_source_dir_files "${BASH_CONFIG_DIR}"/rc
_source_dir_files "${BASH_CONFIG_DIR}"/rc.d
# Source functions definitions
_source_file_if_exists ~/.bash_functions
_source_file_if_exists "${BASH_CONFIG_DIR}"/functions
_source_dir_files "${BASH_CONFIG_DIR}"/functions
_source_dir_files "${BASH_CONFIG_DIR}"/functions.d
if [ -d $HOME/.bash/rc.d ]; then for file in $(ls $HOME/.bash/rc.d/*); do source $file; done; fi
# Source alias definitions
_source_file_if_exists ~/.bash_aliases
_source_file_if_exists "${BASH_CONFIG_DIR}"/aliases
_source_dir_files "${BASH_CONFIG_DIR}"/aliases
_source_dir_files "${BASH_CONFIG_DIR}"/aliases.d
if [ -f $HOME/.bash_aliases ]; then source $HOME/.bash_aliases; fi
if [ -f $HOME/.bash/aliases ]; then source $HOME/.bash/aliases; fi
if [ -d $HOME/.bash/aliases ]; then for file in $(ls $HOME/.bash/aliases/*); do source $file; done; fi
if [ -d $HOME/.bash/aliases.d ]; then for file in $(ls $HOME/.bash/aliases.d/*); do source $file; done; fi
# Source bash completion definitions
# System-wide bash completion (bash-completion package) is expected to
# already be wired by the distro itself, typically via
# /etc/profile.d/bash_completion.sh for login shells and the package's
# own non-login hook — no need to re-source it manually here.
#for file in /etc/bash*completion /etc/profile.d/bash*completion* ; do source $file ; done
# Use bash-completion, if available, and avoid double-sourcing
[[ $PS1 &&
! ${BASH_COMPLETION_VERSINFO:-} &&
-f /usr/share/bash-completion/bash_completion ]] &&
. /usr/share/bash-completion/bash_completion
if [ -f $HOME/.bash_completion ]; then source $HOME/.bash_completion; fi
if [ -f $HOME/.bash/completion ]; then source $HOME/.bash/completion; fi
if [ -d $HOME/.bash/completion ]; then for file in $(ls $HOME/.bash/completion/*); do source $file; done; fi
if [ -d $HOME/.bash/completion.d ]; then for file in $(ls $HOME/.bash/completion.d/*); do source $file; done; fi
# Location for user bash completion
# ${BASH_COMPLETION_USER_DIR:-${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion}/completions
# See https://serverfault.com/questions/506612/standard-place-for-user-defined-bash-completion-d-scripts
# Recommended dirs
# - ~/.bash_completion.d -> ${XDG_DATA_HOME:-$HOME/.local/share}/bash-completion
# - ~/.bash_completion -> ${XDG_CONFIG_HOME:-$HOME/.config}/bash_completion
_source_file_if_exists ~/.bash_completion
_source_file_if_exists "${BASH_CONFIG_DIR}"/completion
_source_dir_files "${BASH_CONFIG_DIR}"/completion
_source_dir_files "${BASH_CONFIG_DIR}"/completion.d
_source_dir_files ~/.nix-profile/share/bash-completion/completions
if (command -v _complete_alias &>/dev/null); then
for alias in $(alias -p | awk '{print $2}' | awk -F= '{print $1}'); do complete -o default -F _complete_alias "${alias}"; done
fi
# Late customization
_source_dir_files "${BASH_CONFIG_DIR}"/rc.after.d
+4 -1
View File
@@ -1,3 +1,6 @@
if (command -v aws && command -v aws_completer) &>/dev/null; then
#!/bin/bash
if ( which aws && which aws_completer ) &> /dev/null
then
complete -C aws_completer aws
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v chezmoi &>/dev/null); then
source <(chezmoi completion bash)
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v flux &>/dev/null); then
source <(flux completion bash)
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v glab &>/dev/null); then
source <(glab completion)
fi
-4
View File
@@ -1,4 +0,0 @@
if (command -v helm &> /dev/null)
then
source <( helm completion bash )
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v k3d &>/dev/null); then
source <(k3d completion bash)
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v kind &>/dev/null); then
source <(kind completion bash)
fi
+3 -1
View File
@@ -1,4 +1,6 @@
if (command -v kubectl &> /dev/null)
#!/bin/bash
if ( which kubectl ) &> /dev/null
then
source <(kubectl completion bash)
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v minikube &>/dev/null); then
source <(minikube completion bash)
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v mise &>/dev/null); then
source <(mise completion bash)
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v podman &>/dev/null); then
source <(podman completion bash)
fi
-4
View File
@@ -1,4 +0,0 @@
if ( command -v poetry &> /dev/null )
then
source <(poetry completions bash)
fi
+10
View File
@@ -0,0 +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
-4
View File
@@ -1,4 +0,0 @@
if (command -v stern &> /dev/null)
then
source <(stern --completion bash)
fi
-7
View File
@@ -1,7 +0,0 @@
#
# Completion for taskwarrior
#
if (command -v task &> /dev/null)
then
complete -o nospace -F _task t
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v tea &>/dev/null); then
source <(tea completion bash)
fi
+7 -9
View File
@@ -1,13 +1,11 @@
#!/bin/bash
# Define the path to the directory of this file if not already set
if [ -z "${BASH_CONFIG_DIR}" ]; then
BASH_CONFIG_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
fi
cd $HOME || exit 1
cd "${HOME}" || exit 1
CONFDIR=.bash
ln -sf "${BASH_CONFIG_DIR}"/bash_profile .bash_profile
ln -sf "${BASH_CONFIG_DIR}"/bashrc .bashrc
ln -sf "${BASH_CONFIG_DIR}"/bash_logout .bash_logout
ln -sf "${BASH_CONFIG_DIR}"/inputrc .inputrc
ln -sf $CONFDIR/bash_profile .bash_profile
ln -sf $CONFDIR/bashrc .bashrc
ln -sf $CONFDIR/bash_logout .bash_logout
ln -sf $CONFDIR/inputrc .inputrc
-16
View File
@@ -1,16 +0,0 @@
function devenv() {
local status
# Get LXC container status
status=$(lxc info devenv | yq .Status)
# Start container if not running
if [ "${status}" != "RUNNING" ]; then lxc start devenv; fi
# Rename tmux window if inside tmux
if [ -n "${TMUX}" ]; then tmux rename-window "devenv"; fi
# Login as user xavier
lxc exec devenv -- login -f xavier
}
+65
View File
@@ -0,0 +1,65 @@
# Include system config file
$include /etc/inputrc
# do not bell on tab-completion
set bell-style none
# Disable display of ^C
set echo-control-characters off
# Completion options
set show-all-if-ambiguous on
set show-all-if-unmodified on
# History
"\e[A": history-search-backward
"\e[B": history-search-forward
# backword/forward during search history
"\eq":backward-search-history
"\es":forward-search-history
# Alt+w Alt+x for beginning/end of line
"\ew":"\C-a"
"\ex":"\C-e"
# prepend "tail -f " with Ctrl+Alt+f
"\e\C-f":"\C-atail -f "
"\ef":"\C-atail -f "
# prepend "sudo " with Ctrl+Alt+s
"\e\C-s":"\C-asudo "
"\es":"\C-asudo "
# prepend "yes | " with Ctrl+Alt+y
"\e\C-y":"\C-ayes | "
"\ey":"\C-ayes | "
# append " | grep" with Ctrl+Alt+g
"\e\C-g":"\C-e | grep "
"\eg":"\C-e | grep "
# append " | head" with Ctrl+Alt+h
"\e\C-h":"\C-e | head"
"\eh":"\C-e | head"
# append " | tail" with Ctrl+Alt+t
"\e\C-t":"\C-e | tail"
"\et":"\C-e | tail"
# append " | more" with Ctrl+Alt+m
"\e\C-m":"\C-e | more"
"\em":"\C-e | more"
# append " | less" with Ctrl+Alt+l
"\e\C-l":"\C-e | less"
"\el":"\C-e | less"
# we can add \C-m add the end to validate command too
#"\e\C-m":"\C-e | less\C-m"
# prepend "man " with F1 and validate
"\e[11~":"\C-aman \C-m"
# Launch commands with <F2> then letter
"\e[12~i":"\C-k\C-uirssi\C-m"
"\e[12~m":"\C-k\C-umutt\C-m"
-1
View File
@@ -1 +0,0 @@
grepp() { x=$1; shift; perl -00ne ' print if /'"${x}"'/i ' "$*" ; }
-9
View File
@@ -1,9 +0,0 @@
#!/bin/bash
_path_add() {
if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
PATH="${PATH:+"${PATH}:"}$1"
fi
}
# Source : https://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there
-9
View File
@@ -1,9 +0,0 @@
#!/bin/bash
_prompt_command_add() {
if [ -n "$1" ] && [[ ":${PROMPT_COMMAND}:" != *":$1:"* ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND:+"${PROMPT_COMMAND};"}$1"
fi
}
export PROMPT_COMMAND
@@ -1,5 +1,5 @@
#!/bin/bash
function basedir() {
(cd "$(dirname \"$-2\")" && pwd)
echo $( cd $(dirname $0) && pwd )
}
+45 -42
View File
@@ -1,3 +1,5 @@
#!/bin/bash
#ANSI CODES
#Code Effect
#0 All attributes off
@@ -28,12 +30,6 @@
#48 Subscript
#49 Superscript
#bold_on=`escape 1m`
#bold_off=`escape 22m`
#blink_on=`escape 5m`
#blink_off=`escape 25m`
#reset=`escape 0m`
#T_ROWS=`tput lines` # Define current terminal dimension
#T_COLS=`tput cols` #+ in rows and columns.
#_UNDERLINE_ON=`tput smul` # turn on underline
@@ -46,46 +42,53 @@
#tput rev - Display inverse colors
#tput sgr0 - Reset everything
# Affiche un message stylisé sur la sortie standard
function echo_bold { echo -e "\e[1m${*}\e[0m"; }
function echo_faint { echo -e "\e[2m${*}\e[0m"; }
function echo_italic { echo -e "\e[3m${*}\e[0m"; }
function echo_underline { echo -e "\e[4m${*}\e[0m"; }
function echo_blink { echo -e "\e[5m${*}\e[0m"; }
function echo_reverse { echo -e "\e[7m${*}\e[0m"; }
function echo_concealed { echo -e "\e[8m${*}\e[0m"; }
default='\E[39;49;00m'
bold='\E[1m'
italic='\E[3m'
underline='\E[4m'
blink='\E[5m'
# Affiche un message informatif stylisé sur la sortie d'erreur
function echo_info { >&2 echo -e "\e[00;34;49m󰋼 ${*}\e[39;49;00m"; }
function echo_warning { >&2 echo -e "\e[00;33;49m ${*}\e[39;49;00m"; }
function echo_error { >&2 echo -e "\e[00;01;31;49m ${*}\e[39;49;00m"; }
function echo_success { >&2 echo -e "\e[00;01;32;49m ${*}\e[39;49;00m"; }
function echo_failed { >&2 echo -e "\e[00;01;31;49m✖ ${*}\e[39;49;00m"; }
blackonwhite='\E[30;47m'
function echo_verbose {
if [ -n "${VERBOSE}" ]; then
echo_faint "${*}" >&2
fi
#reset=`escape 0m`
#black='\E[30;47m'
#red='\E[31;47m'
#green='\E[32;47m'
#yellow='\E[33;47m'
#blue='\E[34;47m'
#magenta='\E[35;47m'
#cyan='\E[36;47m'
#white='\E[37;47m'
#bold_on=`escape 1m`
#bold_off=`escape 22m`
#blink_on=`escape 5m`
#blink_off=`escape 25m`
function echo_reverse
{
echo -ne $blackonwhite
echo -ne "$*"
echo -e $default
}
function echo_debug {
if [ -n "${DEBUG}" ]; then
echo_faint "🐛 ${*}" >&2
fi
function echo_italic
{
echo -ne $italic
echo -ne "$*"
echo -e $default
}
function echo_demo {
echo_bold bold
echo_faint faint
echo_italic italic
echo_underline underline
echo_blink blink
echo_reverse reverse
echo_concealed concealed
echo_info info
echo_warning warning
echo_error error
echo_success success
echo_failed failed
DEBUG=true echo_debug debug
function echo_bold
{
echo -ne $bold
echo -ne "$*"
echo -e $default
}
function echo_underline
{
echo -ne $underline
echo -ne "$*"
echo -e $default
}
+1
View File
@@ -0,0 +1 @@
grepp() { x=$1; shift; perl -00ne ' print if /'"$x"'/i ' "$*" ; }
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
function ip_to_hex ()
{
if test -e "$1" ; then echo "Usage : $0 XXX.XXX.XXX.XXX" ; return ; fi
+1 -1
View File
@@ -12,5 +12,5 @@ function ldifparse ()
if (length) print
next
}
{print}' "${FILE}"
{print}' "$FILE"
}
+8 -6
View File
@@ -1,17 +1,19 @@
note() {
#!/bin/bash
note () {
# if file doesn't exist, create it
if [[ ! -f "${HOME}/.notes" ]]; then
touch "${HOME}"/.notes
if [[ ! -f $HOME/.notes ]]; then
touch $HOME/.notes
fi
if [[ $# -eq 0 ]]; then
# no arguments, print file
cat "${HOME}"/.notes
cat $HOME/.notes
elif [[ "$1" == "-c" ]]; then
# clear file
echo "" >"${HOME}"/.notes
echo "" > $HOME/.notes
else
# add all arguments to file
echo "$@" >>"${HOME}"/.notes
echo "$@" >> $HOME/.notes
fi
}
+14 -14
View File
@@ -1,21 +1,21 @@
#!/bin/bash
encpasswd() {
local password_clear=$1
local password_md5hash=$(openssl passwd -1 "${password_clear}")
local password_sha1=$(echo -n "${password_clear}" | openssl dgst -sha1)
echo "Password : ${password_clear}"
echo "MD5HASH : ${password_md5hash}"
echo "SHA1 : ${password_sha1}"
local password_md5hash=$(openssl passwd -1 $password_clear)
local password_sha1=$(echo -n $password_clear | openssl dgst -sha1)
echo "Password : $password_clear"
echo "MD5HASH : $password_md5hash"
echo "SHA1 : $password_sha1"
}
genpasswd() {
local l=$1
[ "${l}" == "" ] && l=12
local password_clear=$(tr -dc A-Za-z0-9_ </dev/urandom | head -c "${l}" | xargs)
local password_md5hash=$(openssl passwd -1 "${password_clear}")
local password_sha1=$(echo -n "${password_clear}" | openssl dgst -sha1)
local password_base64=$(echo -n "${password_clear}" | base64)
echo "Password : ${password_clear}"
echo "Base64 : ${password_base64}"
echo "MD5HASH : ${password_md5hash}"
echo "SHA1 : ${password_sha1}"
[ "$l" == "" ] && l=12
local password_clear=$(tr -dc A-Za-z0-9_ < /dev/urandom | head -c ${l} | xargs)
local password_md5hash=$(openssl passwd -1 $password_clear)
local password_sha1=$(echo -n $password_clear | openssl dgst -sha1)
echo "Password : $password_clear"
echo "MD5HASH : $password_md5hash"
echo "SHA1 : $password_sha1"
}
+7 -3
View File
@@ -1,10 +1,14 @@
function ssh_clean_known_hosts() {
if [ -z "$1" ]; then
#!/bin/bash
function ssh_clean_known_hosts ()
{
if [ -z "$1" ]
then
echo "No arguments given. Cleaning ~/.ssh/known_hosts"
sed -i -e '/no hostip for proxy command/ d' ~/.ssh/known_hosts
else
hostname=$1
ip=$(ssh admin dig +short "$1")
ip=$(ssh admin dig +short $1)
echo "Removing host ${hostname} from ~/.ssh/known_hosts"
sed -i -e "/${hostname}/ d" ~/.ssh/known_hosts
echo "Removing ip ${ip} from ~/.ssh/known_hosts"
+7 -4
View File
@@ -1,12 +1,15 @@
function term_change_title {
case ${TERM} in
#!/bin/bash
function term_change_title
{
case $TERM in
# Change the window title of X terminals
xterm* | rxvt* | urxvt* | Eterm)
xterm*|rxvt*|urxvt*|Eterm)
echo -ne "\033]0;${1}\007"
;;
# Change the window title of screen terminals
screen* | tmux*)
screen*)
echo -ne "\033k${1}\033\\"
;;
esac
+10 -8
View File
@@ -1,20 +1,22 @@
#!/bin/bash
todo() {
if [[ ! -f "${HOME}/.todo" ]]; then
touch "${HOME}/.todo"
if [[ ! -f $HOME/.todo ]]; then
touch $HOME/.todo
fi
if [[ $# -eq 0 ]]; then
cat "${HOME}/.todo"
cat $HOME/.todo
elif [[ "$1" == "-l" ]]; then
cat -n "${HOME}/.todo"
cat -n $HOME/.todo
elif [[ "$1" == "-c" ]]; then
echo "" > "${HOME}/.todo"
echo "" > $HOME/.todo
elif [[ "$1" == "-r" ]]; then
cat -n "${HOME}/.todo"
cat -n $HOME/.todo
echo -ne "----------------------------\nType a number to remove: "
read NUMBER
sed -ie "${NUMBER}d" "${HOME}/.todo"
sed -ie ${NUMBER}d $HOME/.todo
else
echo "$@" >> "${HOME}/.todo"
echo "$@" >> $HOME/.todo
fi
}
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
function urxvt_set_font
{
# set font
@@ -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
@@ -188,7 +190,7 @@ vm_create_magick2() {
template=${3}
# Define ressources based on template
case ${template} in
case $template in
small)
vcpus="1,maxvcpus=2"
memory="1024,maxmemory=2048"
@@ -262,7 +264,7 @@ _hypervisors() {
if [ -e ~/.ssh/known_hosts ]; then
known_hypervisors=$(cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e 's/,.*//g' | grep -v "\[" | grep -i hypervisor | uniq)
fi
echo "${configured_hypervisors}" "${known_hypervisors}"
echo $configured_hypervisors $known_hypervisors
}
#complete -W "$(cat ~/.ssh/config | egrep -i "^\s*host\s+[a-zA-Z]" | sed -e "s/^host\s*//i" | grep -i hypervisor)" hypervisor_connect
+2
View File
@@ -1,2 +1,4 @@
#!/bin/bash
function prettyxml () { sed -e 's,>,>\n,g'; }
+7 -2
View File
@@ -1,5 +1,10 @@
#!/bin/bash
# https://github.com/riywo/anyenv
# git clone https://github.com/riywo/anyenv ${HOME}/.anyenv
# git clone https://github.com/riywo/anyenv $HOME/.anyenv
_path_prepend "${HOME}/.anyenv/bin"
if [ -d "$HOME/.anyenv/bin" ]
then
export PATH="$HOME/.anyenv/bin:$PATH"
fi
+8
View File
@@ -0,0 +1,8 @@
#!/bin/bash
# Defined prefered applications
export TERMINAL=urxvtc
export PAGER=less
export EDITOR=vim
export BROWSER=surf
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
# Customize history format
export HISTSIZE=5000
export HISTFILESIZE=20000
+5 -2
View File
@@ -1,3 +1,6 @@
if (command -v keychain &>/dev/null); then
eval "$(keychain --inherit any --quiet --noask ~/.ssh/id_{rsa,ed25519})"
#!/bin/bash
if $(which keychain &> /dev/null)
then
eval $(keychain --agents ssh,gpg --eval)
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v krew &>/dev/null); then
_path_prepend "${KREW_ROOT:-${HOME}/.krew}/bin"
fi
+2
View File
@@ -1,2 +1,4 @@
#!/bin/bash
# Define prefered LANG
export LANG=fr_FR.UTF-8
+2
View File
@@ -1,2 +1,4 @@
#!/bin/bash
# Mail
export MAILPATH=~/Mails/
+7 -5
View File
@@ -1,6 +1,8 @@
# Customize PATH
_path_append "${HOME}/.bin"
_path_append "${HOME}/.local/bin"
#!/bin/bash
_path_append "${HOME}/bin"
_path_append "${HOME}/scripts"
# Customize PATH
if [ -d $HOME/.bin ] ; then export PATH=$PATH:$HOME/.bin ; fi
if [ -d $HOME/.local/bin ] ; then export PATH=$PATH:$HOME/.local/bin ; fi
if [ -d $HOME/bin ] ; then export PATH=$PATH:$HOME/bin ; fi
if [ -d $HOME/scripts ] ; then export PATH=$PATH:$HOME/scripts ; fi
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
# Proxy
if [ -x /usr/bin/tsocks ]
then
+4
View File
@@ -0,0 +1,4 @@
#!/bin/bash
# Defined prefered applications
export XDG_RUNTIME_DIR=$HOME/.cache
View File
-28
View File
@@ -1,28 +0,0 @@
# Defined prefered applications
# EDITOR
if (command -v nvim &>/dev/null); then
export EDITOR=nvim
fi
# PAGER
if (command -v less &>/dev/null); then
export PAGER=less
fi
# MANPAGER
if (command -v nvim &>/dev/null); then
export MANPAGER='nvim +Man!'
elif (command -v bat &>/dev/null); then
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
fi
# TERMINAL
if (command -v kitty &>/dev/null); then
export TERMINAL=kitty
fi
# BROWSER
if (command -v firefox &>/dev/null); then
export BROWSER=firefox
fi
-1
View File
@@ -1 +0,0 @@
[[ ${BLE_VERSION-} ]] && ble-attach
View File
-4
View File
@@ -1,4 +0,0 @@
# ble.sh () installed from nix
if (command -v blesh-share &>/dev/null); then
source "$(blesh-share)"/ble.sh --attach=none # does not work currently
fi
-6
View File
@@ -1,6 +0,0 @@
if (command -v mise &>/dev/null); then
# activate mise-en-place (https://mise.jdx.dev/)
eval "$(mise activate bash)"
fi
+5 -2
View File
@@ -1,7 +1,10 @@
#!/bin/bash
# https://github.com/riywo/anyenv
# git clone https://github.com/riywo/anyenv ${HOME}/.anyenv
# git clone https://github.com/riywo/anyenv $HOME/.anyenv
if (command -v anyenv &>/dev/null); then
if ( which anyenv &> /dev/null )
then
eval "$(anyenv init -)"
fi
-12
View File
@@ -1,12 +0,0 @@
if [ -f ~/.asdf/asdf.sh ]; then
# activate asdf
source ~/.asdf/asdf.sh
# activate completion
source ~/.asdf/completions/asdf.bash
elif [ -f "${HOME}/.nix-profile/share/asdf-vm/asdf.sh" ]; then
. "${HOME}/.nix-profile/share/asdf-vm/asdf.sh"
. "${HOME}/.nix-profile/share/bash-completion/completions/asdf.bash"
fi
-21
View File
@@ -1,21 +0,0 @@
if (command -v broot &>/dev/null); then
# This script was automatically generated by the broot program
# More information can be found in https://github.com/Canop/broot
# This function starts broot and executes the command
# it produces, if any.
# It's needed because some shell commands, like `cd`,
# have no useful effect if executed in a subshell.
function br {
local cmd cmd_file code
cmd_file=$(mktemp)
if broot --outcmd "${cmd_file}" "$@"; then
cmd=$(<"${cmd_file}")
rm -f "${cmd_file}"
eval "${cmd}"
else
code=$?
rm -f "${cmd_file}"
return "${code}"
fi
}
fi
Regular → Executable
+7 -5
View File
@@ -1,5 +1,7 @@
#!/bin/bash
# Use cgroups
if [ "${PS1}" ] ; then
if [ "$PS1" ] ; then
if [ -d /sys/fs/cgroup ] ; then
cdir=/sys/fs/cgroup
@@ -7,10 +9,10 @@ if [ "${PS1}" ] ; then
cdir=/dev/cgroup
fi
if [ -d "${cdir}/user" ]; then
mkdir -p -m 0700 "${cdir}/user/$$" > /dev/null 2>&1
/bin/echo $$ > "${cdir}/user/$$/tasks"
/bin/echo '1' > "${cdir}/user/$$/notify_on_release"
if [ -d "$cdir/user" ]; then
mkdir -p -m 0700 $cdir/user/$$ > /dev/null 2>&1
/bin/echo $$ > $cdir/user/$$/tasks
/bin/echo '1' > $cdir/user/$$/notify_on_release
unset -v cdir
fi
+2
View File
@@ -1,3 +1,5 @@
#!/bin/bash
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if [[ -f ~/.dir_colors ]]; then
eval `dircolors -b ~/.dir_colors`
+3 -11
View File
@@ -1,14 +1,6 @@
if (asdf which direnv &>/dev/null); then
# Hook direnv into your shell.
eval "$(asdf exec direnv hook bash)"
#!/bin/bash
# A shortcut for asdf managed direnv.
direnv() { asdf exec direnv "$@"; }
return
elif (command -v direnv &>/dev/null); then
# Hook direnv into your shell.
if (which -s direnv)
then
eval "$(direnv hook bash)"
fi
-69
View File
@@ -1,69 +0,0 @@
if (command -v fzf &>/dev/null); then
# Shell integration
source <(fzf --bash)
# Options par défaut
FZF_DEFAULT_OPTS="\
--height 60%
--border rounded
--layout reverse
--highlight-line \
--info=inline-right \
--ansi \
"
export FZF_DEFAULT_OPTS
# Navigation vers un répertoire
FZF_ALT_C_OPTS="$(
cat <<'EOF'
--prompt '󰥨 '
--pointer
--marker ✔
EOF
)"
export FZF_ALT_C_OPTS
# Selection de fichiers
FZF_CTRL_T_OPTS="$(
cat <<'EOF'
--prompt '󰈞 '
--pointer
--marker ✔
--preview="bat --color=always --style=-header {}"
EOF
)"
export FZF_CTRL_T_OPTS
# Navigation dans l'historique
FZF_CTRL_R_OPTS="$(
cat <<'EOF'
--prompt ' '
--pointer
--marker ✔
EOF
)"
export FZF_CTRL_R_OPTS
# Theme tokyonight
FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS} \
--color=bg+:#283457 \
--color=bg:#16161e \
--color=border:#27a1b9 \
--color=fg:#c0caf5 \
--color=gutter:#16161e \
--color=header:#ff9e64 \
--color=hl+:#2ac3de \
--color=hl:#2ac3de \
--color=info:#545c7e \
--color=marker:#ff007c \
--color=pointer:#ff007c \
--color=prompt:#2ac3de \
--color=query:#c0caf5:regular \
--color=scrollbar:#27a1b9 \
--color=separator:#ff9e64 \
--color=spinner:#ff007c \
"
export FZF_DEFAULT_OPTS
fi
-3
View File
@@ -1,3 +0,0 @@
if (command -v git && command -v fzf) &>/dev/null; then
function gsb { git checkout "$(git branch --all | fzf | tr -d '[:space:]')"; }
fi
-48
View File
@@ -1,48 +0,0 @@
# Customize shell history search
# Indicate your preference order for history tools
# The first one found available will be used
MY_HISTORY_TOOLS="atuin mcfly"
for tool in ${MY_HISTORY_TOOLS}; do
if (command -v "${tool}" &>/dev/null); then
USE_HISTORY_TOOL="${tool}"
break
fi
done
case "${USE_HISTORY_TOOL}" in
# https://atuin.sh/
"atuin")
if (command -v atuin &>/dev/null); then
eval "$(atuin init bash)"
else
echo "${USE_HISTORY_TOOL} command not found"
fi
;;
# https://github.com/cantino/mcfly
"mcfly")
if (command -v mcfly &>/dev/null); then
export MCFLY_PROMPT=" "
export MCFLY_INTERFACE_VIEW=BOTTOM
export MCFLY_RESULTS=50
export MCFLY_RESULTS_SORT=LAST_RUN
# export MCFLY_KEY_SCHEME=vim
export MCFLY_FUZZY=3
eval "$(mcfly init bash)"
else
echo "${USE_HISTORY_TOOL} command not found"
fi
;;
*)
# Default sane bash history behavior
export HISTCONTROL=ignoreboth:erasedups
export HISTSIZE=10000
export HISTFILESIZE=20000
shopt -s histappend
;;
esac
-8
View File
@@ -1,8 +0,0 @@
if (which lsd &> /dev/null)
then
# create a aliases
alias ls='lsd'
alias lt='lsd --tree'
fi
+60
View File
@@ -0,0 +1,60 @@
#!/bin/bash
if ( ! which mcfly &> /dev/null ); then return; fi
# Avoid loading this file more than once
if [[ "$__MCFLY_LOADED" == "loaded" ]]; then
return 0
fi
__MCFLY_LOADED="loaded"
export MCFLY_SESSION_ID=$(cat /dev/urandom | env LC_ALL=C tr -dc 'a-zA-Z0-9' | fold -w 24 | head -n 1)
export MCFLY_HISTORY=$(mktemp -t mcfly.XXXX)
export HISTFILE="${HISTFILE:-$HOME/.bash_history}"
if [[ -f "$HISTFILE" ]];
then
tail -n100 "${HISTFILE}" >| ${MCFLY_HISTORY}
else
printf "Welcome to McFly\n" >| ${MCFLY_HISTORY}
fi
# Ignore commands with a leading space
#export HISTCONTROL="ignorespace"
# Append new history items to .bash_history
shopt -s histappend
# Setup a function to be used by $PROMPT_COMMAND.
function mcfly_prompt_command {
local exit_code=$? # Record exit status of previous command.
history -a ${MCFLY_HISTORY} # Append history to $MCFLY_HISTORY.
# Run mcfly with the saved code. It will:
# * append commands to $HISTFILE, (~/.bash_history by default)
# for backwards compatibility and to load in new terminal sessions;
# * find the text of the last command in $MCFLY_HISTORY and save it to the database.
mcfly add --exit ${exit_code} --append-to-histfile
# Clear the in-memory history and reload it from $MCFLY_HISTORY
# (to remove instances of '#mcfly: ' from the local session history).
history -cr ${MCFLY_HISTORY}
return ${exit_code} # Restore the original exit code by returning it.
}
# Set $PROMPT_COMMAND run mcfly_prompt_command and then any existing $PROMPT_COMMAND.
PROMPT_COMMAND="mcfly_prompt_command;$PROMPT_COMMAND"
# If this is an interactive shell, take ownership of ctrl-r.
# The logic here is:
# 1. Jump to the beginning of the edit buffer, add 'mcfly: ', and comment out the current line. We comment out the line
# to ensure that all possible special characters, including backticks, are ignored. This commented out line will
# end up as the most recent entry in the $MCFLY_HISTORY file.
# 2. Type "mcfly search" and then run the command. McFly will pull the last line from the $MCFLY_HISTORY file,
# which should be the commented-out search from step #1. It will then remove that line from the history file and
# render the search UI pre-filled with it.
if [[ $- =~ .*i.* ]]; then
if set -o | grep "vi " | grep -q on; then
bind "'\C-r': '\e0i#mcfly: \e\C-j mcfly search\C-j'"
else
bind "'\C-r': '\C-amcfly: \e# mcfly search\C-j'"
fi
fi
Regular → Executable
+20 -36
View File
@@ -1,52 +1,36 @@
#!/bin/bash
# Customize the prompt
# Indicate your preference order for prompt tools
# The first one found available will be used
MY_PROMPT_TOOLS="starship powerline-go"
# Limit the path to 3 levels
PROMPT_DIRTRIM=3
for prompt in ${MY_PROMPT_TOOLS}; do
if (command -v "${prompt}" &>/dev/null); then
USE_PROMPT="${prompt}"
break
fi
done
case "${USE_PROMPT}" in
# Use powerline-go if availaible
# https://starship.rs/
"starship")
if (command -v starship &>/dev/null); then
eval "$(starship init bash)"
else
echo "${USE_PROMPT} command not found"
fi
;;
# -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
# https://github.com/justjanne/powerline-go
"powerline-go")
if (command -v powerline-go &>/dev/null); then
if (which powerline-go &> /dev/null); then
function _update_ps1() {
PS1=$(powerline-go -jobs "$(jobs -p | wc -l)" -error $? -modules "ssh,host,wsl,user,cwd,direnv,venv,perms,git,jobs,exit,root" -modules-right "docker,docker-context,kube,terraform-workspace,termtitle" -newline)
#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 _prompt_command_add "_update_ps1"; fi
else
echo "${USE_PROMPT} command not found"
if [ "$TERM" != "linux" ] ; then
export PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi
;;
*)
# Default simple prompt
if [ "${UID}" -eq 0 ]; then
else
if [ "$UID" -eq 0 ]; then
export PS1='\[\e[01;31m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '
else
export PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '
fi
;;
esac
# Limit the path to 3 levels
PROMPT_DIRTRIM=3
fi
# Add a smiley at end of prompt showing last command status code
#smiley() {
+5 -3
View File
@@ -1,8 +1,10 @@
#!/bin/bash
# Load RVM into a shell session *as a function*
[[ -s "${HOME}/.rvm/scripts/rvm" ]] && source "${HOME}/.rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# Source bash completion for RVM
[[ -r "${HOME}/.rvm/scripts/completion" ]] && source "${HOME}/.rvm/scripts/completion"
[[ -r "$HOME/.rvm/scripts/completion" ]] && source "$HOME/.rvm/scripts/completion"
# Add RVM to PATH for scripting
[[ -r "${HOME}/.rvm/bin" ]] && _path_append "${HOME}/.rvm/bin"
[[ -r "$HOME/.rvm/bin" ]] && PATH=$PATH:$HOME/.rvm/bin
Regular → Executable
+4 -2
View File
@@ -1,7 +1,9 @@
#!/bin/bash
# GNU Screen stuff
if ( command -v screen &> /dev/null )
if ( which screen &> /dev/null )
then
if [[ ${TERM} != screen* ]]
if [[ $TERM != screen* ]]
then
if [ "$(screen -ls | sed -ne 's/[[:space:]]//' -ne 's/(Attached)// p')" ]
then
+6 -6
View File
@@ -1,10 +1,10 @@
# Auto startx depending on the VT
if [[ -z "${DISPLAY}" && $(id -u) -ge 1000 ]] ; then
if [[ -z "$DISPLAY" && $(id -u) -ge 1000 ]] ; then
TTY=$(tty)
if [ "${TTY}" == "not a tty" ]; then return; fi
if [ "${TTY/tty}" != "${TTY}" -a "$(basename "${TTY/tty}")" -le 3 ]
if [ "$TTY" == "not a tty" ]; then return; fi
if [ "${TTY/tty}" != "$TTY" -a $(basename ${TTY/tty}) -le 3 ]
then
case $(tty | cut -b9-) in
@@ -13,14 +13,14 @@ if [[ -z "${DISPLAY}" && $(id -u) -ge 1000 ]] ; then
3) VT=vt3 ;;
esac
if ( command -v ck-launch-session &> /dev/null )
if ( which ck-launch-session &> /dev/null )
then
EXEC="exec ck-launch-session"
fi
if ( command -v startx &> /dev/null )
if ( which startx &> /dev/null )
then
${EXEC} startx 1> ~/.log/xsession-errors 2>&1 -- "${VT}"
$EXEC startx 1> ~/.log/xsession-errors 2>&1 -- $VT
fi
fi
fi
-47
View File
@@ -1,47 +0,0 @@
# Function to update terminal/tmux title
_update_terminal_title() {
local kubecontext dir gitrepo gitremote icon title
# Detect Kubernetes context (if kubectl is available)
if [ -n "${KUBECONFIG}" ]; then
if command -v kubectl >/dev/null 2>&1; then
kubecontext=$(kubectl config current-context 2>/dev/null)
if [ -n "${kubecontext}" ]; then
title="󱃾 ${kubecontext}"
fi
fi
fi
# If no title is already set, check if we're in ${HOME}
if [ -z "${title}" ] && [ "${PWD}" = "${HOME}" ]; then
title="󱂵 ~"
fi
# If we're in a git repo display repo name with a nice icon
if [ -z "${title}" ] && gitrepo=$(git rev-parse --show-toplevel 2>/dev/null); then
dir=$(basename "${gitrepo}")
# Detect host from remote URL
gitremote=$(git remote get-url origin 2>/dev/null)
case "${gitremote}" in
*github.com*) icon="" ;; # nf-fa-github
*gitlab.com*) icon="" ;; # nf-fa-gitlab
*gitea*) icon="" ;; # nf-linux-gitea
*) icon="" ;; # nf-dev-git
esac
title="${icon} ${dir}"
fi
# Set the title in tmux or terminal window
if [ -n "${title}" ]; then
if [ -n "${TMUX}" ]; then
tmux rename-window "${title}"
else
printf '\033]0;%s\007' "${title}"
fi
fi
}
# Add the function to the PROMPT_COMMAND variable to have regular updates
if [ "${TERM}" != "linux" ]; then _prompt_command_add "_update_terminal_title"; fi
Regular → Executable
+16 -10
View File
@@ -1,19 +1,25 @@
#!/bin/bash
# GNU Screen stuff
if (command -v tmux &>/dev/null); then
if [ "$(pgrep -u "${UID}" "tmux" | wc -l)" -gt 0 ]; then
if [[ ${TERM} != screen* ]]; then
if ( which tmux &> /dev/null )
then
if [ $(pgrep -u "$UID" "tmux" | wc -l) -gt 0 ]
then
if [[ $TERM != screen* ]]
then
nb_sessions=$(tmux list-session | wc -l)
nb_sessions_attached=$(tmux list-session | grep -c "attached")
nb_sessions_detached=$(tmux list-session | grep -c -v "attached")
nb_sessions_attached=$(tmux list-session | grep "attached" | wc -l)
nb_sessions_detached=$(tmux list-session | grep -v "attached" | wc -l)
echo_info "tmux : found ${nb_sessions} session(s)"
echo_reverse "Found ${nb_sessions} tmux session(s)"
echo " ${nb_sessions_attached} session(s) attached"
tmux list-sessions | grep "attached" | sed -e 's/^/ /'
echo " * ${nb_sessions_attached} attached"
tmux list-sessions | grep "attached" | sed -e 's/^/ - /'
echo " ${nb_sessions_detached} session(s) detached"
tmux list-sessions | grep -v "attached" | sed -e 's/^/ /'
echo " * ${nb_sessions_detached} detached"
tmux list-sessions | grep -v "attached" | sed -e 's/^/ - /'
fi
fi
fi

Some files were not shown because too many files have changed in this diff Show More