From 34d9d9f7177eb4e91e482be4e19898caeea40e0f Mon Sep 17 00:00:00 2001 From: Heus-Sueh <98482469+Heus-Sueh@users.noreply.github.com> Date: Fri, 4 Oct 2024 14:03:17 -0300 Subject: [PATCH] adding my bashrc and aliases --- files/system/etc/skel/.aliases | 118 +++++++++++++ files/system/etc/skel/.bashrc | 107 +++++++++++ .../etc/skel/.config/hypr/keybinds.conf | 8 +- files/system/etc/skel/.local/bin/nvim-arch | 15 ++ files/system/etc/skel/.local/bin/rpm-copr | 166 ++++++++++++++++++ 5 files changed, 410 insertions(+), 4 deletions(-) create mode 100644 files/system/etc/skel/.aliases create mode 100644 files/system/etc/skel/.bashrc create mode 100755 files/system/etc/skel/.local/bin/nvim-arch create mode 100755 files/system/etc/skel/.local/bin/rpm-copr diff --git a/files/system/etc/skel/.aliases b/files/system/etc/skel/.aliases new file mode 100644 index 0000000..c938cc6 --- /dev/null +++ b/files/system/etc/skel/.aliases @@ -0,0 +1,118 @@ +#!/usr/bin/env bash +# Shortcuts +alias profile="$EDITOR ~/.profile" +alias bashrc="$EDITOR ~/.bashrc" +alias zshrc="$EDITOR ~/.zshrc" +# alias ohmyzsh="$EDITOR ~/.oh-my-zsh" +alias clickpaste='sleep 3; xdotool type "$(xclip -o -selection clipboard)"' + +# Change directory aliases +if [ "$(command -v zoxide)" ]; then + alias cd="z" +fi + +# Remove a directory and all files +alias rmd='/bin/rm --recursive --force --verbose ' + +# ls aliases +if [ "$(command -v eza)" ]; then + alias ll='eza -l --icons=auto --group-directories-first' + alias l.='eza -d .*' + alias ls='eza' + alias l1='eza -1' +fi + +if [ "$(command -v fd)" ]; then + alias find="fd" +fi + +if [ "$(command -v bat)" ]; then + alias cat="bat" +fi + +# ugrep for grep +if [ "$(command -v ug)" ]; then + alias grep='ug' + alias egrep='ug -E' + alias fgrep='ug -F' + alias xzgrep='ug -z' + alias xzegrep='ug -zE' + alias xzfgrep='ug -zF' +fi + +# Check if ripgrep is installed +if [ "$(command -v rg)" ]; then + # Alias grep to rg if ripgrep is installed + alias grep='rg' +else + # Alias grep to /usr/bin/grep with GREP_OPTIONS if ripgrep is not installed + alias grep="/usr/bin/grep $GREP_OPTIONS" +fi +unset GREP_OPTIONS + +if [ "$(command -v trash)" ]; then + alias rm='trash -v' +fi + +case "$(command -v apt pacman dnf rpm-ostree 2>/dev/null | head -n 1)" in +*apt) + alias pkg='sudo apt' + ;; +*pacman) + alias pkg='sudo pacman' + ;; +*dnf) + alias pkg='sudo dnf' + ;; +*rpm-ostree) + alias pkg='rpm-ostree' + ;; +*) + echo "No supported package manager found." + ;; +esac + +alias home='cd ~' +alias cd..='cd ..' +alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' +alias .....='cd ../../../..' + +# Always interactive +alias cp='cp -i' +alias mv='mv -i' + +alias mkdir='mkdir -p' +alias ps='ps auxf' +alias ping='ping -c 10' +alias less='less -R' +alias h="history | grep " +alias f="find . | grep " +alias openports='netstat -nape --inet' +alias unexport="unset" +alias readf="less" +alias seef="bat" +alias help="man" +alias cls="clear" +alias xkill="pkill -i" +alias pkg="rpm-ostree" +# alias chmod commands +alias mkexe='chmod a+x' +alias mx='chmod a+x' +alias 000='chmod -R 000' +alias 644='chmod -R 644' +alias 666='chmod -R 666' +alias 755='chmod -R 755' +alias 777='chmod -R 777' +# Alias's for archives +alias mktar='tar -cvf' +alias mkbz2='tar -cvjf' +alias mkgz='tar -cvzf' +alias untar='tar -xvf' +alias unbz2='tar -xvjf' +alias ungz='tar -xvzf' +# Nvidia +alias nrun='__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia' +# Others + diff --git a/files/system/etc/skel/.bashrc b/files/system/etc/skel/.bashrc new file mode 100644 index 0000000..7ae5bf1 --- /dev/null +++ b/files/system/etc/skel/.bashrc @@ -0,0 +1,107 @@ +#!/usr/bin/env bash +iatest=$(expr index "$-" i) + +# Source profile definitions +if [ -f $HOME/.profile ]; then + . $HOME/.profile +fi + +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc +fi + +# Enable bash programmable completion features in interactive shells +if [ -f /usr/share/bash-completion/bash_completion ]; then + . /usr/share/bash-completion/bash_completion +elif [ -f /etc/bash_completion ]; then + . /etc/bash_completion +fi + +# Expand the history size +export HISTFILESIZE=10000 +export HISTSIZE=500 +export HISTTIMEFORMAT="%F %T" # add timestamp to history + +# Don't put duplicate lines in the history and do not add lines that start with a space +export HISTCONTROL=erasedups:ignoredups:ignorespace + +# Check the window size after each command and, if necessary, update the values of LINES and COLUMNS +shopt -s checkwinsize + +# Causes bash to append to history instead of overwriting it so if you start a new terminal, you have old session history +shopt -s histappend +PROMPT_COMMAND='history -a' + +# Allow ctrl-S for history navigation (with ctrl-R) +[[ $- == *i* ]] && stty -ixon + +# Disable the bell +if [[ $iatest -gt 0 ]]; then bind "set bell-style visible"; fi + +# Ignore case on auto-completion +# Note: bind used instead of sticking these in .inputrc +if [[ $iatest -gt 0 ]]; then bind "set completion-ignore-case on"; fi + +# Show auto-completion list automatically, without double tab +if [[ $iatest -gt 0 ]]; then bind "set show-all-if-ambiguous On"; fi + +# To have colors for ls and all grep commands such as grep, egrep and zgrep +export CLICOLOR=1 +export LS_COLORS='no=00:fi=00:di=00;34:ln=01;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.gz=01;31:*.bz2=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.avi=01;35:*.fli=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.ogg=01;35:*.mp3=01;35:*.wav=01;35:*.xml=00;31:' + +# Color for manpages in less makes manpages a little easier to read +export LESS_TERMCAP_mb=$'\E[01;31m' +export LESS_TERMCAP_md=$'\E[01;31m' +export LESS_TERMCAP_me=$'\E[0m' +export LESS_TERMCAP_se=$'\E[0m' +export LESS_TERMCAP_so=$'\E[01;44;33m' +export LESS_TERMCAP_ue=$'\E[0m' +export LESS_TERMCAP_us=$'\E[01;32m' + +# Functions +extract() { + for archive in "$@"; do + if [ -f "$archive" ]; then + case $archive in + *.tar.bz2) tar xvjf $archive ;; + *.tar.gz) tar xvzf $archive ;; + *.bz2) bunzip2 $archive ;; + *.rar) rar x $archive ;; + *.gz) gunzip $archive ;; + *.tar) tar xvf $archive ;; + *.tbz2) tar xvjf $archive ;; + *.tgz) tar xvzf $archive ;; + *.zip) unzip $archive ;; + *.Z) uncompress $archive ;; + *.7z) 7z x $archive ;; + *) echo "don't know how to extract '$archive'..." ;; + esac + else + echo "'$archive' is not a valid file!" + fi + done +} + +# Path +export PATH=$PATH:"$HOME/.local/bin" +export PATH=$PATH:"$HOME/.cargo/bin" + +export GOPATH=$HOME/.go +export GOMODCACHE=$HOME/.go/pkg/mod + +# Aliases +source $HOME/.aliases + +# Init +if command -v starship &>/dev/null; then + eval "$(starship init bash)" +fi + +if command -v zoxide &>/dev/null; then + eval "$(zoxide init bash)" +fi + +if command -v mise &>/dev/null; then + eval "$(~/.local/bin/mise activate bash)" +fi diff --git a/files/system/etc/skel/.config/hypr/keybinds.conf b/files/system/etc/skel/.config/hypr/keybinds.conf index f9d512a..4beff13 100644 --- a/files/system/etc/skel/.config/hypr/keybinds.conf +++ b/files/system/etc/skel/.config/hypr/keybinds.conf @@ -31,10 +31,10 @@ bind = CTRL ALT, tab, changegroupactive bind = $mainMod, left, changegroupactive, b bind = $mainMod, right, changegroupactive, f -bind = CTRL ALT, K, togglegroup -bind = CTRL ALT, J, moveoutofgroup -bind = CTRL ALT, L, moveintogroup, l -bind = CTRL ALT, H, moveintogroup, r +# bind = CTRL ALT, K, togglegroup +bind = CTRL $mainMod, Q, moveoutofgroup +bind = CTRL ALT, L, moveintogroup, l # Not so good +bind = CTRL ALT, H, moveintogroup, r # Not so good bind = $mainMod, H, changegroupactive, b bind = $mainMod, L, changegroupactive, f diff --git a/files/system/etc/skel/.local/bin/nvim-arch b/files/system/etc/skel/.local/bin/nvim-arch new file mode 100755 index 0000000..1cab6c5 --- /dev/null +++ b/files/system/etc/skel/.local/bin/nvim-arch @@ -0,0 +1,15 @@ +#!/bin/sh + +container_name="nvim-arch" + +# Verifica se o caminho foi passado como argumento +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +# Resolve o caminho absoluto do argumento +real_path=$(realpath "$1") + +# Entra no container e executa o nvim com o caminho passado +distrobox-enter -n "$container_name" -- nvim "$real_path" diff --git a/files/system/etc/skel/.local/bin/rpm-copr b/files/system/etc/skel/.local/bin/rpm-copr new file mode 100755 index 0000000..c594e20 --- /dev/null +++ b/files/system/etc/skel/.local/bin/rpm-copr @@ -0,0 +1,166 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# Colors +RC='\033[0m' +RED='\033[31m' +YELLOW='\033[33m' +GREEN='\033[32m' + +# Function to display usage instructions +display_usage() { + cat <, +and packages are not held to any quality or security level. + +Please do not file bug reports about these packages in Fedora +Bugzilla. In case of problems, contact the owner of this repository. + +Do you really want to enable copr.fedorainfracloud.org/$author/$reponame? [y/N]: +EOF +) + +# Function to backup and remove repo +backup_and_remove_repo() { + if [[ -e "$1" ]]; then + mkdir -p "$backup_dir" + pkexec cp "$1" "$repofilebak" && pkexec chown "$USER" "$repofilebak" + pkexec rm "$1" && echo -e "${GREEN}COPR Repository $author/$reponame removed.${RC}" || echo -e "${RED}ERROR removing COPR repository.${RC}" + else + echo -e "${YELLOW}Repo with name $author/$reponame not found, trying a search...${YELLOW}" + result=$(grep -ril --include='*.repo' "$reponame" /etc/yum.repos.d/) + if [[ -z "$result" ]]; then + echo -e "${RED}No repositories containing '$reponame' were found.${RC}" + else + read -rp "Repo '$result' was found. Do you want to backup and remove this repo? (Y/N) " answer + if [[ "${answer,,}" == "y" ]]; then + pkexec cp "$result" "$repofilebak" && pkexec chown "$USER" "$repofilebak" + pkexec rm "$result" && echo -e "${GREEN}COPR Repository '$reponame' removed.${RC}" || echo -e "${RED}ERROR removing COPR repository.${RC}" + fi + fi + fi +} + +# Main loop +case "$1" in +enable) + if [[ -f "$repofile" ]]; then + if grep -q 'enabled=0' "$repofile"; then + sed -i 's/enabled=0/enabled=1/' "$repofile" + echo -e "${GREEN}Repository $author/$reponame enabled.${RC}" + else + echo -e "${YELLOW}Repository $author/$reponame is already enabled.${RC}" + fi + else + read -p "$question" yn + if [[ "${yn,,}" == "y" ]]; then + echo "$author/$reponame -> $releasever" + curl -fsSL "https://copr.fedorainfracloud.org/coprs/$author/$reponame/repo/fedora-$releasever/$author-$reponame-fedora-.repo" | pkexec tee "$repofile" + else + echo -e "${YELLOW}Operation cancelled.${RC}" + fi + fi + ;; + +remove) + backup_and_remove_repo "$repofile" + ;; + +search) + xdg-open "https://copr.fedorainfracloud.org/coprs/fulltext/?fulltext=$2" + ;; + +disable) + if [[ -f "$repofile" && $(grep 'enabled=1' "$repofile") ]]; then + sed -i 's/enabled=1/enabled=0/' "$repofile" + echo -e "${GREEN}Repository $author/$reponame disabled.${RC}" + else + echo -e "${YELLOW}Repository is already disabled or not found.${RC}" + fi + ;; + +*) + echo -e "${YELLOW}Unknown option. Use 'help' to see available options.${RC}" + ;; +esac