Compare commits

39 Commits
Author SHA1 Message Date
xavier 874d55625c fix: Try to fix completion 2026-08-23 17:21:48 +02:00
xavier 1a7a850efa fix: Simplify create-links.bash path resolution
Replace the ~30-line get_script_dir() copy (duplicated a third time
from bashrc/bash_profile) with a one-liner. This script is always
executed directly, never sourced from another file, so BASH_SOURCE[0]
reliably points to itself — the extra logic in get_script_dir() for
the sourced-from-elsewhere case doesn't apply here.
2026-08-22 02:16:49 +02:00
xavier f24e250f77 fix: Use _path_prepend in profile.d/krew and profile.d/anyenv
Both prepended to PATH directly, so re-sourcing them in the same
shell would duplicate entries — same issue _path_append already
fixed for profile.d/path and rc.d/rvm. _path_prepend keeps the same
priority ordering (these paths still take precedence over the rest
of PATH) while adding the dedup guard.
2026-08-22 02:10:52 +02:00
xavier bbcf389ace feat: Split _path_add into _path_append and _path_prepend
_path_add only ever appended to PATH, which didn't fit profile.d/krew
and profile.d/anyenv (they prepend, to take priority). Rename it to
_path_append for clarity and add _path_prepend alongside it, so both
orderings get the same dedup guard when needed — krew and anyenv
aren't converted yet, kept as plain PATH concatenation until then.
2026-08-22 02:10:04 +02:00
xavier a92c1c340f fix(bashrc): Stop manually re-sourcing system bash completion
The removed loop tried to source /etc/bash*completion and
/etc/profile.d/bash*completion* by hand, with two real problems:
nullglob wasn't enabled for it (unlike everywhere else via
_source_dir_files), so an empty match sourced the literal glob
pattern and errored — the TODO already flagged this. It also
re-sourced /etc/profile.d/bash_completion.sh, a script meant for
/etc/profile on login shells, not for being re-run from an
interactive-only ~/.bashrc.

On a properly packaged system, bash-completion wires itself up
already (confirmed here via /etc/profile.d/bash_completion.sh and
progcomp being on by default) — this loop was dead weight at best and
a source of environment-dependent breakage at worst (seen previously
on Termux, where /etc doesn't have the same layout).
2026-08-22 02:03:17 +02:00
xavier 6e01d0308e fix: Use _path_add for PATH entries appended at the end
profile.d/path and rc.d/rvm concatenated onto PATH directly, so
re-sourcing them in the same shell (source ~/.bashrc, a resourced
tmux pane, etc.) would duplicate entries. _path_add already guards
against that and tests directory existence itself.

profile.d/krew and profile.d/anyenv are left untouched: they prepend
to PATH (to take priority over other entries), while _path_add always
appends — converting them would silently change resolution order.
2026-08-22 01:59:44 +02:00
xavier 5653b8caf0 fix(rc): Prevent double-sourcing asdf when both native and Nix installs exist
rc.d/asdf tested native (~/.asdf) and Nix-profile asdf independently,
so if both were present on a machine, asdf would be sourced twice —
duplicate PATH entries and redefined completions/functions. Make the
Nix branch an elif so at most one is sourced.
2026-08-22 00:55:59 +02:00
xavier d94d9177d3 chore: Remove orphaned z submodule reference from .gitmodules
3rd-party/z (rupa/z) was declared but the directory doesn't exist on
disk, isn't in the git index, and nothing sources it — zoxide replaced
it as the cd-frecency tool (see rc.d/zoxide). complete-alias and
fzf-git.sh are left as-is; they still need to be initialized via the
chezmoi-managed external config that clones this repo (separate task).
2026-08-22 00:55:59 +02:00
xavier 6968a93343 style: Normalize variable expansions in libs.deprecated/*
These files stay deprecated and out of the sourcing path for now, but
apply the same ${var} notation cleanup as the rest of the repo where
it's a pure notation fix. basedir.bash is left untouched: its bug is
a broken escape, not a notation issue, and it mirrors the one already
removed from _helpers.bash.
2026-08-22 00:55:59 +02:00
xavier 6738296ace fix: Remove dead and broken basedir() from _helpers.bash
basedir() had a broken escape ($(dirname \"$-2\") makes no sense) and
was never called anywhere in the repo — it's a leftover copy of the
already-deprecated libs.deprecated/basedir.bash. bashrc already has
its own get_script_dir() for the same need, with proper symlink
resolution.
2026-08-22 00:55:59 +02:00
xavier 55d2607035 style: Use command -v instead of which for availability checks
rc.d/anyenv, rc.d/screen, aliases.d/mc, and rc.d/startx were the last
holdouts still using `which` to check tool availability. Every other
file in rc.d/* already uses `command -v`, which doesn't depend on an
external binary being installed.
2026-08-22 00:55:55 +02:00
xavier df189f9ec1 style: Normalize variable expansions to ${var} across the repo
Replace bare $var with ${var} everywhere it was still used, matching
the convention already established in rc.d/prompt and rc.d/history.
Positional parameters ($1, $@, $#) and special variables ($?, $$, $-)
are left as-is, consistent with existing usage in _helpers.bash.

rc.d/broot is auto-generated by the broot binary and will likely be
overwritten with its original formatting on the next broot update.
2026-08-22 00:55:39 +02:00
xavier 6a53ee36fd chore(rc,profile,aliases,completion,libs,functions): Remove shebangs from sourced files
These files are always sourced (never executed directly), so the
#!/bin/bash shebang is inert and misleading. Drop it consistently
across rc.d/*, profile.d/*, and aliases.d/*.
2026-08-22 00:52:02 +02:00
xavier 7000bde368 feat(rc): Unify history tool selection (atuin/mcfly) with preference order
Merge rc.d/mcfly and rc.d/atuin into rc.d/history, following the same
preference-list + availability-check + fallback pattern as rc.d/prompt,
so only one history tool is active at a time instead of both being
initialized independently. Also normalize variable expansions in
rc.d/prompt to consistently use ${var} braces.
2026-08-22 00:19:55 +02:00
xavier 4f004fee15 feat(rc): Improve fzf configuration 2026-07-22 23:29:41 +02:00
xavier 2d8b9a5309 feat(profile): use existing helpers to manage profile files (just like rc ones) 2026-07-22 22:19:07 +02:00
xavier ee5e92e0a4 feat(profile): change LANG value to something more standard 2026-07-22 22:17:50 +02:00
xavier 32c0b021c5 feat(rc): Add preference for starship prompt over powerline-go 2026-07-16 19:00:51 +02:00
xavier f2c78152cc feat(rc): Add support for vivid tool to beautify LS_COLORS 2026-07-16 18:54:01 +02:00
xavier 7e007b5b0d feat(rc): Fix prompt choice 2026-07-16 18:47:44 +02:00
xavier 76ce8a4758 feat(rc): Add support for vivid tool 2026-07-15 19:36:34 +02:00
xavier e8eba3619a feat: Move prefered apps logic from profile.d to rc.d
Without this, mise is not yet activated when evaluating the prefered
apps scripts and mise installed apps are considered not installed (for
exemple nvim for the EDITOR variable)
2026-07-14 18:20:41 +02:00
xavier d6290589cf feat: Remove inputrc file that is now managed by chezmoi 2026-07-14 00:31:42 +02:00
xavier e40045aa99 feat: Improve way to determine and set the path containing the bash config
Before this:
The bash config repo needed to be cloned in ~/.bash/ to work properly

After this:
The bash config repo can be move anywhere (for exemple in
~/.config/bash).
The create-links.bash helper is adapted to this new behaviour.
So you can clone anywhere and call create-links.bash from anywhere. Then
the symbolic links in your home should be good and the config would load
correctly.
2026-07-13 12:44:45 +02:00
Xavier Logerais 6f7aec9147 feat(libs): Improve colors lib 2025-11-21 19:44:12 +00:00
Xavier Logerais c4a93c7647 feat(rc): Smart titles for tmux windows 2025-11-21 19:43:35 +00:00
Xavier Logerais 8d98936961 feat: Add fzf-git as 3rd party module 2025-11-21 19:42:04 +00:00
xavier 5f8997f418 chore(rc): fzf integration config spacing rework 2025-11-03 01:34:40 +01:00
xavier 693d20f2cf feat(aliases): Improve aliases for kitty 2025-11-03 01:33:44 +01:00
xavier db981696b6 fix: activate mise early
because some tools set in rc.d (like fzf, ...) depends on it
2025-11-03 01:24:52 +01:00
xavier 594a212ebc chore(rc): rework fzf integration config 2025-11-01 12:53:41 +01:00
xavier 8fef2338eb feat(aliases): Add aliases for kitty 2025-10-24 12:48:22 +02:00
xavier ea9139f77f feat(completion): Add autocompletion for tea
`tea` is the command line tool for Gitea.
2025-10-02 22:41:47 +02:00
xavier 15a56af2c8 chores(completion): spaces 2025-10-02 22:40:57 +02:00
xavier a56929aa8b feat(aliases): Add some aliases for cd 2025-09-28 19:03:11 +02:00
xavier 526e6cae26 feat(functions): Add a function to start and log into the devenv container 2025-09-28 17:55:51 +02:00
xavier 1a003a9d72 feat(bashrc): Add management for functions 2025-09-28 17:55:51 +02:00
xavier 2b51dfd554 feat(bashrc): remove z.sh third party library
Better use zoxide (See https://github.com/ajeetdsouza/zoxide).
(It is available with mise. Just `mise use -g zoxide`.)
2025-09-28 17:52:54 +02:00
xavier d078a852df fix(profile): fix keychain inheritance 2025-09-28 17:50:30 +02:00
91 changed files with 453 additions and 390 deletions
+3 -3
View File
@@ -1,6 +1,6 @@
[submodule "3rd-party/z"]
path = 3rd-party/z
url = https://github.com/rupa/z.git
[submodule "3rd-party/complete-alias"] [submodule "3rd-party/complete-alias"]
path = 3rd-party/complete-alias path = 3rd-party/complete-alias
url = https://github.com/cykerway/complete-alias.git 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
+16 -16
View File
@@ -1,27 +1,21 @@
#!/bin/bash
function basedir() {
(cd "$(dirname \"$-2\")" && pwd)
}
function _source_file_if_exists() { function _source_file_if_exists() {
if [ -r "$1" ]; then if [ -r "$1" ]; then
test -n "$DEBUG_BASHRC" && echo "-- Sourcing file $1" test -n "${DEBUG_BASHRC}" && echo "-- Sourcing file $1"
source "$1" source "$1"
fi fi
} }
function _source_dir_files() { function _source_dir_files() {
if [ -d "$1" ]; then if [ -d "$1" ]; then
test -n "$DEBUG_BASHRC" && echo "-- Sourcing files in directory $1" test -n "${DEBUG_BASHRC}" && echo "-- Sourcing files in directory $1"
# Safe loops for empty dirs # Safe loops for empty dirs
shopt -s nullglob shopt -s nullglob
for file in "$1"/*; do for file in "$1"/*; do
if [ -e "$file" ]; then if [ -e "${file}" ]; then
test -n "$DEBUG_BASHRC" && echo " * sourcing file $file" test -n "${DEBUG_BASHRC}" && echo " * sourcing file ${file}"
source "$file" source "${file}"
fi fi
done done
@@ -31,14 +25,20 @@ function _source_dir_files() {
} }
# Source : https://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there # Source : https://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there
_path_add() { _path_append() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1" PATH="${PATH:+"${PATH}:"}$1"
fi
}
_path_prepend() {
if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
PATH="$1${PATH:+":${PATH}"}"
fi fi
} }
_prompt_command_add() { _prompt_command_add() {
if [ -n "$1" ] && [[ ":$PROMPT_COMMAND:" != *":$1:"* ]]; then if [ -n "$1" ] && [[ ":${PROMPT_COMMAND}:" != *":$1:"* ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND:+"$PROMPT_COMMAND;"}$1" PROMPT_COMMAND="${PROMPT_COMMAND:+"${PROMPT_COMMAND};"}$1"
fi fi
} }
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v bat &>/dev/null); then if (command -v bat &>/dev/null); then
alias cat=bat alias cat=bat
fi fi
+4 -2
View File
@@ -1,5 +1,7 @@
alias cdrepo='cd ~/Repositories/' alias cdrepo='cd ~/Repositories/'
alias cdgitlab='cd ~/Repositories/Gitlab'
alias cdgithub='cd ~/Repositories/Github' alias cdgithub='cd ~/Repositories/Github'
alias cdgl=cdgitlab alias cdgitlab='cd ~/Repositories/Gitlab'
alias cdgitea='cd ~/Repositories/Gitea'
alias cdgh=cdgithub alias cdgh=cdgithub
alias cdgl=cdgitlab
alias cdgt=cdgitea
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (which colordiff &> /dev/null) if (which colordiff &> /dev/null)
then then
alias diff=colordiff alias diff=colordiff
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Colors # Colors
alias ls='ls --color=auto' alias ls='ls --color=auto'
alias grep='grep --color=auto' alias grep='grep --color=auto'
+1 -3
View File
@@ -1,7 +1,5 @@
#!/bin/bash
# Fun # Fun
alias matrix='tr -c "[:digit:]" " " < /dev/urandom | dd cbs=$COLUMNS conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"' alias matrix='tr -c "[:digit:]" " " < /dev/urandom | dd cbs=${COLUMNS} conv=unblock | GREP_COLOR="1;32" grep --color "[^ ]"'
if (command -v beep &> /dev/null) if (command -v beep &> /dev/null)
then then
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Cd # Cd
alias cdup='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 then
alias emerge='sudo emerge' alias emerge='sudo emerge'
alias etc-update='sudo etc-update' alias etc-update='sudo etc-update'
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Git # Git
if [ -x /usr/bin/git ]; then if [ -x /usr/bin/git ]; then
alias gs='git status' alias gs='git status'
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v 'gopass' && ! command -v pass ) &> /dev/null if (command -v 'gopass' && ! command -v pass ) &> /dev/null
then then
alias pass='gopass' alias pass='gopass'
+5
View File
@@ -0,0 +1,5 @@
# [ "$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
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v kubectl &>/dev/null); then if (command -v kubectl &>/dev/null); then
# create some usefull aliases # create some usefull aliases
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v lsd &> /dev/null) if (command -v lsd &> /dev/null)
then then
alias ls='lsd' alias ls='lsd'
+2 -4
View File
@@ -1,7 +1,5 @@
#!/bin/bash if (command -v mc &> /dev/null); then
if [ "${TERM}" = "rxvt-unicode" ]; then
if (which mc &> /dev/null); then
if [ "$TERM" = "rxvt-unicode" ]; then
alias mc="TERM=rxvt-unicode-256color mc" alias mc="TERM=rxvt-unicode-256color mc"
fi fi
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Vim Editor # Vim Editor
if [ -x ~/AppImages/nvim.appimage ] if [ -x ~/AppImages/nvim.appimage ]
then then
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (which ovs-appctl &> /dev/null); then alias appctl='sudo ovs-appctl'; fi 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-vsctl &> /dev/null); then alias vsctl='sudo ovs-vsctl'; fi
if (which ovs-ofctl &> /dev/null); then alias ofctl='sudo ovs-ofctl'; fi if (which ovs-ofctl &> /dev/null); then alias ofctl='sudo ovs-ofctl'; fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Power # Power
alias reboot='sudo reboot' alias reboot='sudo reboot'
alias halt='sudo halt' alias halt='sudo halt'
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Security # Security
alias rm='rm -i' alias rm='rm -i'
alias mv='mv -i' alias mv='mv -i'
-2
View File
@@ -1,4 +1,2 @@
#!/bin/bash
# SSH # SSH
alias ssh!='ssh -q -oStrictHostKeyChecking=no -oIdentitiesOnly=yes' alias ssh!='ssh -q -oStrictHostKeyChecking=no -oIdentitiesOnly=yes'
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# System tools # System tools
if [ -f /sbin/ifconfig ] && [ -x /sbin/ifconfig ]; then alias ifconfig='/sbin/ifconfig'; fi 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 if [ -f /sbin/ip ] && [ -x /sbin/ip ]; then alias ip='/sbin/ip'; fi
-2
View File
@@ -1,3 +1 @@
#!/bin/bash
alias tree='tree -A -C' alias tree='tree -A -C'
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Vim Editor # Vim Editor
if (command -v nvim &> /dev/null) if (command -v nvim &> /dev/null)
then then
-2
View File
@@ -1,4 +1,2 @@
#!/bin/bash
if (which zfs &> /dev/null); then alias zfs='sudo zfs'; fi if (which zfs &> /dev/null); then alias zfs='sudo zfs'; fi
if (which zpool &> /dev/null); then alias zpool='sudo zpool'; fi if (which zpool &> /dev/null); then alias zpool='sudo zpool'; fi
+43 -7
View File
@@ -1,12 +1,48 @@
#!/bin/bash if [ -f "${HOME}"/.nix-profile/etc/profile.d/hm-session-vars.sh ]; then
source "${HOME}"/.nix-profile/etc/profile.d/hm-session-vars.sh
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 fi
if [ -f "$HOME"/.bash/profile ]; then source "$HOME"/.bash/profile; fi # Define the path to the directory of this file if not already set
if [ -d "$HOME"/.bash/profile ]; then for file in "$HOME"/.bash/profile/*; do source "$file"; done; fi if [ -z "${BASH_CONFIG_DIR}" ]; then
if [ -d "$HOME"/.bash/profile.d ]; then for file in "$HOME"/.bash/profile.d/*; do source "$file"; done; fi # 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"
# This file is sourced by bash for login shells. The following line # This file is sourced by bash for login shells. The following line
# runs your .bashrc and is recommended by the bash info pages. # runs your .bashrc and is recommended by the bash info pages.
+73 -23
View File
@@ -13,49 +13,99 @@ fi
# DEBUG_BASHRC=true # DEBUG_BASHRC=true
# Determine path to directory of this file (FIX: remove dependency to readlink for posix compliance)
BASEDIR=$( # Define the path to the directory of this file if not already set
source_file=$(readlink -f "${BASH_SOURCE[0]}") if [ -z "${BASH_CONFIG_DIR}" ]; then
source_dir=$(dirname "${source_file}") # Define a function to get the real path of a script
cd "${source_dir}" && pwd # (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 some helpers functions
source "${BASEDIR}/_helpers.bash" source "${BASH_CONFIG_DIR}/_helpers.bash"
# Source custom libs # Source custom libs
_source_dir_files "${BASEDIR}"/libs _source_dir_files "${BASH_CONFIG_DIR}"/libs
# Source 3rd party libs if they exists # Source 3rd party libs if they exists
_source_file_if_exists "${BASEDIR}/3rd-party/complete-alias/complete_alias" _source_file_if_exists "${BASH_CONFIG_DIR}/3rd-party/complete-alias/complete_alias"
# _source_file_if_exists "${BASEDIR}/3rd-party/z/z.sh" # FIX: Problème de gestion de la variable PROMPT_COMMAND _source_file_if_exists "${BASH_CONFIG_DIR}/3rd-party/junegunn/fzf-git.sh/fzf-git.sh"
# Early customization # Early customization
_source_dir_files "${BASEDIR}"/rc.before.d _source_dir_files "${BASH_CONFIG_DIR}"/rc.before.d
# Source rc.d/* # Source rc.d/*
_source_dir_files "${BASEDIR}"/rc _source_dir_files "${BASH_CONFIG_DIR}"/rc
_source_dir_files "${BASEDIR}"/rc.d _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
# Source alias definitions # Source alias definitions
_source_file_if_exists ~/.bash_aliases _source_file_if_exists ~/.bash_aliases
_source_file_if_exists "${BASEDIR}"/aliases _source_file_if_exists "${BASH_CONFIG_DIR}"/aliases
_source_dir_files "${BASEDIR}"/aliases _source_dir_files "${BASH_CONFIG_DIR}"/aliases
_source_dir_files "${BASEDIR}"/aliases.d _source_dir_files "${BASH_CONFIG_DIR}"/aliases.d
# Source bash completion definitions # Source bash completion definitions
# TODO: Améliorer cette partie pour éviter les erreurs quand aucun fichier n'existe # System-wide bash completion (bash-completion package) is expected to
for file in /etc/bash*completion /etc/profile.d/bash*completion*; do source "$file"; done # 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.
# 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
# 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_completion
_source_file_if_exists "${BASEDIR}"/completion _source_file_if_exists "${BASH_CONFIG_DIR}"/completion
_source_dir_files "${BASEDIR}"/completion _source_dir_files "${BASH_CONFIG_DIR}"/completion
_source_dir_files "${BASEDIR}"/completion.d _source_dir_files "${BASH_CONFIG_DIR}"/completion.d
_source_dir_files ~/.nix-profile/share/bash-completion/completions _source_dir_files ~/.nix-profile/share/bash-completion/completions
if (command -v _complete_alias &>/dev/null); then 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 for alias in $(alias -p | awk '{print $2}' | awk -F= '{print $1}'); do complete -o default -F _complete_alias "${alias}"; done
fi fi
# Late customization # Late customization
_source_dir_files "${BASEDIR}"/rc.after.d _source_dir_files "${BASH_CONFIG_DIR}"/rc.after.d
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v aws && command -v aws_completer) &>/dev/null; then if (command -v aws && command -v aws_completer) &>/dev/null; then
complete -C aws_completer aws complete -C aws_completer aws
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v chezmoi &>/dev/null); then if (command -v chezmoi &>/dev/null); then
source <(chezmoi completion bash) source <(chezmoi completion bash)
fi fi
-3
View File
@@ -1,6 +1,3 @@
#!/bin/bash
if (command -v flux &>/dev/null); then if (command -v flux &>/dev/null); then
source <(flux completion bash) source <(flux completion bash)
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v glab &>/dev/null); then if (command -v glab &>/dev/null); then
source <(glab completion) source <(glab completion)
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v helm &> /dev/null) if (command -v helm &> /dev/null)
then then
source <( helm completion bash ) source <( helm completion bash )
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v k3d &>/dev/null); then if (command -v k3d &>/dev/null); then
source <(k3d completion bash) source <(k3d completion bash)
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v kind &>/dev/null); then if (command -v kind &>/dev/null); then
source <(kind completion bash) source <(kind completion bash)
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v kubectl &> /dev/null) if (command -v kubectl &> /dev/null)
then then
source <(kubectl completion bash) source <(kubectl completion bash)
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v minikube &>/dev/null); then if (command -v minikube &>/dev/null); then
source <(minikube completion bash) source <(minikube completion bash)
fi fi
+1 -3
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v mise &>/dev/null); then if (command -v mise &>/dev/null); then
source <(mise completion bash --include-bash-completion-lib) source <(mise completion bash)
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v podman &>/dev/null); then if (command -v podman &>/dev/null); then
source <(podman completion bash) source <(podman completion bash)
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if ( command -v poetry &> /dev/null ) if ( command -v poetry &> /dev/null )
then then
source <(poetry completions bash) source <(poetry completions bash)
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v stern &> /dev/null) if (command -v stern &> /dev/null)
then then
source <(stern --completion bash) source <(stern --completion bash)
+3
View File
@@ -0,0 +1,3 @@
if (command -v tea &>/dev/null); then
source <(tea completion bash)
fi
+9 -7
View File
@@ -1,11 +1,13 @@
#!/bin/bash #!/bin/bash
cd $HOME || exit 1 # 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
CONFDIR=.bash cd "${HOME}" || exit 1
ln -sf $CONFDIR/bash_profile .bash_profile ln -sf "${BASH_CONFIG_DIR}"/bash_profile .bash_profile
ln -sf $CONFDIR/bashrc .bashrc ln -sf "${BASH_CONFIG_DIR}"/bashrc .bashrc
ln -sf $CONFDIR/bash_logout .bash_logout ln -sf "${BASH_CONFIG_DIR}"/bash_logout .bash_logout
ln -sf "${BASH_CONFIG_DIR}"/inputrc .inputrc
ln -sf $CONFDIR/inputrc .inputrc
+16
View File
@@ -0,0 +1,16 @@
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
@@ -1,65 +0,0 @@
# 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 -1
View File
@@ -1 +1 @@
grepp() { x=$1; shift; perl -00ne ' print if /'"$x"'/i ' "$*" ; } grepp() { x=$1; shift; perl -00ne ' print if /'"${x}"'/i ' "$*" ; }
+1 -1
View File
@@ -12,5 +12,5 @@ function ldifparse ()
if (length) print if (length) print
next next
} }
{print}' "$FILE" {print}' "${FILE}"
} }
+2 -2
View File
@@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
_path_add() { _path_add() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then if [ -d "$1" ] && [[ ":${PATH}:" != *":$1:"* ]]; then
PATH="${PATH:+"$PATH:"}$1" PATH="${PATH:+"${PATH}:"}$1"
fi fi
} }
+2 -2
View File
@@ -1,8 +1,8 @@
#!/bin/bash #!/bin/bash
_prompt_command_add() { _prompt_command_add() {
if [ -n "$1" ] && [[ ":$PROMPT_COMMAND:" != *":$1:"* ]]; then if [ -n "$1" ] && [[ ":${PROMPT_COMMAND}:" != *":$1:"* ]]; then
PROMPT_COMMAND="${PROMPT_COMMAND:+"$PROMPT_COMMAND;"}$1" PROMPT_COMMAND="${PROMPT_COMMAND:+"${PROMPT_COMMAND};"}$1"
fi fi
} }
+2 -2
View File
@@ -188,7 +188,7 @@ vm_create_magick2() {
template=${3} template=${3}
# Define ressources based on template # Define ressources based on template
case $template in case ${template} in
small) small)
vcpus="1,maxvcpus=2" vcpus="1,maxvcpus=2"
memory="1024,maxmemory=2048" memory="1024,maxmemory=2048"
@@ -262,7 +262,7 @@ _hypervisors() {
if [ -e ~/.ssh/known_hosts ]; then 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) known_hypervisors=$(cat ~/.ssh/known_hosts | cut -f 1 -d ' ' | sed -e 's/,.*//g' | grep -v "\[" | grep -i hypervisor | uniq)
fi 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 #complete -W "$(cat ~/.ssh/config | egrep -i "^\s*host\s+[a-zA-Z]" | sed -e "s/^host\s*//i" | grep -i hypervisor)" hypervisor_connect
+13 -2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
#ANSI CODES #ANSI CODES
#Code Effect #Code Effect
#0 All attributes off #0 All attributes off
@@ -64,6 +62,18 @@ 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_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"; } function echo_failed { >&2 echo -e "\e[00;01;31;49m✖ ${*}\e[39;49;00m"; }
function echo_verbose {
if [ -n "${VERBOSE}" ]; then
echo_faint "${*}" >&2
fi
}
function echo_debug {
if [ -n "${DEBUG}" ]; then
echo_faint "🐛 ${*}" >&2
fi
}
function echo_demo { function echo_demo {
echo_bold bold echo_bold bold
echo_faint faint echo_faint faint
@@ -77,4 +87,5 @@ function echo_demo {
echo_error error echo_error error
echo_success success echo_success success
echo_failed failed echo_failed failed
DEBUG=true echo_debug debug
} }
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
function ip_to_hex () function ip_to_hex ()
{ {
if test -e "$1" ; then echo "Usage : $0 XXX.XXX.XXX.XXX" ; return ; fi if test -e "$1" ; then echo "Usage : $0 XXX.XXX.XXX.XXX" ; return ; fi
+5 -7
View File
@@ -1,19 +1,17 @@
#!/bin/bash
note() { note() {
# if file doesn't exist, create it # if file doesn't exist, create it
if [[ ! -f $HOME/.notes ]]; then if [[ ! -f "${HOME}/.notes" ]]; then
touch "$HOME"/.notes touch "${HOME}"/.notes
fi fi
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
# no arguments, print file # no arguments, print file
cat "$HOME"/.notes cat "${HOME}"/.notes
elif [[ "$1" == "-c" ]]; then elif [[ "$1" == "-c" ]]; then
# clear file # clear file
echo "" >"$HOME"/.notes echo "" >"${HOME}"/.notes
else else
# add all arguments to file # add all arguments to file
echo "$@" >>"$HOME"/.notes echo "$@" >>"${HOME}"/.notes
fi fi
} }
+13 -15
View File
@@ -1,23 +1,21 @@
#!/bin/bash
encpasswd() { encpasswd() {
local password_clear=$1 local password_clear=$1
local password_md5hash=$(openssl passwd -1 "$password_clear") local password_md5hash=$(openssl passwd -1 "${password_clear}")
local password_sha1=$(echo -n "$password_clear" | openssl dgst -sha1) local password_sha1=$(echo -n "${password_clear}" | openssl dgst -sha1)
echo "Password : $password_clear" echo "Password : ${password_clear}"
echo "MD5HASH : $password_md5hash" echo "MD5HASH : ${password_md5hash}"
echo "SHA1 : $password_sha1" echo "SHA1 : ${password_sha1}"
} }
genpasswd() { genpasswd() {
local l=$1 local l=$1
[ "$l" == "" ] && l=12 [ "${l}" == "" ] && l=12
local password_clear=$(tr -dc A-Za-z0-9_ </dev/urandom | head -c "${l}" | xargs) 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_md5hash=$(openssl passwd -1 "${password_clear}")
local password_sha1=$(echo -n "$password_clear" | openssl dgst -sha1) local password_sha1=$(echo -n "${password_clear}" | openssl dgst -sha1)
local password_base64=$(echo -n "$password_clear" | base64) local password_base64=$(echo -n "${password_clear}" | base64)
echo "Password : $password_clear" echo "Password : ${password_clear}"
echo "Base64 : $password_base64" echo "Base64 : ${password_base64}"
echo "MD5HASH : $password_md5hash" echo "MD5HASH : ${password_md5hash}"
echo "SHA1 : $password_sha1" echo "SHA1 : ${password_sha1}"
} }
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
function ssh_clean_known_hosts() { function ssh_clean_known_hosts() {
if [ -z "$1" ]; then if [ -z "$1" ]; then
echo "No arguments given. Cleaning ~/.ssh/known_hosts" echo "No arguments given. Cleaning ~/.ssh/known_hosts"
+1 -3
View File
@@ -1,7 +1,5 @@
#!/bin/bash
function term_change_title { function term_change_title {
case $TERM in case ${TERM} in
# Change the window title of X terminals # Change the window title of X terminals
xterm* | rxvt* | urxvt* | Eterm) xterm* | rxvt* | urxvt* | Eterm)
echo -ne "\033]0;${1}\007" echo -ne "\033]0;${1}\007"
+8 -10
View File
@@ -1,22 +1,20 @@
#!/bin/bash
todo() { todo() {
if [[ ! -f $HOME/.todo ]]; then if [[ ! -f "${HOME}/.todo" ]]; then
touch $HOME/.todo touch "${HOME}/.todo"
fi fi
if [[ $# -eq 0 ]]; then if [[ $# -eq 0 ]]; then
cat $HOME/.todo cat "${HOME}/.todo"
elif [[ "$1" == "-l" ]]; then elif [[ "$1" == "-l" ]]; then
cat -n $HOME/.todo cat -n "${HOME}/.todo"
elif [[ "$1" == "-c" ]]; then elif [[ "$1" == "-c" ]]; then
echo "" > $HOME/.todo echo "" > "${HOME}/.todo"
elif [[ "$1" == "-r" ]]; then elif [[ "$1" == "-r" ]]; then
cat -n $HOME/.todo cat -n "${HOME}/.todo"
echo -ne "----------------------------\nType a number to remove: " echo -ne "----------------------------\nType a number to remove: "
read NUMBER read NUMBER
sed -ie ${NUMBER}d $HOME/.todo sed -ie "${NUMBER}d" "${HOME}/.todo"
else else
echo "$@" >> $HOME/.todo echo "$@" >> "${HOME}/.todo"
fi fi
} }
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
function urxvt_set_font function urxvt_set_font
{ {
# set font # set font
-2
View File
@@ -1,4 +1,2 @@
#!/bin/bash
function prettyxml () { sed -e 's,>,>\n,g'; } function prettyxml () { sed -e 's,>,>\n,g'; }
+2 -7
View File
@@ -1,10 +1,5 @@
#!/bin/bash
# https://github.com/riywo/anyenv # https://github.com/riywo/anyenv
# git clone https://github.com/riywo/anyenv $HOME/.anyenv # git clone https://github.com/riywo/anyenv ${HOME}/.anyenv
if [ -d "$HOME/.anyenv/bin" ] _path_prepend "${HOME}/.anyenv/bin"
then
export PATH="$HOME/.anyenv/bin:$PATH"
fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Customize history format # Customize history format
export HISTSIZE=5000 export HISTSIZE=5000
export HISTFILESIZE=20000 export HISTFILESIZE=20000
+1 -3
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v keychain &>/dev/null); then if (command -v keychain &>/dev/null); then
eval "$(keychain --eval --noask ~/.ssh/{id_ed25519,id_rsa_native})" eval "$(keychain --inherit any --quiet --noask ~/.ssh/id_{rsa,ed25519})"
fi fi
+1 -3
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v krew &>/dev/null); then if (command -v krew &>/dev/null); then
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH" _path_prepend "${KREW_ROOT:-${HOME}/.krew}/bin"
fi fi
+1 -3
View File
@@ -1,4 +1,2 @@
#!/bin/bash
# Define prefered LANG # Define prefered LANG
export LANG=fr_FR.utf8 export LANG=fr_FR.UTF-8
-2
View File
@@ -1,4 +1,2 @@
#!/bin/bash
# Mail # Mail
export MAILPATH=~/Mails/ export MAILPATH=~/Mails/
+4 -6
View File
@@ -1,8 +1,6 @@
#!/bin/bash
# Customize PATH # Customize PATH
if [ -d $HOME/.bin ] ; then export PATH=$PATH:$HOME/.bin ; fi _path_append "${HOME}/.bin"
if [ -d $HOME/.local/bin ] ; then export PATH=$PATH:$HOME/.local/bin ; fi _path_append "${HOME}/.local/bin"
if [ -d $HOME/bin ] ; then export PATH=$PATH:$HOME/bin ; fi _path_append "${HOME}/bin"
if [ -d $HOME/scripts ] ; then export PATH=$PATH:$HOME/scripts ; fi _path_append "${HOME}/scripts"
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Proxy # Proxy
if [ -x /usr/bin/tsocks ] if [ -x /usr/bin/tsocks ]
then then
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Defined prefered applications # Defined prefered applications
# EDITOR # EDITOR
-2
View File
@@ -1,3 +1 @@
#!/bin/bash
[[ ${BLE_VERSION-} ]] && ble-attach [[ ${BLE_VERSION-} ]] && ble-attach
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# ble.sh () installed from nix # ble.sh () installed from nix
if (command -v blesh-share &>/dev/null); then if (command -v blesh-share &>/dev/null); then
source "$(blesh-share)"/ble.sh --attach=none # does not work currently source "$(blesh-share)"/ble.sh --attach=none # does not work currently
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v mise &>/dev/null); then if (command -v mise &>/dev/null); then
# activate mise-en-place (https://mise.jdx.dev/) # activate mise-en-place (https://mise.jdx.dev/)
+2 -4
View File
@@ -1,9 +1,7 @@
#!/bin/bash
# https://github.com/riywo/anyenv # https://github.com/riywo/anyenv
# git clone https://github.com/riywo/anyenv $HOME/.anyenv # git clone https://github.com/riywo/anyenv ${HOME}/.anyenv
if (which anyenv &>/dev/null); then if (command -v anyenv &>/dev/null); then
eval "$(anyenv init -)" eval "$(anyenv init -)"
fi fi
+3 -7
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if [ -f ~/.asdf/asdf.sh ]; then if [ -f ~/.asdf/asdf.sh ]; then
# activate asdf # activate asdf
@@ -8,9 +6,7 @@ if [ -f ~/.asdf/asdf.sh ]; then
# activate completion # activate completion
source ~/.asdf/completions/asdf.bash source ~/.asdf/completions/asdf.bash
fi elif [ -f "${HOME}/.nix-profile/share/asdf-vm/asdf.sh" ]; then
. "${HOME}/.nix-profile/share/asdf-vm/asdf.sh"
if [ -f "$HOME/.nix-profile/share/asdf-vm/asdf.sh" ]; then . "${HOME}/.nix-profile/share/bash-completion/completions/asdf.bash"
. "$HOME/.nix-profile/share/asdf-vm/asdf.sh"
. "$HOME/.nix-profile/share/bash-completion/completions/asdf.bash"
fi fi
+6 -8
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v broot &>/dev/null); then if (command -v broot &>/dev/null); then
# This script was automatically generated by the broot program # This script was automatically generated by the broot program
# More information can be found in https://github.com/Canop/broot # More information can be found in https://github.com/Canop/broot
@@ -10,14 +8,14 @@ if (command -v broot &>/dev/null); then
function br { function br {
local cmd cmd_file code local cmd cmd_file code
cmd_file=$(mktemp) cmd_file=$(mktemp)
if broot --outcmd "$cmd_file" "$@"; then if broot --outcmd "${cmd_file}" "$@"; then
cmd=$(<"$cmd_file") cmd=$(<"${cmd_file}")
rm -f "$cmd_file" rm -f "${cmd_file}"
eval "$cmd" eval "${cmd}"
else else
code=$? code=$?
rm -f "$cmd_file" rm -f "${cmd_file}"
return "$code" return "${code}"
fi fi
} }
fi fi
+5 -7
View File
@@ -1,7 +1,5 @@
#!/bin/bash
# Use cgroups # Use cgroups
if [ "$PS1" ] ; then if [ "${PS1}" ] ; then
if [ -d /sys/fs/cgroup ] ; then if [ -d /sys/fs/cgroup ] ; then
cdir=/sys/fs/cgroup cdir=/sys/fs/cgroup
@@ -9,10 +7,10 @@ if [ "$PS1" ] ; then
cdir=/dev/cgroup cdir=/dev/cgroup
fi fi
if [ -d "$cdir/user" ]; then if [ -d "${cdir}/user" ]; then
mkdir -p -m 0700 $cdir/user/$$ > /dev/null 2>&1 mkdir -p -m 0700 "${cdir}/user/$$" > /dev/null 2>&1
/bin/echo $$ > $cdir/user/$$/tasks /bin/echo $$ > "${cdir}/user/$$/tasks"
/bin/echo '1' > $cdir/user/$$/notify_on_release /bin/echo '1' > "${cdir}/user/$$/notify_on_release"
unset -v cdir unset -v cdir
fi fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
# Enable colors for ls, etc. Prefer ~/.dir_colors #64489 # Enable colors for ls, etc. Prefer ~/.dir_colors #64489
if [[ -f ~/.dir_colors ]]; then if [[ -f ~/.dir_colors ]]; then
eval `dircolors -b ~/.dir_colors` eval `dircolors -b ~/.dir_colors`
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (asdf which direnv &>/dev/null); then if (asdf which direnv &>/dev/null); then
# Hook direnv into your shell. # Hook direnv into your shell.
eval "$(asdf exec direnv hook bash)" eval "$(asdf exec direnv hook bash)"
+59 -21
View File
@@ -1,31 +1,69 @@
#!/bin/bash
if (command -v fzf &>/dev/null); then if (command -v fzf &>/dev/null); then
# Shell integration
source <(fzf --bash) source <(fzf --bash)
# Selection de fichiers # Options par défaut
export FZF_CTRL_T_OPTS="--height 60% \ FZF_DEFAULT_OPTS="\
--border sharp \ --height 60%
--layout reverse \ --border rounded
--prompt '󰈞 ' \ --layout reverse
--pointer \ --highlight-line \
--marker ✔" --info=inline-right \
--ansi \
"
export FZF_DEFAULT_OPTS
# Navigation vers un répertoire # Navigation vers un répertoire
export FZF_ALT_C_OPTS="--height 60% \ FZF_ALT_C_OPTS="$(
--border sharp \ cat <<'EOF'
--layout reverse \ --prompt '󰥨 '
--prompt '󰥨 ' \ --pointer
--pointer \ --marker ✔
--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 # Navigation dans l'historique
export FZF_CTRL_R_OPTS="--height 60% \ FZF_CTRL_R_OPTS="$(
--border sharp \ cat <<'EOF'
--layout reverse \ --prompt ' '
--prompt ' ' \ --pointer
--pointer \ --marker ✔
--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 fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v git && command -v fzf) &>/dev/null; then if (command -v git && command -v fzf) &>/dev/null; then
function gsb { git checkout "$(git branch --all | fzf | tr -d '[:space:]')"; } function gsb { git checkout "$(git branch --all | fzf | tr -d '[:space:]')"; }
fi fi
+48
View File
@@ -0,0 +1,48 @@
# 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
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (which lsd &> /dev/null) if (which lsd &> /dev/null)
then then
-11
View File
@@ -1,11 +0,0 @@
#!/bin/bash
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)"
fi
+17 -10
View File
@@ -1,35 +1,42 @@
#!/bin/bash
# Customize the prompt # Customize the prompt
USE_PROMPT=powerline-go # Indicate your preference order for prompt tools
# The first one found available will be used
MY_PROMPT_TOOLS="starship powerline-go"
case "$USE_PROMPT" in for prompt in ${MY_PROMPT_TOOLS}; do
if (command -v "${prompt}" &>/dev/null); then
USE_PROMPT="${prompt}"
break
fi
done
case "${USE_PROMPT}" in
# https://starship.rs/
"starship") "starship")
if (command -v starship &>/dev/null); then if (command -v starship &>/dev/null); then
# echo "Using $USE_PROMPT prompt"
eval "$(starship init bash)" eval "$(starship init bash)"
else else
echo "$USE_PROMPT command not found" echo "${USE_PROMPT} command not found"
fi fi
;; ;;
# https://github.com/justjanne/powerline-go
"powerline-go") "powerline-go")
if (command -v powerline-go &>/dev/null); then if (command -v powerline-go &>/dev/null); then
# echo "Using $USE_PROMPT prompt"
function _update_ps1() { 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) 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)
} }
if [ "$TERM" != "linux" ]; then _prompt_command_add "_update_ps1"; fi if [ "${TERM}" != "linux" ]; then _prompt_command_add "_update_ps1"; fi
else else
echo "$USE_PROMPT command not found" echo "${USE_PROMPT} command not found"
fi fi
;; ;;
*) *)
# Default simple prompt # Default simple prompt
if [ "$UID" -eq 0 ]; then if [ "${UID}" -eq 0 ]; then
export PS1='\[\e[01;31m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] ' export PS1='\[\e[01;31m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '
else else
export PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] ' export PS1='\[\e[01;32m\]\u@\h\[\e[01;34m\] \w \$\[\e[0m\] '
+3 -5
View File
@@ -1,10 +1,8 @@
#!/bin/bash
# Load RVM into a shell session *as a function* # 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 # 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 # Add RVM to PATH for scripting
[[ -r "$HOME/.rvm/bin" ]] && PATH=$PATH:$HOME/.rvm/bin [[ -r "${HOME}/.rvm/bin" ]] && _path_append "${HOME}/.rvm/bin"
+2 -4
View File
@@ -1,9 +1,7 @@
#!/bin/bash
# GNU Screen stuff # GNU Screen stuff
if ( which screen &> /dev/null ) if ( command -v screen &> /dev/null )
then then
if [[ $TERM != screen* ]] if [[ ${TERM} != screen* ]]
then then
if [ "$(screen -ls | sed -ne 's/[[:space:]]//' -ne 's/(Attached)// p')" ] if [ "$(screen -ls | sed -ne 's/[[:space:]]//' -ne 's/(Attached)// p')" ]
then then
+6 -6
View File
@@ -1,10 +1,10 @@
# Auto startx depending on the VT # Auto startx depending on the VT
if [[ -z "$DISPLAY" && $(id -u) -ge 1000 ]] ; then if [[ -z "${DISPLAY}" && $(id -u) -ge 1000 ]] ; then
TTY=$(tty) TTY=$(tty)
if [ "$TTY" == "not a tty" ]; then return; fi if [ "${TTY}" == "not a tty" ]; then return; fi
if [ "${TTY/tty}" != "$TTY" -a $(basename ${TTY/tty}) -le 3 ] if [ "${TTY/tty}" != "${TTY}" -a "$(basename "${TTY/tty}")" -le 3 ]
then then
case $(tty | cut -b9-) in case $(tty | cut -b9-) in
@@ -13,14 +13,14 @@ if [[ -z "$DISPLAY" && $(id -u) -ge 1000 ]] ; then
3) VT=vt3 ;; 3) VT=vt3 ;;
esac esac
if ( which ck-launch-session &> /dev/null ) if ( command -v ck-launch-session &> /dev/null )
then then
EXEC="exec ck-launch-session" EXEC="exec ck-launch-session"
fi fi
if ( which startx &> /dev/null ) if ( command -v startx &> /dev/null )
then then
$EXEC startx 1> ~/.log/xsession-errors 2>&1 -- $VT ${EXEC} startx 1> ~/.log/xsession-errors 2>&1 -- "${VT}"
fi fi
fi fi
fi fi
+47
View File
@@ -0,0 +1,47 @@
# 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
+2 -4
View File
@@ -1,9 +1,7 @@
#!/bin/bash
# GNU Screen stuff # GNU Screen stuff
if (command -v tmux &>/dev/null); then if (command -v tmux &>/dev/null); then
if [ "$(pgrep -u "$UID" "tmux" | wc -l)" -gt 0 ]; then if [ "$(pgrep -u "${UID}" "tmux" | wc -l)" -gt 0 ]; then
if [[ $TERM != screen* ]]; then if [[ ${TERM} != screen* ]]; then
nb_sessions=$(tmux list-session | wc -l) nb_sessions=$(tmux list-session | wc -l)
nb_sessions_attached=$(tmux list-session | grep -c "attached") nb_sessions_attached=$(tmux list-session | grep -c "attached")
nb_sessions_detached=$(tmux list-session | grep -c -v "attached") nb_sessions_detached=$(tmux list-session | grep -c -v "attached")
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if [ -f ~/software/todo.txt-cli/todo.sh ]; then if [ -f ~/software/todo.txt-cli/todo.sh ]; then
export TODOTXT_DEFAULT_ACTION=ls export TODOTXT_DEFAULT_ACTION=ls
+3 -4
View File
@@ -1,4 +1,3 @@
#!/bin/bash
# #
#URXVT_FONT_NAME="DejaVu Sans Mono" #URXVT_FONT_NAME="DejaVu Sans Mono"
#URXVT_FONT_SIZE=16 #URXVT_FONT_SIZE=16
@@ -7,16 +6,16 @@
## Quick functions ## Quick functions
# #
#zp() { #zp() {
# URXVT_FONT_SIZE=$(echo "$URXVT_FONT_SIZE+$URXVT_FONT_INCREMENT" | bc ) # URXVT_FONT_SIZE=$(echo "${URXVT_FONT_SIZE}+${URXVT_FONT_INCREMENT}" | bc )
# urxvt_set_font "${URXVT_FONT_NAME}:size=${URXVT_FONT_SIZE}" # urxvt_set_font "${URXVT_FONT_NAME}:size=${URXVT_FONT_SIZE}"
#} #}
# #
#zm() { #zm() {
# URXVT_FONT_SIZE=$(echo "$URXVT_FONT_SIZE-$URXVT_FONT_INCREMENT" | bc ) # URXVT_FONT_SIZE=$(echo "${URXVT_FONT_SIZE}-${URXVT_FONT_INCREMENT}" | bc )
# urxvt_set_font "${URXVT_FONT_NAME}:size=${URXVT_FONT_SIZE}" # urxvt_set_font "${URXVT_FONT_NAME}:size=${URXVT_FONT_SIZE}"
#} #}
# #
#if [ -z "$SSH_CONNECTION" ] #if [ -z "${SSH_CONNECTION}" ]
#then #then
# urxvt_set_font "${URXVT_FONT_NAME}:size=${URXVT_FONT_SIZE}" # urxvt_set_font "${URXVT_FONT_NAME}:size=${URXVT_FONT_SIZE}"
#fi #fi
+10
View File
@@ -0,0 +1,10 @@
# INFO:
#  vivid is a generator for the LS_COLORS environment variable that controls the colorized output of ls, tree, fd, bfs, dust and many other tools.
# ➜ https://github.com/sharkdp/vivid
# 💡Use command `vivid themes` to see available themes
if (command -v vivid &>/dev/null); then
THEME=tokyonight-moon
LS_COLORS="$(vivid generate ${THEME})"
export LS_COLORS
fi
-2
View File
@@ -1,5 +1,3 @@
#!/bin/bash
if (command -v zoxide &>/dev/null); then if (command -v zoxide &>/dev/null); then
eval "$(zoxide init bash)" eval "$(zoxide init bash)"
fi fi