Initial commit
This commit is contained in:
commit
225efae78b
166
bashrc
Normal file
166
bashrc
Normal file
@ -0,0 +1,166 @@
|
||||
# ~/.bashrc
|
||||
# byMasterKTO
|
||||
|
||||
# NOTE if .bashrc is not sourced at login, add `source ~/.bashrc` to ~/.profile
|
||||
|
||||
# If not running interactively, don't do anything
|
||||
[[ $- != *i* ]] && return
|
||||
|
||||
# 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=1000
|
||||
HISTFILESIZE=2000
|
||||
|
||||
# check the window size after each command and, if necessary,
|
||||
# update the values of LINES and COLUMNS.
|
||||
shopt -s checkwinsize
|
||||
|
||||
# make less more friendly for non-text input files, see lesspipe(1)
|
||||
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
|
||||
|
||||
########################################################################################################################
|
||||
# set custom prompt
|
||||
# for upgrade, we should look at https://wiki.archlinux.org/index.php/Bash/Prompt_customization#Terminfo_escape_sequences
|
||||
|
||||
system=$(uname)
|
||||
|
||||
# colors and custom
|
||||
C_BOLD="\[$(tput bold)\]"
|
||||
C_RESET="\[$(tput sgr0)\]"
|
||||
if [[ $system == "Linux" ]]; then
|
||||
C_USER="\[$(tput setaf 19)\]"
|
||||
C_ROOT="\[$(tput setab 1)\]"
|
||||
C_ARCH="\[$(tput setaf 32)\]"
|
||||
C_DEB="\[$(tput setaf 166)\]"
|
||||
C_RH="\[$(tput setaf 21)\]"
|
||||
C_SUSE="\[$(tput setaf 40)\]"
|
||||
elif [[ $system == "OpenBSD" ]]; then
|
||||
C_USER="\[$(tput setaf 19 19 19)\]"
|
||||
C_ROOT="\[$(tput setab 1 1 1)\]"
|
||||
C_OBSD="\[$(tput setaf 11 11 11)\]"
|
||||
fi
|
||||
|
||||
# user
|
||||
if [[ $(whoami) == 'root' ]]; then
|
||||
user="$C_BOLD$C_ROOT\u$C_RESET"
|
||||
else
|
||||
user="$C_BOLD$C_USER\u$C_RESET"
|
||||
fi
|
||||
|
||||
# distro
|
||||
if [[ $system == "Linux" ]]; then
|
||||
case $(lsb_release -si) in
|
||||
# Arch family: light blue
|
||||
Arch | ManjaroLinux) COLOR=$C_BOLD$C_ARCH;;
|
||||
# Debian family: orange
|
||||
Debian | Ubuntu | Linuxmint | Neon | Raspbian) COLOR=$C_BOLD$C_DEB;;
|
||||
# RedHat family: blue
|
||||
Fedora) COLOR=$C_BOLD$C_RH;;
|
||||
# SUSE family: green
|
||||
openSUSE) COLOR=$C_BOLD$C_SUSE;;
|
||||
# Other: white
|
||||
*) COLOR=$C_BOLD;;
|
||||
esac
|
||||
elif [[ $system == "OpenBSD" ]]; then
|
||||
# OpenBSD: yellow
|
||||
COLOR=$C_BOLD$C_OBSD
|
||||
BSD="$C_BOLD(BSD) $C_RESET"
|
||||
fi
|
||||
|
||||
# virtualization
|
||||
if [[ $system == "Linux" ]]; then
|
||||
type systemd-detect-virt > /dev/null 2>&1
|
||||
if [[ $? -eq 0 ]]; then
|
||||
systemd-detect-virt --quiet -v
|
||||
if [ $? -eq 0 ]; then
|
||||
virt='/V'
|
||||
fi
|
||||
systemd-detect-virt --quiet -c
|
||||
if [ $? -eq 0 ]; then
|
||||
virt='/C'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# hostname
|
||||
# if hostname has 4 parts then host=.secondpart
|
||||
if [[ $(hostname | grep -o "\." | wc -l) -eq 3 ]]; then
|
||||
host='.'$(hostname | cut -f 2 -d '.')
|
||||
fi
|
||||
hn="$COLOR\h$host$virt$C_RESET"
|
||||
|
||||
# current directory
|
||||
cur_dir="$C_BOLD\W$C_RESET"
|
||||
|
||||
# set result
|
||||
PS1=$C_RESET$BSD$user' '$hn' '$cur_dir' \$ '
|
||||
########################################################################################################################
|
||||
|
||||
# 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
|
||||
|
||||
# some more aliases
|
||||
if [[ $system == "Linux" ]]; then
|
||||
alias ll='ls -lhX'
|
||||
alias la='ls -lahX'
|
||||
alias dh='df -h'
|
||||
elif [[ $system == "OpenBSD" ]]; then
|
||||
alias ll='ls -lh'
|
||||
alias la='ls -lah'
|
||||
alias dh='df -h'
|
||||
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
|
||||
|
||||
# useful exports
|
||||
export EDITOR=vim
|
||||
export GPG_TTY=$(tty)
|
||||
|
||||
# unsetting $TMUX enables sessions nesting
|
||||
unset TMUX
|
||||
|
||||
# Saving touchpad (hp8)
|
||||
alias touchpad='xinput set-prop 12 "Device Enabled" 1'
|
||||
|
||||
# Set VNC aliases
|
||||
X_user=$(who | grep \(: | cut -d " " -f1)
|
||||
X_display=$(who | grep \(: | cut -d ":" -f2 | cut -b 1)
|
||||
if id -u gdm > /dev/null 2>&1; then
|
||||
X_gdm_id=$(id -u gdm)
|
||||
elif id -u Debian-gdm > /dev/null 2>&1; then
|
||||
X_gdm_id=$(id -u Debian-gdm)
|
||||
fi
|
||||
alias vnc-mine='x11vnc -localhost -once -nopw -display :0'
|
||||
alias vnc-desktop="sudo -H -u $X_user x11vnc -localhost -once -nopw -display :0"
|
||||
alias vnc-gnome="sudo -H -u $X_user x11vnc -localhost -once -nopw -display :$X_display"
|
||||
alias vnc-sddm='sudo x11vnc -auth /var/run/sddm/* -localhost -once -nopw -display :0'
|
||||
alias vnc-gdm="sudo x11vnc -auth /run/user/$X_gdm_id/gdm/Xauthority -localhost -once -nopw -display :0"
|
||||
alias vnc-lightdm='sudo x11vnc -auth /var/run/lightdm/root/:0 -localhost -once -nopw -display :0'
|
||||
|
||||
# load any additional configuration
|
||||
for f in ~/.bashrc-*; do
|
||||
[ -e "$f" ] && . ~/.bashrc-*
|
||||
break
|
||||
done
|
77
vimrc
Normal file
77
vimrc
Normal file
@ -0,0 +1,77 @@
|
||||
" ~/.vimrc
|
||||
" byMasterKTO
|
||||
|
||||
" Credits: DougBlack's blog post: https://dougblack.io/words/a-good-vimrc.html
|
||||
|
||||
" Indentation
|
||||
|
||||
" Use space characters (soft tabs)
|
||||
set expandtab
|
||||
" Set '1 tab press inserts 2 spaces'
|
||||
set softtabstop=2
|
||||
set shiftwidth=2
|
||||
" If hard tabs are present, set their width to 8 characters (I want to see them)
|
||||
set tabstop=8
|
||||
|
||||
" UI
|
||||
|
||||
" syntax highlighting
|
||||
syntax on
|
||||
|
||||
" lines number
|
||||
set number
|
||||
|
||||
" load filetype-specific indent files
|
||||
" apparently, they're supposed to be at ~/.vim/indent/<lang>.vim
|
||||
filetype indent on
|
||||
|
||||
" visual autocomplete for command menu
|
||||
set wildmenu
|
||||
|
||||
" redraw only when nedded
|
||||
set lazyredraw
|
||||
|
||||
" search as characters are entered
|
||||
set incsearch
|
||||
|
||||
" allow cursor change in tmux mode
|
||||
if exists('$TMUX')
|
||||
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
|
||||
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
|
||||
else
|
||||
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
|
||||
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
|
||||
endif
|
||||
|
||||
" Specific configurations
|
||||
|
||||
augroup configgroup
|
||||
autocmd!
|
||||
|
||||
" remove trailing whitespaces on every files at saving
|
||||
autocmd BufWritePre * %s/\s\+$//e
|
||||
|
||||
" Makefiles specifics
|
||||
autocmd BufEnter Makefile setlocal noexpandtab
|
||||
|
||||
"Python specifics
|
||||
autocmd BufEnter *.py setlocal filetype=python
|
||||
|
||||
" Javascript specifics
|
||||
autocmd BufEnter *.js setlocal filetype=javascript
|
||||
autocmd FileType javascript setlocal softtabstop=2
|
||||
autocmd FileType javascript setlocal shiftwidth=2
|
||||
|
||||
" Markdown specifics
|
||||
autocmd BufEnter *.md setlocal filetype=markdown
|
||||
autocmd FileType markdown setlocal softtabstop=2
|
||||
autocmd FileType markdown setlocal shiftwidth=2
|
||||
augroup END
|
||||
|
||||
|
||||
" Notes
|
||||
|
||||
" spellchecking
|
||||
" Vim seems to be able to use dictionnaries
|
||||
" We can use `:setlocal spell spelllang=en_GB` and `:setlocal nospell`
|
||||
|
Loading…
Reference in New Issue
Block a user