Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enable fish integration #50

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
# shellcheck shell=sh disable=SC1091
if test "$(id -u)" -gt "0"; then
green=$'\033[32m'
bold=$'\033[1m'
normal=$'\033[0m'
blue=$(printf '\033[38;5;32m')
bold=$(printf '\033[1m')
normal=$(printf '\033[0m')
HOMEBREW_REPOSITORY=/home/linuxbrew/.linuxbrew
export HOMEBREW_REPOSITORY
HOMEBREW_NO_AUTO_UPDATE=0
export HOMEBREW_NO_AUTO_UPDATE
if test ! -f /etc/linuxbrew.firstrun; then
printf "\nBluefin-CLI First Run Setup\n\n"
printf "Setting up sudo for %s%s%s...\t\t\t " "${bold}" "${USER}" "${normal}"
echo "#${UID} ALL = (root) NOPASSWD:ALL" | su-exec root tee -a /etc/sudoers > /dev/null
printf "%s[ OK ]%s\n" "${green}" "${normal}"
printf "Setting up sudo for %s%s%s%s...\t\t\t " "$bold" "$blue" "$USER" "$normal"
echo "#$(id -u) ALL = (root) NOPASSWD:ALL" | su-exec root tee -a /etc/sudoers > /dev/null
printf "%s[ OK ]%s\n" "${blue}" "${normal}"
fi

if test ! -d /home/linuxbrew/.linuxbrew; then
name=""
test -f /run/.containerenv && . /run/.containerenv
test -f /run/.dockerenv && . /run/.dockerenv
name="$(hostname -s)"
linuxbrew_home="${XDG_DATA_HOME:-$HOME/.local/share}"/bluefin-cli/"${name}"
printf "Setting up Linuxbrew...\t\t\t\t "
if test ! -d "${linuxbrew_home}"; then
Expand All @@ -28,9 +29,9 @@ if test "$(id -u)" -gt "0"; then
fi
su-exec root mount --bind "${linuxbrew_home}" /home/linuxbrew
su-exec root cp -R /home/homebrew/.linuxbrew /home/linuxbrew/
su-exec root chown -R $UID /home/linuxbrew
su-exec root chown -R "$(id -u)" /home/linuxbrew
unset linuxbrew_home
printf "%s[ OK ]%s\n" "${green}" "${normal}"
printf "%s[ OK ]%s\n" "${blue}" "${normal}"
fi

if test ! -d /usr/local/share/bash-completion/completions; then
Expand All @@ -40,7 +41,7 @@ if test "$(id -u)" -gt "0"; then
if test -x /run/host/usr/bin/ujust; then
su-exec root ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/ujust
fi
printf "%s[ OK ]%s\n" "${green}" "${normal}"
printf "%s[ OK ]%s\n" "${blue}" "${normal}"
fi

if test ! -f /etc/linuxbrew.firstrun; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ if [ "x${BASH_VERSION-}" != x -a "x${PS1-}" != x -a "x${BASH_COMPLETION_VERSINFO
# Source completion code.
. /usr/local/share/bash-completion/bash_completion
fi
if ! test -L /home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew; then
if ! test -L /home/linuxbrew/.linuxbrew/etc/bash_completion.d/brew && test "$(id -u)" -gt 0; then
/home/linuxbrew/.linuxbrew/bin/brew completions link
fi
if test -d /home/linuxbrew/.linuxbrew/etc/bash_completion.d; then
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=sh
command_not_found_handle() {
# don't run if not in a container
if [ ! -e /run/.containerenv ] && [ ! -e /.dockerenv ]; then
Expand Down
1 change: 1 addition & 0 deletions toolboxes/bluefin-cli/files/etc/profile.d/modern-unix.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=sh
# Eza for ls
alias ll='eza -l --icons=auto --group-directories-first' 2>/dev/null
alias l.='eza -d .*' 2>/dev/null
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# shellcheck shell=sh
if [ -z "$PROFILESOURCED" ] && [ "$PS1" ]; then
PROFILESOURCED="Y"
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
if test "$(id -u)" -gt "0"
set blue (set_color blue)
set bold (set_color -o blue)
set normal (set_color normal)
if test ! -f /etc/linuxbrew.firstrun
printf "\nBluefin-CLI First Run Setup\n\n"
printf "Setting up sudo for %s%s%s...\t\t\t " "$bold" "$USER" "$normal"
echo "#$UID ALL = (root) NOPASSWD:ALL" | su-exec root tee -a /etc/sudoers > /dev/null
printf "%s[ OK ]%s\n" "$blue" "$normal"
end

if test ! -d /home/linuxbrew/.linuxbrew
set name $(hostname -s)
set xdg_data_home "$XDG_DATA_HOME"
test -z "$xdg_data_home"; and set xdg_data_home "$HOME/.local/share/"
set linuxbrew_home "$xdg_data_home/bluefin-cli/$name"
printf "Setting up Linuxbrew...\t\t\t\t "
if test ! -d "$linuxbrew_home"
mkdir -p "$linuxbrew_home"
end
if test ! -d /home/linuxbrew
su-exec root mkdir -p /home/linuxbrew
end
su-exec root mount --bind "$linuxbrew_home" /home/linuxbrew
su-exec root cp -R /home/homebrew/.linuxbrew /home/linuxbrew/
su-exec root chown -R "$UID" /home/linuxbrew
set -e linuxbrew_home
printf "%s[ OK ]%s\n" "$blue" "$normal"
end

if test ! -d /usr/local/share/bash-completion/completions
printf "Setting up Tab-Completions...\t\t\t "
su-exec root mkdir -p /usr/local/share/bash-completion
su-exec root mount --bind /run/host/usr/share/bash-completion /usr/local/share/bash-completion
if test -x /run/host/usr/bin/ujust
su-exec root ln -fs /usr/bin/distrobox-host-exec /usr/local/bin/ujust
end
printf "%s[ OK ]%s\n" "$blue" "$normal"
end

if test ! -f /etc/linuxbrew.firstrun
su-exec root touch /etc/linuxbrew.firstrun
printf "\nBluefin-CLI first run complete!\n\n"
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
if status is-interactive
set -gx STARSHIP_CONFIG /etc/starship.toml
eval "$(starship init fish)"
eval "$(atuin init fish)"
eval "$(zoxide init fish --cmd cd)"
end

# Eza for ls
alias ll='eza -l --icons=auto --group-directories-first' 2>/dev/null
alias l.='eza -d .*' 2>/dev/null
alias ls='eza' 2>/dev/null
alias l1='eza -1'

# Ripgrep for grep
alias grep='rg' 2>/dev/null
alias egrep='rg' 2>/dev/null
alias fgrep='rg -F' 2>/dev/null
alias xzgrep='rg -z' 2>/dev/null
alias xzegrep='rg -z' 2>/dev/null
alias xzfgrep='rg -z -F' 2>/dev/null

# Zoxide is handling cd
alias cd='cd' 2>/dev/null

# Fd for find
alias find='fd' 2>/dev/null
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
if test "$(id -u)" -gt "0"
set -gx PATH $PATH /home/linuxbrew/.linuxbrew/bin
set -gx HOMEBREW_PREFIX /home/linuxbrew/.linuxbrew
set -gx HOMEBREW_CELLAR /home/linuxbrew/.linuxbrew/Cellar
set -gx HOMEBREW_REPOSITORY /home/linuxbrew/.linuxbrew
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function fish_command_not_found
# "In a container" check
if test -e /run/.containerenv -o -e /.dockerenv
distrobox-host-exec $argv
else
__fish_default_command_not_found_handler $argv
end
end
Loading