diff --git a/.bashrc b/.bashrc new file mode 100644 index 00000000..5efcfce3 --- /dev/null +++ b/.bashrc @@ -0,0 +1,110 @@ +# +# ~/.bashrc +# + +# If not running interactively, don't do anything +[[ $- != *i* ]] && return + +[[ -f ~/.welcome_screen ]] && . ~/.welcome_screen + +BROWSER='/usr/bin/brave' +_set_liveuser_PS1() { + PS1='[\u@\h \W]\$ ' + if [ "$(whoami)" = "liveuser" ] ; then + local iso_version="$(grep ^VERSION= /usr/lib/endeavouros-release 2>/dev/null | cut -d '=' -f 2)" + if [ -n "$iso_version" ] ; then + local prefix="eos-" + local iso_info="$prefix$iso_version" + PS1="[\u@$iso_info \W]\$ " + fi + fi +} +_set_liveuser_PS1 +unset -f _set_liveuser_PS1 + +ShowInstallerIsoInfo() { + local file=/usr/lib/endeavouros-release + if [ -r $file ] ; then + cat $file + else + echo "Sorry, installer ISO info is not available." >&2 + fi +} + + +alias ls='ls --color=auto' +alias ll='ls -lav --ignore=..' # show long listing of all except ".." +alias l='ls -lav --ignore=.?*' # show long listing but no hidden dotfiles except "." +alias vim='nvim' + +[[ "$(whoami)" = "root" ]] && return + +[[ -z "$FUNCNEST" ]] && export FUNCNEST=100 # limits recursive functions, see 'man bash' + +## Use the up and down arrow keys for finding a command in history +## (you can write some initial letters of the command first). +bind '"\e[A":history-search-backward' +bind '"\e[B":history-search-forward' + +################################################################################ +## Some generally useful functions. +## Consider uncommenting aliases below to start using these functions. +## +## October 2021: removed many obsolete functions. If you still need them, please look at +## https://github.com/EndeavourOS-archive/EndeavourOS-archiso/raw/master/airootfs/etc/skel/.bashrc + +_open_files_for_editing() { + # Open any given document file(s) for editing (or just viewing). + # Note1: + # - Do not use for executable files! + # Note2: + # - Uses 'mime' bindings, so you may need to use + # e.g. a file manager to make proper file bindings. + + if [ -x /usr/bin/exo-open ] ; then + echo "exo-open $@" >&2 + setsid exo-open "$@" >& /dev/null + return + fi + if [ -x /usr/bin/xdg-open ] ; then + for file in "$@" ; do + echo "xdg-open $file" >&2 + setsid xdg-open "$file" >& /dev/null + done + return + fi + + echo "$FUNCNAME: package 'xdg-utils' or 'exo' is required." >&2 +} + +#------------------------------------------------------------ + +## Aliases for the functions above. +## Uncomment an alias if you want to use it. +## +alias ls="exa --long --git --header --icons" + +# alias ef='_open_files_for_editing' # 'ef' opens given file(s) for editing +# alias pacdiff=eos-pacdiff +################################################################################ + + +eval "$(thefuck --alias)" + +# prompt +. "$HOME/.cargo/env" + +# >>> juliaup initialize >>> + +# !! Contents within this block are managed by juliaup !! + +case ":$PATH:" in + *:/home/fic/.juliaup/bin:*) + ;; + + *) + export PATH=/home/fic/.juliaup/bin${PATH:+:${PATH}} + ;; +esac + +# <<< juliaup initialize <<< diff --git a/.config/yadm/README.md b/.config/yadm/README.md new file mode 100644 index 00000000..ad401067 --- /dev/null +++ b/.config/yadm/README.md @@ -0,0 +1,49 @@ +# Daniel's Dotfiles + +My personal Linux dotfiles. + +I use Arch btw. + +The root of this repo is equivalent to my $HOME directory. + +## Of Interest + +### Neovim + +Neovim, my beloved. + +The best text editor ever made. There's too much going on there to cover here, so I invite you to read my [Neovim config README](./.config/nvim/README.md). + +### Shell + +I use Zsh. It has some nice features while remaining POSIX compliance, which is important if you like to tinker and end up copying a lot of shell scripts from the internet. I also use `starship` for my prompt because it's wicked fast. I find that the `pure` preset with some minor changes to cwd display is really great for my needs. + +### Tmux + +I really like tmux as a terminal multiplexer. The `vim-tmux-navigator` plugin offers really nice compatibility with Neovim split windows. The `minimal-tmux-status` is also really nice: displays only what's needed, in a slightly cleaner way than the default status bar. `tmux-yank` is awesome for easily copying text from the terminal without needing to use the mouse. + +### Terminal + +Kitty has been the best terminal for me so far. It displays stuff properly, and is as fast as I need it to be. + +### i3 + +I'm using i3 for window management. I have experimented in the past with Hyprland, but I prefer the simplicity of i3. + +### Launcher + +Rofi is my application launcher of choice. It's easy to configure, minimal, and gets out of the way. + +### Process Viewer + +`btop` works great when `ps aux | grep` doesn't cut it. It's fast and has a pleasing, intuitive UI. I highly recommend it over both top and htop. + +### Notifications + +Dunst is all I want from a notification manager. + +### Management + +Currently I'm using `yadm` to manage these dotfiles. I have tried some other solutions like `chezmoi` and `stow`, but this one has stuck for me. I highly recommend it. + +If you see a file with a weird name, like `config##hostname.dbox`, it's leveraging `yadm`'s alternate files feature; the program will automatically symlink that file to its appropriate destination depending on which computer it's on. diff --git a/.config/yadm/autoyadm.sh b/.config/yadm/autoyadm.sh new file mode 100755 index 00000000..66ba8f7a --- /dev/null +++ b/.config/yadm/autoyadm.sh @@ -0,0 +1,45 @@ +#!/bin/bash + +# This script reads tracked paths +# from a file and executes "yadm add" +# on all of them, then creates a timestamped +# commit and pushes the changes. + +AYE="AutoYADM Error:" +AYM="AutoYADM:" + +# First we read each path from "tracked" +while read -r path; do + # Execute yadm add on each real file + # if the path points to a directory + # This ensures symlinks are not added + if [ -d "$path" ]; then + find "$path" -type f -exec yadm add {} + + # If just a file, we add directly + elif [ -f "$path" ]; then + yadm add "$path" + # If neither file nor dir, something is very wrong! + else + echo "$AYE Target must be a directory or a file!" + exit 1 + fi +done <"$HOME/.config/yadm/tracked" + +# Define the location of the ssh-agent environment +sshenv="$HOME/.ssh/environment-$HOST" + +if [[ -n $(yadm status --porcelain) ]]; then + yadm commit -m "AutoYADM commit: $(date +'%Y-%m-%d %H:%M:%S')" + # Check if the ssh-agent env exists + if [ -f "$sshenv" ]; then + # Directive to suppress shellcheck warning + # shellcheck source=/dev/null + source "$sshenv" + yadm push + else + echo "$AYE ssh-agent environment not found, aborting push..." + exit 1 + fi +fi + +echo "$AYM Push successful!" diff --git a/.config/yadm/oldautoyadm.sh b/.config/yadm/oldautoyadm.sh new file mode 100755 index 00000000..08c3fe9a --- /dev/null +++ b/.config/yadm/oldautoyadm.sh @@ -0,0 +1,32 @@ +#!/bin/bash +# Add individual files, ignoring symlinks +[ ! -L "$HOME/.zshrc" ] && yadm add "$HOME/.zshrc" + +# Directory navigation +cd "$HOME/.config/" || exit + +# List of config directories/files to add +configs=(nvim btop dunst i3 kitty lazygit nushell polybar rofi tmux wal zathura starship.toml yadm) + +# Loop through each item in configs array +for config in "${configs[@]}"; do + # Check if it's not a symlink before adding + # [ ! -L "$config" ] && [ -n "$(find "$config" -type l)" ] && yadm add "$config" + find "$config" -type f -exec yadm add {} + +done + +sshenv="$HOME/.ssh/environment-$(cat /etc/hostname)" + +# Commit and push if there are changes +if [[ -n $(yadm status --porcelain) ]]; then + yadm commit -m "Auto commit: $(date +'%Y-%m-%d %H:%M:%S')" + # Check if the ssh-agent env is present + if [ -f "$sshenv" ]; then + # shellcheck source=/dev/null + source "$sshenv" + yadm push + else + echo "ERROR: ssh-agent environment not found, aborting push..." + exit + fi +fi diff --git a/.config/yadm/tracked b/.config/yadm/tracked new file mode 100644 index 00000000..c20ce973 --- /dev/null +++ b/.config/yadm/tracked @@ -0,0 +1,16 @@ +/home/fic/.config/yadm +/home/fic/.config/nvim +/home/fic/.config/btop +/home/fic/.config/dunst +/home/fic/.config/i3 +/home/fic/.config/kitty +/home/fic/.config/lazygit +/home/fic/.config/nushell +/home/fic/.config/polybar +/home/fic/.config/rofi +/home/fic/.config/tmux +/home/fic/.config/wal +/home/fic/.config/zathura +/home/fic/.config/starship.toml +/home/fic/.zshrc +/home/fic/.bashrc diff --git a/.config/yadm/yadmadd.sh b/.config/yadm/yadmadd.sh new file mode 100755 index 00000000..b5b85a2e --- /dev/null +++ b/.config/yadm/yadmadd.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# This script takes file or directories as +# arguments and appends them to the "tracked" +# file, for use by autoyadm.sh + +YADMDIR="$HOME/.config/yadm" +AYE="AutoYADM Error:" +AYM="AutoYADM:" + +# We check if any arguments have been provided +if [ $# -eq 0 ]; then + echo "$AYE $0 [ ...]" + exit 1 +fi + +# We loop through arguments +for arg in "$@"; do + # check if current arg is a real path + if [ ! -e "$arg" ]; then + echo "$AYE '$arg' is not a valid path." + continue + fi + # get its absolute path + abs=$(realpath "$arg") + # check if it's inside home dir + if [[ "$abs" == "$HOME"* ]]; then + # convert to path relative to ~ + rel=${abs#"$HOME/"} + # append to tracked file + echo "$HOME/$rel" >>"$YADMDIR/tracked" + echo "$AYM Tracking $HOME/$rel" + else + echo "$AYM Path must be inside the home directory." + exit 1 + fi +done diff --git a/.zshrc b/.zshrc index d4934e78..937b4120 100644 --- a/.zshrc +++ b/.zshrc @@ -29,6 +29,10 @@ alias tnt="tmux new-session -t" alias svenv="source .venv/bin/activate" alias szsh="source ~/.zshrc" +alias vzsh="vim ~/.zshrc" + +alias autoyadm="~/.config/yadm/autoyadm.sh" +alias yadmadd="~/.config/yadm/yadmadd.sh" bindkey -r '^T'