From 03d35a7b27dea6a4effe5b692a99db19844bd7dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Varko=C4=8Dek?= Date: Tue, 18 Aug 2026 10:27:52 +0200 Subject: [PATCH] condiional local things, prompt colors based on a machine PROD ENV --- .bash_aliases | 12 +++++ .bashrc | 169 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ .profile | 27 ++++++++++ 3 files changed, 208 insertions(+) create mode 100644 .bash_aliases create mode 100644 .bashrc create mode 100644 .profile diff --git a/.bash_aliases b/.bash_aliases new file mode 100644 index 0000000..1308c59 --- /dev/null +++ b/.bash_aliases @@ -0,0 +1,12 @@ +alias downtime='uptime' +alias irb=" irb --simple-prompt --readline -r irb/completion" +alias psg="ps -ef | grep" +alias hgr="history | grep" +alias runvnc="x11vnc -rfbauth .vnc/passwd -display :0 -bg -loop &" +alias ssh-null='ssh -o "UserKnownHostsFile=/dev/null" -o "StrictHostKeyChecking=no"' +alias ssh-old='ssh -p 22 -o ServerAliveInterval=30 -o KexAlgorithms=+diffie-hellman-group1-sha1 -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -A ' +alias ssh-oldy='ssh -p 22 -I /usr/lib/x86_64-linux-gnu/libykcs11.so -o ServerAliveInterval=30 -o KexAlgorithms=+diffie-hellman-group1-sha1 -o HostKeyAlgorithms=+ssh-rsa -o PubkeyAcceptedAlgorithms=+ssh-rsa -o StrictHostKeyChecking=no -A ' +alias slunojump="ssh admink2@zabbix6.k2.cz -p 801 -o ServerAliveInterval=30 -A -t 'ssh sluno'" +alias whatsmyip="curl ifconfig.me;echo" +alias apt-get-force="sudo apt-get -o Dpkg::Options::='--force-overwrite' " + diff --git a/.bashrc b/.bashrc new file mode 100644 index 0000000..90e2cd3 --- /dev/null +++ b/.bashrc @@ -0,0 +1,169 @@ +# ~/.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 + +# Home hostname +HOMEHOST="9h259" + +# Changes hostnname color based on the purpose of the machine +#export PRODENV="" #prod/test/not-set + +# 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 + +# Sync history after every command instead of only on shell exit +export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND" + +# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) +HISTSIZE=200000 +HISTFILESIZE=200000 + +# 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\]\$ ' + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;33m\]\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ \[\033[01;44m\]~>\[\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' +fi + +# 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 + +export QT_QPA_PLATFORMTHEME="qt5ct" +export QT_QPA_PLATFORMTHEME="qt6ct" +export SAL_USE_VCLPLUGIN=qt6 + + +#XDG settings +#export XDG_DATA_HOME="/home/chytrex/.local/share" +xdg-settings set default-web-browser firefox.desktop 2> /dev/null + +export LC_MESSAGES=C + +# Vypneme pípání v konzoli +if [ -n "$DISPLAY" ]; then + xset b off +fi + +mcd() { mkdir -p "$1" && cd "$1"; } + +set_ps1() { + if [ "$HOSTNAME" = "$HOMEHOST" ]; then + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[00m\]@\[\033[01;33m\]\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ \[\033[01;44m\]~>\[\033[00m\] ' + return + fi + + local host_color + case "$PRODENV" in + 1|true|prod|production) + host_color='\033[01;37;41m' # bold white on red = production, be careful + ;; + test|staging|stg|qa) + host_color='\033[01;36;7m' # inverted cyan = test/staging + ;; + *) + host_color='\033[33;7m' # normal inverted yellow = default/dev/unset + ;; + esac + PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\u\[\033[00m\]@\['"$host_color"'\]\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$ \[\033[01;44m\]~>\[\033[00m\] ' +} +PROMPT_COMMAND=set_ps1 + +if [ "$HOSTNAME" = "$HOMEHOST" ]; then + # Nasourcujeme termclock + . ~/.config/termclock.rc + mman() { + PID=$(xdotool getwindowpid "$(xdotool search --classname manualy | head -n1)") + SESSION=$(qdbus6 "org.kde.konsole-$PID" | grep '^/Sessions/' | head -n1) + qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.sendText $'\003' + qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.runCommand "man $1" + } + cman() { + PID=$(xdotool getwindowpid "$(xdotool search --classname manualy | head -n1)") + SESSION=$(qdbus6 "org.kde.konsole-$PID" | grep '^/Sessions/' | head -n1) + qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.sendText "q" + qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.sendText $'\003' + qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.sendText $'\014' + qdbus6 "org.kde.konsole-$PID" "$SESSION" org.kde.konsole.Session.runCommand "TERM_CLOCK_COLOR='$TERM_CLOCK_COLOR' TERM_CLOCK_SYMBOL='$TERM_CLOCK_SYMBOL' TERM_CLOCK_SELF='$TERM_CLOCK_SELF' TERM_CLOCK_NO_DAY='$TERM_CLOCK_NO_DAY' $TERM_CLOCK_CMD -g3" + } +fi + diff --git a/.profile b/.profile new file mode 100644 index 0000000..d89ea5a --- /dev/null +++ b/.profile @@ -0,0 +1,27 @@ +# ~/.profile: executed by the command interpreter for login shells. +# This file is not read by bash(1), if ~/.bash_profile or ~/.bash_login +# exists. +# see /usr/share/doc/bash/examples/startup-files for examples. +# the files are located in the bash-doc package. + +# the default umask is set in /etc/profile; for setting the umask +# for ssh logins, install and configure the libpam-umask package. +#umask 022 + +# if running bash +if [ -n "$BASH_VERSION" ]; then + # include .bashrc if it exists + if [ -f "$HOME/.bashrc" ]; then + . "$HOME/.bashrc" + fi +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/bin" ] ; then + PATH="$HOME/bin:$PATH" +fi + +# set PATH so it includes user's private bin if it exists +if [ -d "$HOME/.local/bin" ] ; then + PATH="$HOME/.local/bin:$PATH" +fi