#!/bin/sh echo -e "\e[33mhallo\e[0m" if [ "$(uname)" = FreeBSD ]; then echo free fi if [ "$(uname)" = OpenBSD ]; then echo open fi if [ "$(uname)" = NetBSD ]; then echo net fi if [ "$(uname)" = Linux ]; then echo linux fi echo echo echo creating backup files for file in ~/.bashrc ~/.vimrc ~/.bash_aliases ~/.minttyrc; do [ -f $file ] && ! [ -f $file.orig ] && echo backing up $file && mv $file $file.orig; done echo writing .bashrc hash 2>/dev/null bash && cat > ~/.bashrc << "EOF" # ~/.bashrc # Author: Toni Schranz # License: feel free to edit and redistribute case $- in *i*) ;; *) return;; esac # 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 ################################################# # options ################################################# HISTCONTROL=ignoreboth shopt -s histappend HISTSIZE=1000 HISTFILESIZE=2000 shopt -s checkwinsize shopt -s globstar [ -z "$USERNAME" ] && USERNAME=$USER ################################################# # color support ################################################# if [ -x /usr/bin/dircolors ]; then test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" fi ls --color=auto > /dev/null 2>&1 && alias ls='ls --color=auto' dir --color=auto > /dev/null 2>&1 && alias dir='dir --color=auto' vdir --color=auto > /dev/null 2>&1 && alias vdir='vdir --color=auto' echo x | grep --color=auto > /dev/null 2>&1 && alias grep='grep --color=auto' echo x | fgrep --color=auto > /dev/null 2>&1 && alias fgrep='fgrep --color=auto' echo x | egrep --color=auto > /dev/null 2>&1 && alias egrep='egrep --color=auto' export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' ################################################# # completions ################################################# 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 [[ $PS1 && -f /usr/local/share/bash-completion/bash_completion.sh ]] && \ source /usr/local/share/bash-completion/bash_completion.sh complete -cf sudo [ -f /usr/local/share/git-core/contrib/completion/git-completion.bash ] && . /usr/local/share/git-core/contrib/completion/git-completion.bash [ -f /usr/share/bash-completion/completions/git ] && . /usr/share/bash-completion/completions/git ################################################# # aliases ################################################# ! [ -f ~/.bash_aliases ] && echo writing .bash_aliases && echo " alias hash='hash 2>/dev/null' alias alias='alias 2>/dev/null' alias ll='ls -ahlF' alias la='ls -A' alias cl='clear' alias symb='for y in {0..9} {a..f}; do for i in {0..9} {a..f}; do echo -ne "U+26\$y\$i\\\\e[32m \\\\u26\$y\$i\\\\e[0m\\\\t"; done; echo; done' alias sudo='sudo ' hash git && alias ga='git add' hash git && alias gb='git branch' #hash git && alias gc='git clone' hash git && alias gd='git diff' hash git && alias gf='git fetch' hash git && alias gg='git log' hash git && alias gl='git pull' hash git && alias gm='git merge' ! hash go && hash git && alias go='git checkout' hash git && alias gco='git checkout' hash git && alias gp='git push' hash git && alias gt='git mergetool' hash git && alias gs='git status' hash git && alias gst='git stash' hash git && alias rb='git rebase' #hash git && alias mg='git merge' hash git && alias co='git commit' hash git && alias add='git add' #alias branch='git branch' #alias commit='git commit' #alias fetch='git fetch' hash git && alias pull='git pull' hash git && alias merge='git merge' hash git && alias push='git push' hash git && alias rebase='git rebase' hash dotnet && alias run='dotnet run' hash dotnet && alias build='dotnet build' hash dotnet && alias new='dotnet new' #alias db='dotnet build' #alias bd='dotnet build' hash docker && alias dcp='docker compose' alias sym='~/.symbols' hash librecad && alias cad='librecad' hash virtualbox && alias vbox='virtualbox' hash vscode && ! hash code && alias code='vscode' hash code-oss && ! hash code && alias code='code-oss' [ `id -u` -gt 0 ] || alias vscode='vscode --user-data-dir ~/.vscode_root' alias l='lynx' alias c='curl' alias v='vim -c \"vs.|vertical resize 32|wincmd w|bel term\"' alias g='grep' alias f='find . -type f -print0 | xargs -0 grep' alias n='nano' alias t='top' alias j='jobs' hash ranger && alias r='ranger' alias h='host' hash startx && alias x='startx' alias s='start' alias b='https' alias e='explorer' alias q='google' #replacements hash vim && alias vi='vim' hash htop && alias top='htop' #alias completions hash _git_add && __git_complete ga _git_add alias go && hash _git_checkout && __git_complete go _git_checkout hash _git_checkout && __git_complete gco _git_checkout hash _git_branch && __git_complete gb _git_branch hash _git_diff && __git_complete gd _git_diff hash _git_merge && __git_complete gm _git_merge hash _git_merge && __git_complete mg _git_merge hash _git_rebase && __git_complete rb _git_rebase hash _git_push && __git_complete gp _git_push #hash _git_branch && __git_complete branch _git_branch hash _git_merge && __git_complete merge _git_merge hash _git_rebase && __git_complete rebase _git_rebase hash _git_push && __git_complete push _git_push hash _git_clone && __git_complete clone _git_clone hash _git_stash && __git_complete gst _git_stash hash _git_commit && __git_complete co _git_commit unalias hash unalias alias " > ~/.bash_aliases ! hash 2>/dev/null dotnet && [ -d ~/.dotnet ] && PATH=$PATH:~/.dotnet ! hash 2>/dev/null dotnet && [ -d ~/AppData/Local/Microsoft/dotnet ] &&PATH=$PATH:~/AppData/Local/Microsoft/dotnet ! hash 2>/dev/null php && [ -d ~/.php ] && PATH=$PATH:~/.php ! hash 2>/dev/null php7 && [ -d ~/.php7 ] && PATH=$PATH:~/.php7 hash 2>/dev/null yarn && PATH="$(yarn global bin):$PATH" . ~/.bash_aliases ################################################# # prompt ################################################# alias hash='hash 2>/dev/null' [ -f /usr/local/share/git-core/contrib/completion/git-prompt.sh ] && . /usr/local/share/git-core/contrib/completion/git-prompt.sh [ -f ~/.share/git-core/contrib/git-prompt.sh ] && . ~/.share/git-core/contrib/git-prompt.sh PS1=$'\[\e[0m\]\n$(date +%T\ %Z\ %Y-%m-%d)\n' PS1+='${debian_chroot:+($debian_chroot)}' PS1+=$'\[\e[0m\][\[\e[31m\]$(echo $? | grep "[^0]")\[\e[30m\]>$(cat ~/.org 2>/dev/null)\[\e[34m\]\u' PS1+=$'\[\e[30m\]@' PS1+=$'\[\e[32m\]\h' PS1+=$'\[\e[30m\]:' PS1+=$'\[\e[33m\]\w' hash __git_ps1 && PS1+=$'\[\e[94m\]$(__git_ps1)' PS1+=$'\[\e[0m\] ]\[\e[36m\] \$' PS1+=$'\[\e[0m\] ' unalias hash 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 ################################################# # config files ################################################# if [ -f /git-bash.exe ]; then ## Windows minttyrc [ -f ~/.minttyrc ] || echo "FontHeight=14 Transparency=medium Scrollbar=none FontWeight=400 FontIsBold=no BoldAsFont=no ThemeFile=toni " > ~/.minttyrc ## Windows mintty theme [ -d ~/.mintty/ ] || mkdir ~/.mintty [ -d ~/.mintty/themes/ ] || mkdir ~/.mintty/themes [ -f ~/.mintty/themes/toni ] || echo " ForegroundColour= 236, 240, 241 BackgroundColour= 24, 24, 24 CursorColour= 211, 84, 0 BoldBlack= 52, 73, 94 Black= 44, 62, 80 BoldRed= 231, 76, 60 Red= 192, 57, 43 BoldGreen= 46, 204, 113 Green= 39, 174, 96 BoldYellow= 241, 196, 15 Yellow= 243, 156, 18 BoldBlue= 142, 68, 173 Blue= 52, 152, 219 BoldMagenta= 155, 89, 182 Magenta= 142, 68, 173 BoldCyan= 26, 188, 15 Cyan= 122, 160, 133 BoldWhite= 236, 240, 241 White= 189, 195, 199 " > ~/.mintty/themes/toni ## Windows vimrc ! [ -f ~/.vimrc ] && echo writing .vimrc && echo " syntax on colo default hi LineNr ctermfg=darkgray hi phpDocCustomTags ctermfg=white hi phpDefine ctermfg=darkblue hi Special ctermfg=cyan hi Comment ctermfg=darkgray hi netrwTreeBar ctermfg=darkgray hi PmenuSel ctermbg=yellow hi Pmenu ctermfg=darkgray hi Pmenu ctermbg=gray let g:netrw_chgwin=2 let g:netrw_banner=0 let g:netrw_liststyle=3 inoremap noremap :vs. noremap :bel term set mouse=a set number set secure set ex set wildmenu " > ~/.vimrc && echo written .vimrc fi if hash 2>/dev/null vim;then ! [ -f ~/.vimrc ] && echo writing .vimrc && echo " syntax on colo default hi LineNr ctermfg=darkgray hi phpDocCustomTags ctermfg=white hi phpDefine ctermfg=darkblue hi Special ctermfg=cyan hi Comment ctermfg=darkgray hi netrwTreeBar ctermfg=darkgray hi PmenuSel ctermbg=yellow hi Pmenu ctermfg=darkgray hi Pmenu ctermbg=gray let g:netrw_chgwin=2 let g:netrw_banner=0 let g:netrw_liststyle=3 inoremap noremap :vs. noremap :bel term inoremap noremap :bel term set mouse=a set number set secure set ex set wildmenu " > ~/.vimrc fi if hash 2>/dev/null mc;then [ -d ~/.config ] || mkdir ~/.config [ -d ~/.config/mc ] || mkdir ~/.config/mc [ -f ~/.config/mc/ini ] || echo '[Midnight-Commander] skin=nicedark use_internal_edit=false ' > ~/.config/mc/ini fi ################################################# # shell functions ################################################# alias hash='hash 2>/dev/null' ! hash start && hash xdg-open && function start () { xdg-open $*; } ! hash start && hash open && function start () { open $*; } ! hash explorer && hash nautilus && function explorer () { nautilus $*; } hash start && function https () { start "https://$*"; } hash https && function google () { https "google.com/?q=$*"; } hash git && function clone () { git clone https://github.com/$*; } [ `id -u` -gt 0 ] || function xi () { pkg=$4; [ -z "$pkg" ] && pkg=$3; hash $3 || ! hash $1 || alias $3="echo installing $pkg with $1 && $1 $2 $pkg && unalias $3; $3"; } [ `id -u` -gt 0 ] && function xi () { pkg=$4; [ -z "$pkg" ] && pkg=$3; hash $3 || ! hash $1 || ! hash sudo || alias $3="echo installing $pkg with $1 && sudo $1 $2 $pkg && unalias $3; $3"; } function aai () { xi apk "add" $*; } function ai () { xi apt "install -y" $*; } function si () { xi snap install $*; } function pkgi () { xi pkg "install -y" $*; } function updateall () { mv -f ~/.bashrc ~/.bashrc.old rm -f ~/.vimrc ~/.bash_aliases ~/.minttyrc curl https://tsd.wtf | sh [ -f ~/.bashrc ] || mv -f ~/.bashrc.old ~/.bashrc rm -f ~/.bashrc.old } function leave () { for file in ~/.bashrc ~/.vimrc ~/.bash_aliases ~/.minttyrc; do echo removing $file && rm -f $file [ -f $file.orig ] && echo restoring $file && mv $file.orig $file done } ################################################# # tools ################################################# aai curl aai git aai vim aai php php82 aai npm aai ranger aai mc aai htop aai elinks si docker ai curl ai git ai vim ai php ai npm ai mc ai htop ai make ai gcc ai gnome-tweaks ai elinks xi apt "install -y" snap "squashfuse fuse snapd" xi apt "install -y" docker docker.io pkgi curl pkgi git pkgi vim pkgi php php82 pkgi npm pkgi mc pkgi htop pkgi elinks if [ -f /git-bash.exe ]; then hash php || alias php='curl https://windows.php.net/downloads/releases/latest/php-8.2-nts-Win32-vs16-x64-latest.zip -o ~/.php.zip && unzip ~/.php.zip -d ~/.php && rm ~/.php.zip && curl https://xdebug.org/files/php_xdebug-3.2.0-8.2-vs16-nts-x86_64.dll -o ~/.php/ext/php_xdebug.dll && echo "[PHP] extension_dir=\"ext\" extension=openssl zend_extension=xdebug" > .php/php.ini && unalias php && PATH=$PATH:~/.php && php' hash php7 || alias php7='curl https://windows.php.net/downloads/releases/latest/php-7.4-nts-Win32-vc15-x64-latest.zip -o ~/.php7.zip && unzip ~/.php7.zip -d ~/.php7 && rm ~/.php7.zip && mv ~/.php7/php.exe ~/.php7/php7.exe && curl https://xdebug.org/files/php_xdebug-3.1.5-7.4-vc15-nts-x86_64.dll -o ~/.php7/ext/php_xdebug.dll && echo "[PHP] extension_dir=\"ext\" extension=openssl zend_extension=xdebug" > .php7/php.ini && unalias php7 && PATH=$PATH:~/.php7 && php7' hash dotnet || alias dotnet='curl https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.ps1 | powershell && unalias dotnet && PATH=$PATH:~/AppData/Local/Microsoft/dotnet && dotnet' elif hash curl; then hash dotnet || alias dotnet='curl https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh | bash && unalias dotnet && PATH=$PATH:~/.dotnet && dotnet' fi ################################################# # utilities ################################################# #hash g213-led || ! hash apt || ! hash sudo || (echo Installing g810-led for Logitech G213 Prodigy Keyboard && sudo apt install -y g810-led --no-install-recommends) hash g213-led && g213-led --list-keyboards >/dev/null && g213-led -r 1 000088 && g213-led -r 2 008800 && g213-led -r 3 888800 && g213-led -r 4 008888 && g213-led -r 5 888888 #hash g213-led && g213-led --list-keyboards >/dev/null && g213-led -r 1 0000ff && g213-led -r 2 00ff00 && g213-led -r 3 ffff00 && g213-led -r 4 00ffff && g213-led -r 5 ffffff si code si gimp si inkscape si chromium if hash dpkg && hash apt && hash curl && hash sudo; then hash code || alias code='curl -L "https://code.visualstudio.com/sha/download?build=stable&os=linux-deb-`dpkg --print-architecture`" -o code.deb && sudo apt install -y ./code.deb && rm code.deb && unalias code && code' fi ai firefox ai gimp ai inkscape ai librecad ai lbreoffice-calc ai g213-led g810-led ai fontforge ai startx "xinit i3 xserver-xorg fonts-dejavu ttf-font-awesome ttf-ancient-fonts fonts-cns11643" aai feh aai firefox aai gimp aai inkscape aai librecad aai lbreoffice-calc aai fontforge aai chromium-browser xi setup-xorg-base i3wm startx "ttf-dejavu ttf-font-awesome xf86-video-fbdev rxvt-unicode" pkgi vscode pkgi chrome chromium pkgi feh pkgi firefox pkgi gimp pkgi inkscape pkgi librecad pkgi lbreoffice-calc pkgi bhyve pkgi fontforge pkgi pitivi pkgi openshot pkgi shotcut pkgi vid.stab pkgi startx "xorg-minimal i3 dmenu i3status i3lock rxvt-unicode feh firefox dejavu symbola zh-CNS11643-font junicode" unalias hash unset -f ai si pkgi aai xi ################################################# # end ################################################# [ "`pwd`" == '/' ] && cd echo EOF echo tja.;