diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..58b1a38 --- /dev/null +++ b/.bashrc @@ -0,0 +1,185 @@ +export ZSH="$HOME/.oh-my-zsh" +export SCRIPTS="$HOME/.local/bin/scripts" +export PERSONAL="$HOME/personal" +export SECOND_BRAIN="$HOME/sb" +export WORK="$HOME/work" +export UNI="$HOME/uni" +export STARTUP="$HOME/.config/autostart" +export NVM_DIR="$HOME/.nvm" +export GO="/usr/local/go/bin" +export TURSO="$HOME/.turso" +export DOTFILES="$HOME/Documents/dotfiles" + +if [[ $- == *i* ]]; then + bind '"\C-f":"tmux-sessionizer\n"' +fi + +# ~~~~~~~~~~~~~~~ Aliases ~~~~~~~~~~~~~~~~~~~~~~~~ +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' +alias da='date "+%Y-%m-%d %A %T %Z"' +alias home='cd ~' +alias cd..='cd ..' +alias ..='cd ..' +alias ...='cd ../..' +alias ....='cd ../../..' +alias .....='cd ../../../..' +alias h="history | grep " +alias topcpu="/bin/ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10" +alias f="find . | grep " +alias countfiles="for t in files links directories; do echo \`find . -type \${t:0:1} | wc -l\` \$t; done 2> /dev/null" +alias openports='netstat -nape --inet' # show open ports +alias v="nvim" +alias vi="nvim" +alias vim="nvim" +alias neovim="nvim" +alias c="clear" +alias pn="pnpm" +alias rm="trash" +alias sysupdate="sudo apt update && sudo apt full-upgrade" +alias lg="lazygit" +alias flatls="flatpak list --app --columns=size,name|sort -g | grep MB" +alias fpe="fzf --preview 'bat --color=always --style=numbers --line-range=:500 {}' | xargs nvim" +alias fp="fzf --preview 'bat --style=numbers --color=always --line-range :500 {}'" +alias getip="ip a | grep 192" +alias mktar='tar -cvf' +alias mkbz2='tar -cvjf' +alias mkgz='tar -cvzf' +alias untar='tar -xvf' +alias unbz2='tar -xvjf' +alias ungz='tar -xvzf' + +# cd +alias work="cd $WORK" +alias pers="cd $PERSONAL" +alias uni="cd $UNI" +alias sb="cd $SECOND_BRAIN" +alias scripts="cd $SCRIPTS" +alias startup="cd $STARTUP" + +# ricing +alias es="v $SCRIPTS" +alias ev="cd $HOME/.config/nvim && v" +alias ez="v $HOME/.zshrc" +alias eb="v $HOME/.bashrc" +alias sz="source $HOME/.zshrc" +alias sbr="source $HOME/.bashrc" + +if [ -f ~/.work_aliases ]; then + . ~/.work_aliases +fi + +# ~~~~~~~~~~~~~~~ Path Configuration ~~~~~~~~~~~~~~~~~~~~~~~~ +export PATH="$SCRIPTS:$PATH" +export PATH="$GO:$PATH" +export PATH="$TURSO_PATH:$PATH" + +# ~~~~~~~~~~~~~~~ NVM and Bash Completion ~~~~~~~~~~~~~~~~~~~~~~~~ +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm +[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion + +# ~~~~~~~~~~~~~~~ Editor Configuration ~~~~~~~~~~~~~~~~~~~~~~~~ +export EDITOR='nvim' # preferred editor for local and remote sessions +export VISUAL='nvim' + +# ~~~~~~~~~~~~~~~ Bash Shell Options ~~~~~~~~~~~~~~~~~~~~~~~~ +HISTCONTROL=ignoreboth +HISTSIZE=10000 +HISTFILESIZE=2000 +shopt -s checkwinsize +shopt -s histappend +PROMPT_COMMAND='history -a' + +# ~~~~~~~~~~~~~~~ Other ~~~~~~~~~~~~~~~~~~~~~~~~ + +## +# enable programmable completion features (you don't need to enable +# this, if it's already enabled in /etc/bash.bashrc and /etc/profile +# sources /etc/bash.bashrc). +if ! shopt -oq posix; then + 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 +fi +. "$HOME/.cargo/env" + +# make less more friendly for non-text input files, see lesspipe(1) +[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" + +# set variable identifying the chroot you work in (used in the prompt below) +if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then + debian_chroot=$(cat /etc/debian_chroot) +fi + +# set a fancy prompt (non-color, unless we know we "want" color) +case "$TERM" in +xterm-color | *-256color) color_prompt=yes ;; +esac + +if [ -n "$force_color_prompt" ]; then + if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then + # We have color support; assume it's compliant with Ecma-48 + # (ISO/IEC-6429). (Lack of such support is extremely rare, and such + # a case would tend to support setf rather than setaf.) + color_prompt=yes + else + color_prompt= + fi +fi + +if [ "$color_prompt" = yes ]; then + PROMPT_COMMAND='PS1_CMD1=$(__git_ps1 "(%s) ")'; PS1='\[\e[38;5;40m\][\[\e[38;5;33m\]\u\[\e[0m\]@\[\e[38;5;250m\]\h\[\e[0m\] \W\[\e[38;5;40m\]]\[\e[0m\]\\$ \[\e[38;5;34m\]${PS1_CMD1}\[\e[0m\]' +else + PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +fi +unset color_prompt force_color_prompt + +# If this is an xterm set the title to user@host:dir +case "$TERM" in +xterm* | rxvt*) + PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" + ;; +*) ;; +esac + +# enable color support of ls and also add handy aliases +if [ -x /usr/bin/dircolors ]; then + test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" + alias ls='ls --color=auto' + alias grep='grep --color=auto' + alias fgrep='fgrep --color=auto' + alias egrep='egrep --color=auto' +fi + +# colored GCC warnings and errors +export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' + +# If not running interactively, don't do anything +case $- in +*i*) ;; +*) return ;; +esac + +# Add an "alert" alias for long running commands. Use like so: +# sleep 10; alert +alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' + +# Color for man pages +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' + +# pnpm +export PNPM_HOME="/home/oasido/.local/share/pnpm" +case ":$PATH:" in +*":$PNPM_HOME:"*) ;; +*) export PATH="$PNPM_HOME:$PATH" ;; +esac +# pnpm end diff --git a/.config/lazygit/config.yml b/.config/lazygit/config.yml new file mode 100644 index 0000000..4533ca4 --- /dev/null +++ b/.config/lazygit/config.yml @@ -0,0 +1,9 @@ +gui: + showIcons: true +customCommands: + - key: "C" + command: "git cz c" + description: "commit with commitizen" + context: "files" + loadingText: "opening commitizen commit tool" + subprocess: true diff --git a/.config/systemd/user/default.target.wants/pipewire-source-stereo@virtual-microphone.service b/.config/systemd/user/default.target.wants/pipewire-source-stereo@virtual-microphone.service new file mode 120000 index 0000000..2a00e6b --- /dev/null +++ b/.config/systemd/user/default.target.wants/pipewire-source-stereo@virtual-microphone.service @@ -0,0 +1 @@ +/home/oasido/.config/systemd/user/pipewire-source-stereo@.service \ No newline at end of file diff --git a/.config/systemd/user/pipewire-sink-stereo@.service b/.config/systemd/user/pipewire-sink-stereo@.service new file mode 100644 index 0000000..b015562 --- /dev/null +++ b/.config/systemd/user/pipewire-sink-stereo@.service @@ -0,0 +1,18 @@ +[Unit] +Description = Add a pipewire stereo sink named %i + +After = pipewire.service + +[Service] +Type = oneshot + +StandardOutput = journal + +ExecStart = /bin/sh -c 'pactl load-module module-null-sink media.class=Audio/Sink sink_name="%i" channel_map=stereo > %h/.cache/pipewire_sink_stereo_%i' +ExecStopPost = -/bin/sh -c 'pactl unload-module $(cat %h/.cache/pipewire_sink_stereo_%i)' +ExecStopPost = -/bin/rm %h/.cache/pipewire_sink_stereo_%i + +RemainAfterExit = true + +[Install] +WantedBy = default.target \ No newline at end of file diff --git a/.config/systemd/user/pipewire-source-stereo@.service b/.config/systemd/user/pipewire-source-stereo@.service new file mode 100644 index 0000000..5022afa --- /dev/null +++ b/.config/systemd/user/pipewire-source-stereo@.service @@ -0,0 +1,18 @@ +[Unit] +Description = Add a pipewire stereo source named %i + +After = pipewire.service + +[Service] +Type = oneshot + +StandardOutput = journal + +ExecStart = /bin/sh -c 'pactl load-module module-null-sink object.linger=1 media.class=Audio/Source/Virtual sink_name="%i" channel_map=stereo > %h/.cache/pipewire_source_stereo_%i' +ExecStopPost = -/bin/sh -c 'pactl unload-module $(cat %h/.cache/pipewire_source_stereo_%i)' +ExecStopPost = -/bin/rm %h/.cache/pipewire_source_stereo_%i + +RemainAfterExit = true + +[Install] +WantedBy = default.target \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..407ab24 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.work_aliases diff --git a/.inputrc b/.inputrc new file mode 100644 index 0000000..6699d12 --- /dev/null +++ b/.inputrc @@ -0,0 +1,2 @@ +$include /etc/inputrc +set completion-ignore-case On diff --git a/.local/bin/scripts/ide b/.local/bin/scripts/ide new file mode 100755 index 0000000..9f0d121 --- /dev/null +++ b/.local/bin/scripts/ide @@ -0,0 +1,5 @@ +#!/bin/bash +tmux neww -n 'app' +tmux split-window -v -p 50 +tmux neww -n 'git' +tmux select-window -t:1 diff --git a/.local/bin/scripts/tmux-session b/.local/bin/scripts/tmux-session new file mode 100755 index 0000000..9bb30f2 --- /dev/null +++ b/.local/bin/scripts/tmux-session @@ -0,0 +1,58 @@ +#!/usr/bin/env bash +# Save and restore the state of tmux sessions and windows. +# TODO: persist and restore the state & position of panes. +set -e + +dump() { + local d=$'\t' + tmux list-windows -a -F "#S${d}#W${d}#{pane_current_path}" +} + +save() { + dump > ~/.tmux-session +} + +terminal_size() { + stty size 2>/dev/null | awk '{ printf "-x%d -y%d", $2, $1 }' +} + +session_exists() { + tmux has-session -t "$1" 2>/dev/null +} + +add_window() { + tmux new-window -d -t "$1:" -n "$2" -c "$3" +} + +new_session() { + cd "$3" && + tmux new-session -d -s "$1" -n "$2" $4 +} + +restore() { + tmux start-server + local count=0 + local dimensions="$(terminal_size)" + + while IFS=$'\t' read session_name window_name dir; do + if [[ -d "$dir" && $window_name != "log" && $window_name != "man" ]]; then + if session_exists "$session_name"; then + add_window "$session_name" "$window_name" "$dir" + else + new_session "$session_name" "$window_name" "$dir" "$dimensions" + count=$(( count + 1 )) + fi + fi + done < ~/.tmux-session + + echo "restored $count sessions" +} + +case "$1" in +save | restore ) + $1 + ;; +* ) + echo "valid commands: save, restore" >&2 + exit 1 +esac diff --git a/.local/bin/scripts/tmux-sessionizer b/.local/bin/scripts/tmux-sessionizer new file mode 100755 index 0000000..f2ffa03 --- /dev/null +++ b/.local/bin/scripts/tmux-sessionizer @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +if [[ $# -eq 1 ]]; then + selected=$1 +else + selected=$(find ~/personal ~/uni ~/work -mindepth 1 -maxdepth 1 -type d | fzf) +fi + +if [[ -z $selected ]]; then + exit 0 +fi + +selected_name=$(basename "$selected" | tr . _) +tmux_running=$(pgrep tmux) + +if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then + tmux new-session -s $selected_name -c $selected + exit 0 +fi + +if ! tmux has-session -t=$selected_name 2> /dev/null; then + tmux new-session -ds $selected_name -c $selected +fi + +tmux switch-client -t $selected_name diff --git a/.local/bin/scripts/wifi-pass b/.local/bin/scripts/wifi-pass new file mode 100755 index 0000000..2e8d7cd --- /dev/null +++ b/.local/bin/scripts/wifi-pass @@ -0,0 +1,12 @@ +#!/bin/bash +# Show SSID and password for the currently connected network. Requires sudo. +set -e + +ssid="$(/System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -I | sed -n "/ SSID:/s/^.\\{2,\\}: //p")" +if [ -n "$ssid" ]; then + echo "$ssid" + security find-generic-password -ga "$ssid" 2>&1 >/dev/null | cut -d\" -f2 +else + echo "No current wifi network name detected" >&2 + exit 1 +fi diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..2cd105a --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,38 @@ +# General settings +set-option -g default-terminal "screen-256color" +set -sa terminal-overrides ",xterm-256color:RGB" +set -s escape-time 50 +set -g base-index 1 +set-option -g focus-events on +set -g mouse on + +# Prefix and key bindings +unbind C-b +set-option -g prefix C-a +bind-key C-a send-prefix +bind r source-file ~/.tmux.conf + +# VIM like pane and window navigation +bind -r ^ last-window +bind -r k select-pane -U +bind -r j select-pane -D +bind -r h select-pane -L +bind -r l select-pane -R +bind-key -r f run-shell "tmux neww ~/.local/bin/tmux-sessionizer" +bind-key -r G run-shell "~/.local/bin/scripts/tmux-sessionizer ~/personal" + +# Copy mode (vi mode) +set-window-option -g mode-keys vi +bind -T copy-mode-vi v send-keys -X begin-selection +bind -T copy-mode-vi y send-keys -X copy-pipe-and-cancel 'xclip -in -selection clipboard' + +# Status bar configuration +set -g status-fg colour8 +set -g status-bg colour234 +set -g status-left ' #S ' +set -g status-left-length 15 +set -g status-left-style fg=colour229,bg=colour166 +set -g window-status-format "#[fg=colour8] #I #[fg=colour231]#W#[fg=colour166]#F " +set -g window-status-current-format "#[fg=colour117,bg=colour31] #I #[fg=colour231]#W#[fg=colour234]#F " +set -g window-status-separator "" +