commit 969668e497154d5f09683bd3322c0fbfe74fa248 Author: chodak166 Date: Thu Apr 16 18:16:32 2026 +0200 Added initial shell dotfiles diff --git a/.bashrc b/.bashrc new file mode 100755 index 0000000..e35c1e4 --- /dev/null +++ b/.bashrc @@ -0,0 +1,172 @@ +### Added by Codeium. These lines cannot be automatically removed if modified +if command -v termium > /dev/null 2>&1; then + eval "$(termium shell-hook show pre)" +fi +### End of Codeium integration +# ~/.bashrc: executed by bash(1) for non-login shells. +# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) +# for examples + +# If not running interactively, don't do anything +case $- in + *i*) ;; + *) return;; +esac + +# don't put duplicate lines or lines starting with space in the history. +# See bash(1) for more options +HISTCONTROL=ignoreboth + +# append to the history file, don't overwrite it +shopt -s histappend + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=20000 +HISTFILESIZE=50000 + +# check the window size after each command and, if necessary, +# update the values of LINES and COLUMNS. +shopt -s checkwinsize + +# If set, the pattern "**" used in a pathname expansion context will +# match all files and zero or more directories and subdirectories. +#shopt -s globstar + +# 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 + +# uncomment for a colored prompt, if the terminal has the capability; turned +# off by default to not distract the user: the focus in a terminal window +# should be on the output of commands, not on the prompt +#force_color_prompt=yes + +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 + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' +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 dir='dir --color=auto' + #alias vdir='vdir --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' + +# some more ls aliases +alias ll='ls -alF' +alias la='ls -A' +alias l='ls -CF' + +# 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$//'\'')"' + +# Alias definitions. +# You may want to put all your additions into a separate file like +# ~/.bash_aliases, instead of adding them here directly. +# See /usr/share/doc/bash-doc/examples in the bash-doc package. + +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + +# 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 + +######### GIT-AWARE-PROMPT ######### + +export GITAWAREPROMPT=/usr/share/git-aware-prompt +source "${GITAWAREPROMPT}/main.sh" + +export PS1="\${debian_chroot:+(\$debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] \[$txtcyn\]\$git_branch\[$txtred\]\$git_dirty\[$txtrst\]\$ " + +#################################### + +if [[ "$TERM" == screen* ]]; then + screen_set_window_title () { + + if [ -z "$SLABEL" ] + then + + local HPWD="$PWD" + case $HPWD in + $HOME) HPWD="~";; + $HOME/*) HPWD="~${HPWD#$HOME}";; + esac + printf '\ek%s\e\\' "$HPWD" + else + printf '\ek%s\e\\' "$SLABEL" + fi + } + PROMPT_COMMAND="screen_set_window_title; $PROMPT_COMMAND" +fi + +PROMPT_COMMAND="history -a; $PROMPT_COMMAND" + + + +alias pbgit='git config user.name "Łukasz Chodyła" && git config user.email "lukasz.chodyla@platformabiznesu.net"' + +alias bashI="bash --init-file <(echo '. ~/.bashrc; unset HISTFILE')" + + +alias gl="git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all" + +[ -f ~/.fzf.bash ] && source ~/.fzf.bash + +alias cat=batcat + +### Added by Codeium. These lines cannot be automatically removed if modified +if command -v termium > /dev/null 2>&1; then + eval "$(termium shell-hook show post)" +fi +### End of Codeium integration +. "$HOME/.local/bin/env" diff --git a/.tmux.conf b/.tmux.conf new file mode 100644 index 0000000..2abe6bd --- /dev/null +++ b/.tmux.conf @@ -0,0 +1,34 @@ +set -g default-command /usr/bin/zsh + +set -g default-terminal "xterm-256color" + +# disable mouse mode (to use selection mode from current terminal) +set-option -g mouse off + +# copy mode +setw -g mode-keys vi +bind-key -T copy-mode-vi 'v' send -X begin-selection +bind-key -T copy-mode-vi 'y' send -X copy-selection-and-cancel + +# single-line scrolling in copy mode +bind-key -T copy-mode-vi WheelUpPane send-keys -X scroll-up +bind-key -T copy-mode-vi WheelDownPane send-keys -X scroll-down + +# scrolling with shift + pup/pdown +bind-key -n S-Pageup copy-mode -u +bind-key -n S-Pagedown send-keys Pagedown + +# Home/End for line navigation +bind-key -n Home send-key C-a +bind-key -n End send-key C-e + +# set status bar color +set -g status-bg "dark cyan" + +# window rename +set-option -g status-interval 5 +set-option -g automatic-rename on +set-option -g automatic-rename-format '#{b:pane_current_command}:#{b:pane_current_path}' + + + diff --git a/.zimrc b/.zimrc new file mode 100644 index 0000000..356b855 --- /dev/null +++ b/.zimrc @@ -0,0 +1,60 @@ +# Start configuration added by Zim install {{{ +# +# This is not sourced during shell startup, and it's only used to configure the +# zimfw plugin manager. +# + +# +# Modules +# + +# Sets sane Zsh built-in environment options. +zmodule environment +# Provides handy git aliases and functions. +zmodule git +# Applies correct bindkeys for input events. +zmodule input +# Sets a custom terminal title. +zmodule termtitle +# Utility aliases and functions. Adds colour to ls, grep and less. +zmodule utility + +# +# Prompt +# + +# Exposes to prompts how long the last command took to execute, used by asciiship. +zmodule duration-info + +# Exposes git repository status information to prompts, used by asciiship. +zmodule git-info + +# A heavily reduced, ASCII-only version of the Spaceship and Starship prompts. +zmodule asciiship + +zmodule bira + +# +# Completion +# + +# Additional completion definitions for Zsh. +zmodule zsh-users/zsh-completions --fpath src +# Enables and configures smart and extensive tab completion. +# completion must be sourced after all modules that add completion definitions. +zmodule completion + +# +# Modules that must be initialized last +# + +# Fish-like syntax highlighting for Zsh. +# zsh-users/zsh-syntax-highlighting must be sourced after completion +zmodule zsh-users/zsh-syntax-highlighting +# Fish-like history search (up arrow) for Zsh. +# zsh-users/zsh-history-substring-search must be sourced after zsh-users/zsh-syntax-highlighting +zmodule zsh-users/zsh-history-substring-search +# Fish-like autosuggestions for Zsh. +zmodule zsh-users/zsh-autosuggestions +# }}} End configuration added by Zim install + diff --git a/.zshrc b/.zshrc new file mode 100644 index 0000000..62f6ce6 --- /dev/null +++ b/.zshrc @@ -0,0 +1,241 @@ +# Start configuration added by Zim install {{{ +# +# User configuration sourced by interactive shells +# + +# ----------------- +# Zsh configuration +# ----------------- + +# +# Input/output +# + +setopt CLOBBER # enable >> + +# Set editor default keymap to emacs (`-e`) or vi (`-v`) +bindkey -e + +# Prompt for spelling correction of commands. +#setopt CORRECT + +# Customize spelling correction prompt. +#SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? ' + +# Remove path separator from WORDCHARS. +WORDCHARS=${WORDCHARS//[\/]} + +# ----------------- +# Zim configuration +# ----------------- + +# Use degit instead of git as the default tool to install and update modules. +#zstyle ':zim:zmodule' use 'degit' + +# -------------------- +# Module configuration +# -------------------- + +# +# git +# + +# Set a custom prefix for the generated aliases. The default prefix is 'G'. +#zstyle ':zim:git' aliases-prefix 'g' + +# +# input +# + +# Append `../` to your input for each `.` you type after an initial `..` +#zstyle ':zim:input' double-dot-expand yes + +# +# termtitle +# + +# Set a custom terminal title format using prompt expansion escape sequences. +# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes +# If none is provided, the default '%n@%m: %~' is used. +#zstyle ':zim:termtitle' format '%1~' + +# +# zsh-autosuggestions +# + +# Disable automatic widget re-binding on each precmd. This can be set when +# zsh-users/zsh-autosuggestions is the last module in your ~/.zimrc. +ZSH_AUTOSUGGEST_MANUAL_REBIND=1 + +# Customize the style that the suggestions are shown with. +# See https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md#suggestion-highlight-style +#ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=242' + +# +# zsh-syntax-highlighting +# + +# Set what highlighters will be used. +# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md +ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets) + +# Customize the main highlighter styles. +# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it +#typeset -A ZSH_HIGHLIGHT_STYLES +#ZSH_HIGHLIGHT_STYLES[comment]='fg=242' + +# ------------------ +# Initialize modules +# ------------------ + +ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim +# Download zimfw plugin manager if missing. +if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then + if (( ${+commands[curl]} )); then + curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh + else + mkdir -p ${ZIM_HOME} && wget -nv -O ${ZIM_HOME}/zimfw.zsh \ + https://github.com/zimfw/zimfw/releases/latest/download/zimfw.zsh + fi +fi +# Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated. +if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then + source ${ZIM_HOME}/zimfw.zsh init -q +fi +# Initialize modules. +source ${ZIM_HOME}/init.zsh + +# ------------------------------ +# Post-init module configuration +# ------------------------------ + +# +# History +# + +unsetopt SHARE_HISTORY + +setopt EXTENDED_HISTORY +setopt INC_APPEND_HISTORY +setopt HIST_IGNORE_ALL_DUPS + +export HISTTIMEFORMAT="[%F %T] " +export HISTFILE=~/.zsh_history +export HISTFILESIZE=1000000000 +export HISTSIZE=1000000000 + +#alias history='history -E 0' + + +# +# zsh-history-substring-search +# + +zmodload -F zsh/terminfo +p:terminfo +# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init +#for key ('^[[A' '^P' ${terminfo[kcuu1]}) bindkey ${key} history-substring-search-up +#for key ('^[[B' '^N' ${terminfo[kcud1]}) bindkey ${key} history-substring-search-down +#for key ('k') bindkey -M vicmd ${key} history-substring-search-up +#for key ('j') bindkey -M vicmd ${key} history-substring-search-down +#unset key +# }}} End configuration added by Zim install + + +# screen window naming + +if [[ "$TERM" == screen* ]]; then + screen_set_window_title () { + + if [ -z "$SLABEL" ] + then + + local HPWD="$PWD" + case $HPWD in + $HOME) HPWD="~";; + $HOME/*) HPWD="~${HPWD#$HOME}";; + esac + printf '\ek%s\e\\' "$HPWD" + else + printf '\ek%s\e\\' "$SLABEL" + fi + } + PROMPT_COMMAND="screen_set_window_title; $PROMPT_COMMAND" +fi + +edit_secure() { + # Using $HOME is safer than ~ inside scripts + local plain_file="$HOME/.scripts/secure_functions.sh" + local encrypted_file="${plain_file}.gpg" + + # 1. Check if the encrypted file exists + if [[ -f "$encrypted_file" ]]; then + # It exists: Decrypt it so we can edit + gpg -q -o "$plain_file" -d "$encrypted_file" || return 1 + else + # It doesn't exist: Create the directory just in case + mkdir -p "$(dirname "$plain_file")" + echo "Creating new secure file..." + fi + + # 2. Open editor (Defaults to nano if EDITOR is not set) + ${EDITOR:-nano} "$plain_file" + + # 3. Encrypt and Cleanup + # Only encrypt if the file actually exists (in case you exited editor without saving) + if [[ -f "$plain_file" ]]; then + echo "Encrypting..." + # Encrypt (-c) AND THEN remove the plaintext file (rm) only if encryption succeeded (&&) + gpg -c "$plain_file" && rm "$plain_file" + echo "Done. Secrets saved to $encrypted_file" + else + echo "Aborted: No file saved." + fi +} + + +_run_secure_func() { + local func_name="$1" + local encrypted_file="$HOME/.scripts/secure_functions.sh.gpg" + + [[ -f "$encrypted_file" ]] || { + echo "Error: Encrypted file not found" >&2 + return 1 + } + + # SECURITY CRITICAL: Run in isolated subshell with history disabled + ( + # Cross-shell history disabling + unset HISTFILE # Disables history file in BOTH shells + HISTSIZE=0 # Bash: disable in-memory history + SAVEHIST=0 # Zsh: disable history saving + + # Zsh-specific hardening (safe to run in bash too) + [ -n "${ZSH_VERSION:-}" ] && setopt no_history no_hist_save no_hist_verify 2>/dev/null || true + + # Decrypt → source → execute (all in-memory) + gpg --quiet --decrypt "$encrypted_file" 2>/dev/null | { + source /dev/stdin + "$func_name" + } + ) + + # Optional: Invalidate cache after use (prevents lingering secrets) + #{ sleep 1; echo RELOADAGENT | gpg-connect-agent >/dev/null 2>&1; } & +} + + +test_secure() { + _run_secure_func _test_secure +} + + +[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh + +alias bat=batcat +alias ll='eza --icons=auto -T --level 2 -lah --group-directories-first --color=always | less' +alias config='/usr/bin/git --git-dir=$HOME/.dotfiles/ --work-tree=$HOME' + +export VCPKG_ROOT=/opt/vcpkg + +. "$HOME/.local/bin/env"