first commit
This commit is contained in:
47
shell/.bash_aliases
Normal file
47
shell/.bash_aliases
Normal file
@@ -0,0 +1,47 @@
|
||||
# enable color support of ls and other commands
|
||||
if [ -x /usr/bin/dircolors ]; then
|
||||
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||
alias ls='ls --color=auto -F'
|
||||
#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 ls aliases
|
||||
alias ll='ls -lah'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
# better less
|
||||
alias less="less -R "
|
||||
|
||||
alias php="php -c ~/workspace/php.ini"
|
||||
alias ..="cd .."
|
||||
|
||||
# Alternative system beep for (not only) when the system has no internal beep
|
||||
export BEEP=/usr/share/sounds/freedesktop/stereo/bell.oga
|
||||
alias beep='paplay $BEEP --volume=32768'
|
||||
|
||||
alias vi=$(which vim)
|
||||
|
||||
### Extra aliases added after default:
|
||||
|
||||
# Cheat code indent
|
||||
stylefix ()
|
||||
{
|
||||
for file in $@
|
||||
do
|
||||
indent -linux -l80 -nbad -bap -bc -bbo -bl -bli0 -bls -ncdb -nce -cp1 -c33 -cs -di2 -ndj -nfc1 -nfca -hnl -i8 -ip5 -lp -pcs -psl -nsc -nsob -nut "$PWD/$file"
|
||||
rm "$PWD/$file~"
|
||||
done
|
||||
}
|
||||
alias stylefix=stylefix;
|
||||
alias pkgin='sudo aptitude install'
|
||||
alias pkgrm='sudo aptitude remove'
|
||||
alias wttr='curl http://wttr.in/Porto,Portugal'
|
||||
7
shell/.bash_logout
Normal file
7
shell/.bash_logout
Normal file
@@ -0,0 +1,7 @@
|
||||
# ~/.bash_logout: executed by bash(1) when login shell exits.
|
||||
|
||||
# when leaving the console clear the screen to increase privacy
|
||||
|
||||
if [ "$SHLVL" = 1 ]; then
|
||||
[ -x /usr/bin/clear_console ] && /usr/bin/clear_console -q
|
||||
fi
|
||||
4
shell/.bash_profile
Normal file
4
shell/.bash_profile
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
# It looks like this is a login shell, load .profile
|
||||
[ -f "$HOME/.profile" ] && source "$HOME/.profile"
|
||||
157
shell/.bashrc
Normal file
157
shell/.bashrc
Normal file
@@ -0,0 +1,157 @@
|
||||
# There are 3 different types of shells in bash: the login shell, normal shell
|
||||
# and interactive shell. Login shells read ~/.profile and interactive shells
|
||||
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
|
||||
# settings made here will also take effect in a login shell.
|
||||
#
|
||||
# NOTE: It is recommended to make language settings in ~/.profile rather than
|
||||
# here, since multilingual X sessions would not work properly if LANG is over-
|
||||
# ridden in every subshell.
|
||||
|
||||
# Some applications read the EDITOR variable to determine your favourite text
|
||||
# editor.
|
||||
export EDITOR=$(which nvim)
|
||||
|
||||
# set PATH so it includes user's private bin if it exists (as in GUI this will
|
||||
# not be an interactive login shell)
|
||||
if [ -d "$HOME/.local/bin" ]
|
||||
then
|
||||
PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
# For some news readers it makes sense to specify the NEWSSERVER variable here
|
||||
#export NEWSSERVER=your.news.server
|
||||
|
||||
# If you want to use a Palm device with Linux, uncomment the two lines below.
|
||||
# For some (older) Palm Pilots, you might need to set a lower baud rate
|
||||
# e.g. 57600 or 38400; lowest is 9600 (very slow!)
|
||||
#
|
||||
#export PILOTPORT=/dev/pilot
|
||||
#export PILOTRATE=115200
|
||||
|
||||
# ~/.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
|
||||
|
||||
#[ -z "$PS1" ] && 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
|
||||
|
||||
# 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
|
||||
|
||||
# Make CTRL+S work
|
||||
stty -ixon
|
||||
|
||||
# Workspace is the most frequent directory where I wanna be
|
||||
alias cd="HOME=~/workspace cd"
|
||||
|
||||
cwdSlashAtEnd () {
|
||||
TITLE="$(dirs +0)"
|
||||
|
||||
if [ -z "$1" ] ; then
|
||||
# no argument, full cwd
|
||||
TITLE="${TITLE%/}"
|
||||
else
|
||||
# one arg, basename only
|
||||
TITLE="${TITLE##*/}"
|
||||
fi
|
||||
|
||||
echo -n "${TITLE}/"
|
||||
}
|
||||
|
||||
if [ "$color_prompt" = yes ]; then
|
||||
#PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[$(printf "\x0f")\033[01;34m\]$(cwdSlashAtEnd)\[\033[00m\]$(__git_ps1 " (%s)")$ '
|
||||
PS1='\[$(printf "\x0f")\033[01;34m\]$(cwdSlashAtEnd)\[\033[00m\]$(__git_ps1 " (%s)")$ '
|
||||
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*|screen*)
|
||||
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
|
||||
# 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 PATH=$HOME/.cabal/bin:$PATH
|
||||
|
||||
# VIM is my default text editor
|
||||
export EDITOR=$(which nvim)
|
||||
|
||||
# {{START_NEOVIM_STUDIO_TOKEN}}
|
||||
if [ -z "${NEOVIM_STUDIO_PROFILE_SOURCED}" ] && [ -e "/home/xellos/.neovim-studio/neovim_studio_profile" ]; then
|
||||
source "/home/xellos/.neovim-studio/neovim_studio_profile"
|
||||
fi
|
||||
# {{END_NEOVIM_STUDIO_TOKEN}}
|
||||
|
||||
403
shell/.basic.zshrc
Normal file
403
shell/.basic.zshrc
Normal file
@@ -0,0 +1,403 @@
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
# Completion for kitty
|
||||
#kitty + complete setup zsh | source /dev/stdin
|
||||
#
|
||||
# .zshrc is sourced in interactive shells.
|
||||
# It should contain commands to set up aliases,
|
||||
# functions, options, key bindings, etc.
|
||||
#
|
||||
# Not all terminals support this and, of those that do,
|
||||
# not all provide facilities to test the support, hence
|
||||
# the user should decide based on the terminal type. Most
|
||||
# terminals support the colours black, red, green,
|
||||
# yellow, blue, magenta, cyan and white, which can be set
|
||||
# by name. In addition. default may be used to set the
|
||||
# terminal's default foreground colour. Abbreviations
|
||||
# are allowed; b or bl selects black.
|
||||
#
|
||||
HISTFILE=~/.histfile
|
||||
HISTSIZE=1000
|
||||
SAVEHIST=1000
|
||||
WORDCHARS="${WORDCHARS:s#/#}"
|
||||
WORDCHARS="${WORDCHARS:s#.#}"
|
||||
export EDITOR=$(which nvim)
|
||||
##############################################################
|
||||
#key binding stuff to get the right keys to work
|
||||
# key bindings
|
||||
bindkey "\e[1~" beginning-of-line
|
||||
bindkey "\e[4~" end-of-line
|
||||
bindkey "\e[5~" beginning-of-history
|
||||
bindkey "\e[6~" end-of-history
|
||||
bindkey "\e[3~" delete-char
|
||||
bindkey "\e[2~" overwrite-mode
|
||||
bindkey "\e[5C" forward-word
|
||||
bindkey "\eOc" emacs-forward-word
|
||||
bindkey "\e[5D" backward-word
|
||||
bindkey "\eOd" emacs-backward-word
|
||||
bindkey "\ee[C" forward-word
|
||||
bindkey "\ee[D" backward-word
|
||||
#Ctrl-left/right
|
||||
bindkey '\e[1;5C' forward-word # ctrl right
|
||||
bindkey '\e[1;5D' backward-word # ctrl left o
|
||||
#alt-left/right
|
||||
bindkey "\e[1;3C" forward-word
|
||||
bindkey "\e[1;3D" backward-word
|
||||
#bindkey "^H" backward-delete-word
|
||||
# for rxvt
|
||||
bindkey "\e[8~" end-of-line
|
||||
bindkey "\e[7~" beginning-of-line
|
||||
# for non RH/Debian xterm, cant hurt for RH/Debian xterm
|
||||
bindkey "\eOH" beginning-of-line
|
||||
bindkey "\eOF" end-of-line
|
||||
# for freebsd console
|
||||
bindkey "\e[H" beginning-of-line
|
||||
bindkey "\e[F" end-of-line
|
||||
# completion in the middle of a line
|
||||
bindkey '^i' expand-or-complete-prefix
|
||||
|
||||
setopt appendhistory autocd nobeep extendedglob nomatch notify
|
||||
setopt autolist auto_menu
|
||||
bindkey -e
|
||||
# End of lines configured by zsh-newuser-install
|
||||
# The following lines were added by compinstall
|
||||
zstyle :compinstall filename '/home/mwoodson/.zshrc'
|
||||
|
||||
autoload -Uz compinit
|
||||
compinit
|
||||
# End of lines added by compinstall
|
||||
## completion system
|
||||
_force_rehash() {
|
||||
(( CURRENT == 1 )) && rehash
|
||||
return 1 # Because we didn't really complete anything
|
||||
}
|
||||
|
||||
zstyle ':completion:*' completer _oldlist _expand _force_rehash _complete _approximate
|
||||
zstyle ':completion:*:approximate:' max-errors 'reply=( $((($#PREFIX+$#SUFFIX)/3 )) numeric )' # allow one error for every three characters typed in approximate completer
|
||||
zstyle ':completion:*:complete:-command-::commands' ignored-patterns '*\~' # don't complete backup files as executables
|
||||
zstyle ':completion:*:correct:*' insert-unambiguous true # start menu completion only if it could find no unambiguous initial string
|
||||
zstyle ':completion:*:corrections' format $'%{\e[0;31m%}%d (errors: %e)%{\e[0m%}' #
|
||||
zstyle ':completion:*:correct:*' original true #
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} # activate color-completion(!)
|
||||
zstyle ':completion:*:descriptions' format $'%{\e[0;31m%}completing %B%d%b%{\e[0m%}' # format on completion
|
||||
zstyle ':completion:*:*:cd:*:directory-stack' menu yes select # complete 'cd -<tab>' with menu
|
||||
#zstyle ':completion:*:expand:*' tag-order all-expansions # insert all expansions for expand completer
|
||||
zstyle ':completion:*:history-words' list false #
|
||||
zstyle ':completion:*:history-words' menu yes # activate menu
|
||||
zstyle ':completion:*:history-words' remove-all-dups yes # ignore duplicate entries
|
||||
zstyle ':completion:*:history-words' stop yes #
|
||||
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}' # match uppercase from lowercase
|
||||
zstyle ':completion:*:matches' group 'yes' # separate matches into groups
|
||||
zstyle ':completion:*' group-name ''
|
||||
zstyle ':completion:*:messages' format '%d' #
|
||||
zstyle ':completion:*:options' auto-description '%d' #
|
||||
zstyle ':completion:*:options' description 'yes' # describe options in full
|
||||
zstyle ':completion:*:processes' command 'ps -au$USER' # on processes completion complete all user processes
|
||||
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters # offer indexes before parameters in subscripts
|
||||
zstyle ':completion:*' verbose true # provide verbose completion information
|
||||
zstyle ':completion:*:warnings' format $'%{\e[0;31m%}No matches for:%{\e[0m%} %d' # set format for warnings
|
||||
zstyle ':completion:*:*:zcompile:*' ignored-patterns '(*~|*.zwc)' # define files to ignore for zcompile
|
||||
zstyle ':completion:correct:' prompt 'correct to: %e' #
|
||||
zstyle ':completion::(^approximate*):*:functions' ignored-patterns '_*' # Ignore completion functions for commands you don't have:
|
||||
|
||||
# complete manual by their section
|
||||
zstyle ':completion:*:manuals' separate-sections true
|
||||
zstyle ':completion:*:manuals.*' insert-sections true
|
||||
zstyle ':completion:*:man:*' menu yes select
|
||||
|
||||
|
||||
|
||||
# Completion caching
|
||||
zstyle ':completion::complete:*' use-cache on
|
||||
zstyle ':completion::complete:*' cache-path .zcache
|
||||
zstyle ':completion:*:cd:*' ignore-parents parent pwd
|
||||
|
||||
zstyle ':completion::complete:cd::' tag-order local-directories
|
||||
zstyle ':completion:*' menu select=2
|
||||
zstyle ':completion:*' squeeze-slashes true
|
||||
zstyle ':completion:*:*:kill:*' menu yes select
|
||||
zstyle ':completion:*:kill:*' force-list always
|
||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||
|
||||
CDPATH=.:~:~/git
|
||||
|
||||
#I want my umask 0002 if I'm not root
|
||||
if [[ $(whoami) = root ]]; then
|
||||
umask 0022
|
||||
else
|
||||
umask 0002
|
||||
fi
|
||||
|
||||
|
||||
|
||||
#setup ~/.dir_colors if one doesn\'t exist
|
||||
if [ ! -s ~/.dir_colors ]; then
|
||||
dircolors -p > ~/.dir_colors
|
||||
fi
|
||||
eval `dircolors ~/.dir_colors`
|
||||
|
||||
#aliases
|
||||
alias ls='ls --color=auto'
|
||||
alias dir='dir --color=auto'
|
||||
alias vdir='vdir --color=auto'
|
||||
alias grep='grep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias fgrep='fgrep --color=auto'
|
||||
alias egrep='egrep --color=auto'
|
||||
alias vi=$(which vim)
|
||||
alias -- -='cd -'
|
||||
alias ...='../..'
|
||||
alias ....='../../..'
|
||||
alias .....='../../../..'
|
||||
alias ll='ls -lah'
|
||||
#alias sl='ls -lah'
|
||||
#alias l='ls -la'
|
||||
alias -g X='| xargs'
|
||||
alias -g G='| egrep'
|
||||
|
||||
show-colors() {
|
||||
for line in {0..17}; do
|
||||
for col in {0..15}; do
|
||||
code=$(( $col * 18 + $line ));
|
||||
printf $'\e[38;05;%dm %03d' $code $code;
|
||||
done;
|
||||
echo;
|
||||
done
|
||||
}
|
||||
|
||||
#allow tab completion in the middle of a word
|
||||
setopt COMPLETE_IN_WORD
|
||||
setopt CORRECT
|
||||
|
||||
## keep background processes at full speed
|
||||
#setopt NOBGNICE
|
||||
## restart running processes on exit
|
||||
#setopt HUP
|
||||
|
||||
## history
|
||||
#setopt APPEND_HISTORY
|
||||
## for sharing history between zsh processes
|
||||
setopt INC_APPEND_HISTORY
|
||||
setopt SHARE_HISTORY
|
||||
|
||||
setopt nonomatch # do not print error on non matched patterns
|
||||
## automatically decide when to page a list of completions
|
||||
#LISTMAX=0
|
||||
|
||||
## disable mail checking
|
||||
#MAILCHECK=0
|
||||
|
||||
autoload -U colors && colors
|
||||
# set some colors
|
||||
for COLOR in RED GREEN YELLOW WHITE BLACK CYAN BLUE PURPLE; do
|
||||
eval PR_$COLOR='%{$fg[${(L)COLOR}]%}'
|
||||
eval PR_BRIGHT_$COLOR='%{$fg_bold[${(L)COLOR}]%}'
|
||||
done
|
||||
PR_RESET="%{${reset_color}%}";
|
||||
|
||||
setopt prompt_subst
|
||||
|
||||
autoload -Uz vcs_info
|
||||
|
||||
zstyle ':vcs_info:*' enable git cvs svn
|
||||
# set formats
|
||||
# %b - branchname
|
||||
# %u - unstagedstr (see below)
|
||||
# %c - stangedstr (see below)
|
||||
# %a - action (e.g. rebase-i)
|
||||
# %R - repository path
|
||||
# %S - path in the repository
|
||||
## check-for-changes can be really slow.
|
||||
## you should disable it, if you work with large repositories
|
||||
zstyle ':vcs_info:*:prompt:*' check-for-changes true # slower, but lets us show changes to working/index
|
||||
zstyle ':vcs_info:*:prompt:*' unstagedstr "${PR_BRIGHT_YELLOW}*${PR_RESET}" # unstaged changes string: red *
|
||||
zstyle ':vcs_info:*:prompt:*' stagedstr "${PR_BRIGHT_YELLOW}+${PR_RESET}" # staged changes string: yellow +
|
||||
zstyle ':vcs_info:*:prompt:*' formats " ${PR_GREEN}%s${PR_RESET}:${PR_BRIGHT_RED}(%b${PR_RESET}%c%u${PR_BRIGHT_RED})${PR_RESET}" "%a"
|
||||
zstyle ':vcs_info:*:prompt:*' actionformats " ${PR_GREEN}%s${PR_RESET}:${PR_BRIGHT_RED}(%b|%a)${PR_RESET}" "%a"
|
||||
zstyle ':vcs_info:*:prompt:*' nvcsformats "" "%~"
|
||||
zstyle ':vcs_info:*:prompt:*' branchformat "%b:%r" ""
|
||||
|
||||
BLUE_DIAMOND="%B%F{blue}◆%f%b"
|
||||
YELLOW_DIAMOND="%B%F{yellow}◆%f%b"
|
||||
GREEN_DIAMOND="%B%F{green}◆%f%b"
|
||||
RED_DIAMOND="%B%F{red}◆%f%b"
|
||||
RED_RARROW="%B%F{red}▶%f%b"
|
||||
RED_LARROW="%B%F{red}◀%f%b"
|
||||
RED_STAR="%B%F{red}✱%b%f"
|
||||
|
||||
case $TERM in
|
||||
*xterm*|rxvt|(dt|k|E)term)
|
||||
preexec () {
|
||||
if [[ $(basename ${1[(w)1]}) == "ssh" ]]; then
|
||||
SHN=${1[(w)-1]}
|
||||
SHN_ARRAY=( ${(s,.,)SHN})
|
||||
print -Pn "\e]2;$SHN:%~\a"
|
||||
else
|
||||
print -Pn "\e]2;%n@%m:%~\a"
|
||||
fi
|
||||
}
|
||||
;;
|
||||
screen)
|
||||
preexec () {
|
||||
if [[ $(basename ${1[(w)1]}) == "ssh" ]]; then
|
||||
SHN=${1[(w)-1]}
|
||||
SHN=${SHN#*@}
|
||||
SHN_ARRAY=( ${(s,.,)SHN})
|
||||
case ${#SHN_ARRAY} in
|
||||
2)
|
||||
print -Pn "\033k$SHN\033\\"
|
||||
;;
|
||||
4)
|
||||
print -Pn "\033k$SHN_ARRAY[1].$SHN_ARRAY[2]\033\\"
|
||||
;;
|
||||
5)
|
||||
#print -Pn "\033k$SHN_ARRAY[1].$SHN_ARRAY[2].$SHN_ARRAY[3]\033\\"
|
||||
print -Pn "\033k$SHN_ARRAY[1].$SHN_ARRAY[3]\033\\"
|
||||
;;
|
||||
*)
|
||||
print -Pn "\033k$SHN_ARRAY[1]\033\\"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
#set up precmd to draw the screen title
|
||||
function set_screen_title {
|
||||
print -Pn "\033k%m\033\\"
|
||||
}
|
||||
precmd_functions=( set_screen_title )
|
||||
;;
|
||||
}
|
||||
|
||||
if [[ -n $SSH_CONNECTION ]]; then
|
||||
SSH_IP=$(echo $SSH_CLIENT | awk '{print $1}')
|
||||
HOST_OUTPUT=$(host $SSH_IP)
|
||||
if [[ $? -eq 0 ]]; then
|
||||
SSH_HOST=$(echo $HOST_OUTPUT | awk '{print $NF}' | sed 's/.$//')
|
||||
else
|
||||
SSH_HOST=$SSH_IP
|
||||
fi
|
||||
SSH_PROMPT="${RED_STAR}%F{yellow}SSH from: %f%B%F{green}$SSH_HOST%f%b${RED_STAR}"
|
||||
#SSH_PROMPT="${YELLOW_DIAMOND}${PR_BRIGHT_RED}SSH${PR_RESET}${YELLOW_DIAMOND}"
|
||||
#SSH_VAR="${YELLOW_DIAMOND}${PR_BRIGHT_RED}SSH${PR_RESET}${YELLOW_DIAMOND}"
|
||||
|
||||
fi
|
||||
|
||||
HASH_NUM=$(echo $HOSTNAME | md5sum | tr -d 'a-f' | cut -b 1-6)
|
||||
HASH_MOD=$(($HASH_NUM % 6 + 2))
|
||||
if [[ $(whoami) = root ]]; then
|
||||
PROMPT_LINE="%B%F{red}%n@%M%f%b"
|
||||
else
|
||||
PROMPT_LINE="%F{green}%n%f@%B%F{$HASH_MOD}%m%b%f"
|
||||
fi
|
||||
|
||||
precmd(){
|
||||
|
||||
local exit_status=$?
|
||||
|
||||
vcs_info 'prompt'
|
||||
|
||||
# Battery Stuff
|
||||
if which ibam &> /dev/null; then
|
||||
IBAMSTAT="$(ibam)"
|
||||
if [[ ${IBAMSTAT[(f)(1)][(w)1]} = "Battery" ]]; then
|
||||
BATTSTATE="$(ibam --percentbattery)"
|
||||
BATTPRCNT="${BATTSTATE[(f)1][(w)-2]}"
|
||||
BATTTIME="${BATTSTATE[(f)2][(w)-1]}"
|
||||
PR_BATTERY="Bat: ${BATTPRCNT}%% (${BATTTIME})"
|
||||
if [[ "${BATTPRCNT}" -lt 15 ]]; then
|
||||
PR_BATTERY=" ${BLUE_DIAMOND} ${PR_BRIGHT_RED}${PR_BATTERY}"
|
||||
elif [[ "${BATTPRCNT}" -lt 50 ]]; then
|
||||
PR_BATTERY=" ${BLUE_DIAMOND} ${PR_BRIGHT_YELLOW}${PR_BATTERY}"
|
||||
elif [[ "${BATTPRCNT}" -lt 100 ]]; then
|
||||
PR_BATTERY=" ${BLUE_DIAMOND} ${PR_BRIGHT_CYAN}${PR_BATTERY}${PR_RESET}"
|
||||
else
|
||||
PR_BATTERY=""
|
||||
fi
|
||||
else
|
||||
PR_BATTERY=""
|
||||
fi
|
||||
fi
|
||||
###End of Battery Stuff######
|
||||
|
||||
# now lets change the color of the path if its not writable
|
||||
if [[ -w $PWD ]]; then
|
||||
PR_PWDCOLOR="%F{yellow}"
|
||||
else
|
||||
PR_PWDCOLOR="${PR_BRIGHT_RED}"
|
||||
fi
|
||||
|
||||
# exit code, print it if its not 0
|
||||
if [[ $exit_status -ne 0 ]]; then
|
||||
EXIT_STATUS=" %B%F{blue}◆%f%b %B%F{$HASH_MOD}Exit Code:%b%f %B%F{yellow}${exit_status}%b%f"
|
||||
else
|
||||
EXIT_STATUS=""
|
||||
fi
|
||||
|
||||
|
||||
#PROMPT LINE
|
||||
#${PR_BRIGHT_YELLOW}%D{%R.%S %a %b %d %Y}${PR_RESET}\
|
||||
LINE1_PROMPT="\
|
||||
%B%F{black}▶%f%b%F{red}▶%B%F{red}▶%f%b \
|
||||
%B%F{$HASH_MOD}%D{%R.%S %a %b %d %Y}%b%f\
|
||||
${EXIT_STATUS}\
|
||||
%(1j. %B%F{green}◆%f%b %B%F{yellow}Jobs: %j%f%b.)\
|
||||
${PR_BATTERY}\
|
||||
%B%F{red}◀%f%b%F{red}◀%B%F{black}◀%f%b"
|
||||
###################
|
||||
|
||||
local TERMWIDTH
|
||||
(( TERMWIDTH = ${COLUMNS} - 2 ))
|
||||
LINE1=${(e%)LINE1_PROMPT} SSH_P=${(e%)SSH_PROMPT}
|
||||
#$LINE1
|
||||
LINE1_LENGTH=${#${LINE1//\[[^m]##m/}}
|
||||
SSH_P_LENGTH=${#${SSH_P//\[[^m]##m/}}
|
||||
FILL_SPACES=${(l:TERMWIDTH - (LINE1_LENGTH + SSH_P_LENGTH):: :)}
|
||||
|
||||
print -- "$LINE1 $FILL_SPACES $SSH_P"
|
||||
}
|
||||
|
||||
PROMPT='${PROMPT_LINE}%B%F{green}:%f%b${PR_PWDCOLOR}%~${PR_RESET}${vcs_info_msg_0_}%(!.%B%F{red}%#%f%b.%B%F{green}➤%f%b) '
|
||||
|
||||
|
||||
######################################D
|
||||
|
||||
# set PATH so it includes user's private bin if it exists (as in GUI this will
|
||||
# not be an interactive login shell)
|
||||
if [ -d "$HOME/.local/bin" ]
|
||||
then
|
||||
PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
# Make CTRL+S work
|
||||
stty -ixon
|
||||
|
||||
# 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 ~/.zsh_aliases ]; then
|
||||
. ~/.zsh_aliases
|
||||
fi
|
||||
|
||||
# Start tmux
|
||||
#if command -v tmux>/dev/null; then
|
||||
# [[ ! $TERM =~ screen ]] && [ -z $TMUX ] && exec tmux
|
||||
#fi
|
||||
|
||||
# Enable Ctrl-x-e to edit command line
|
||||
autoload -U edit-command-line
|
||||
# Emacs style
|
||||
#zle -N edit-command-line
|
||||
#bindkey '^xe' edit-command-line
|
||||
#bindkey '^x^e' edit-command-line
|
||||
# Vi style:
|
||||
zle -N edit-command-line
|
||||
bindkey -M vicmd v edit-command-line
|
||||
|
||||
export PATH="$PATH:$HOME/.config/composer/vendor/bin/"
|
||||
|
||||
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh
|
||||
|
||||
export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
|
||||
export PATH="$HOME/.cabal/bin:$PATH"
|
||||
189
shell/.dir_colors
Normal file
189
shell/.dir_colors
Normal file
@@ -0,0 +1,189 @@
|
||||
# Configuration file for dircolors, a utility to help you set the
|
||||
# LS_COLORS environment variable used by GNU ls with the --color option.
|
||||
# Copyright (C) 1996-2016 Free Software Foundation, Inc.
|
||||
# Copying and distribution of this file, with or without modification,
|
||||
# are permitted provided the copyright notice and this notice are preserved.
|
||||
# The keywords COLOR, OPTIONS, and EIGHTBIT (honored by the
|
||||
# slackware version of dircolors) are recognized but ignored.
|
||||
# Below are TERM entries, which can be a glob patterns, to match
|
||||
# against the TERM environment variable to determine if it is colorizable.
|
||||
TERM Eterm
|
||||
TERM ansi
|
||||
TERM *color*
|
||||
TERM con[0-9]*x[0-9]*
|
||||
TERM cons25
|
||||
TERM console
|
||||
TERM cygwin
|
||||
TERM dtterm
|
||||
TERM gnome
|
||||
TERM hurd
|
||||
TERM jfbterm
|
||||
TERM konsole
|
||||
TERM kterm
|
||||
TERM linux
|
||||
TERM linux-c
|
||||
TERM mlterm
|
||||
TERM putty
|
||||
TERM rxvt*
|
||||
TERM screen*
|
||||
TERM st
|
||||
TERM terminator
|
||||
TERM tmux*
|
||||
TERM vt100
|
||||
TERM xterm*
|
||||
# Below are the color init strings for the basic file types. A color init
|
||||
# string consists of one or more of the following numeric codes:
|
||||
# Attribute codes:
|
||||
# 00=none 01=bold 04=underscore 05=blink 07=reverse 08=concealed
|
||||
# Text color codes:
|
||||
# 30=black 31=red 32=green 33=yellow 34=blue 35=magenta 36=cyan 37=white
|
||||
# Background color codes:
|
||||
# 40=black 41=red 42=green 43=yellow 44=blue 45=magenta 46=cyan 47=white
|
||||
#NORMAL 00 # no color code at all
|
||||
#FILE 00 # regular file: use no color at all
|
||||
RESET 0 # reset to "normal" color
|
||||
DIR 01;34 # directory
|
||||
LINK 01;36 # symbolic link. (If you set this to 'target' instead of a
|
||||
# numerical value, the color is as for the file pointed to.)
|
||||
MULTIHARDLINK 00 # regular file with more than one link
|
||||
FIFO 40;33 # pipe
|
||||
SOCK 01;35 # socket
|
||||
DOOR 01;35 # door
|
||||
BLK 40;33;01 # block device driver
|
||||
CHR 40;33;01 # character device driver
|
||||
ORPHAN 40;31;01 # symlink to nonexistent file, or non-stat'able file ...
|
||||
MISSING 00 # ... and the files they point to
|
||||
SETUID 37;41 # file that is setuid (u+s)
|
||||
SETGID 30;43 # file that is setgid (g+s)
|
||||
CAPABILITY 30;41 # file with capability
|
||||
STICKY_OTHER_WRITABLE 30;42 # dir that is sticky and other-writable (+t,o+w)
|
||||
OTHER_WRITABLE 34;42 # dir that is other-writable (o+w) and not sticky
|
||||
STICKY 37;44 # dir with the sticky bit set (+t) and not other-writable
|
||||
# This is for files with execute permission:
|
||||
EXEC 01;32
|
||||
# List any file extensions like '.gz' or '.tar' that you would like ls
|
||||
# to colorize below. Put the extension, a space, and the color init string.
|
||||
# (and any comments you want to add after a '#')
|
||||
# If you use DOS-style suffixes, you may want to uncomment the following:
|
||||
#.cmd 01;32 # executables (bright green)
|
||||
#.exe 01;32
|
||||
#.com 01;32
|
||||
#.btm 01;32
|
||||
#.bat 01;32
|
||||
# Or if you want to colorize scripts even if they do not have the
|
||||
# executable bit actually set.
|
||||
#.sh 01;32
|
||||
#.csh 01;32
|
||||
# archives or compressed (bright red)
|
||||
.tar 01;31
|
||||
.tgz 01;31
|
||||
.arc 01;31
|
||||
.arj 01;31
|
||||
.taz 01;31
|
||||
.lha 01;31
|
||||
.lz4 01;31
|
||||
.lzh 01;31
|
||||
.lzma 01;31
|
||||
.tlz 01;31
|
||||
.txz 01;31
|
||||
.tzo 01;31
|
||||
.t7z 01;31
|
||||
.zip 01;31
|
||||
.z 01;31
|
||||
.Z 01;31
|
||||
.dz 01;31
|
||||
.gz 01;31
|
||||
.lrz 01;31
|
||||
.lz 01;31
|
||||
.lzo 01;31
|
||||
.xz 01;31
|
||||
.zst 01;31
|
||||
.tzst 01;31
|
||||
.bz2 01;31
|
||||
.bz 01;31
|
||||
.tbz 01;31
|
||||
.tbz2 01;31
|
||||
.tz 01;31
|
||||
.deb 01;31
|
||||
.rpm 01;31
|
||||
.jar 01;31
|
||||
.war 01;31
|
||||
.ear 01;31
|
||||
.sar 01;31
|
||||
.rar 01;31
|
||||
.alz 01;31
|
||||
.ace 01;31
|
||||
.zoo 01;31
|
||||
.cpio 01;31
|
||||
.7z 01;31
|
||||
.rz 01;31
|
||||
.cab 01;31
|
||||
# image formats
|
||||
.jpg 01;35
|
||||
.jpeg 01;35
|
||||
.mjpg 01;35
|
||||
.mjpeg 01;35
|
||||
.gif 01;35
|
||||
.bmp 01;35
|
||||
.pbm 01;35
|
||||
.pgm 01;35
|
||||
.ppm 01;35
|
||||
.tga 01;35
|
||||
.xbm 01;35
|
||||
.xpm 01;35
|
||||
.tif 01;35
|
||||
.tiff 01;35
|
||||
.png 01;35
|
||||
.svg 01;35
|
||||
.svgz 01;35
|
||||
.mng 01;35
|
||||
.pcx 01;35
|
||||
.mov 01;35
|
||||
.mpg 01;35
|
||||
.mpeg 01;35
|
||||
.m2v 01;35
|
||||
.mkv 01;35
|
||||
.webm 01;35
|
||||
.ogm 01;35
|
||||
.mp4 01;35
|
||||
.m4v 01;35
|
||||
.mp4v 01;35
|
||||
.vob 01;35
|
||||
.qt 01;35
|
||||
.nuv 01;35
|
||||
.wmv 01;35
|
||||
.asf 01;35
|
||||
.rm 01;35
|
||||
.rmvb 01;35
|
||||
.flc 01;35
|
||||
.avi 01;35
|
||||
.fli 01;35
|
||||
.flv 01;35
|
||||
.gl 01;35
|
||||
.dl 01;35
|
||||
.xcf 01;35
|
||||
.xwd 01;35
|
||||
.yuv 01;35
|
||||
.cgm 01;35
|
||||
.emf 01;35
|
||||
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
|
||||
.ogv 01;35
|
||||
.ogx 01;35
|
||||
# audio formats
|
||||
.aac 00;36
|
||||
.au 00;36
|
||||
.flac 00;36
|
||||
.m4a 00;36
|
||||
.mid 00;36
|
||||
.midi 00;36
|
||||
.mka 00;36
|
||||
.mp3 00;36
|
||||
.mpc 00;36
|
||||
.ogg 00;36
|
||||
.ra 00;36
|
||||
.wav 00;36
|
||||
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
|
||||
.oga 00;36
|
||||
.opus 00;36
|
||||
.spx 00;36
|
||||
.xspf 00;36
|
||||
56
shell/.notifyosd.zsh
Normal file
56
shell/.notifyosd.zsh
Normal file
@@ -0,0 +1,56 @@
|
||||
# commands to ignore
|
||||
cmdignore=(htop tmux top vim nvim testomatic pgcli bat mux tmuxp gc)
|
||||
|
||||
# set gt 0 to enable GNU units for time results
|
||||
gnuunits=0
|
||||
|
||||
# end and compare timer, notify-send if needed
|
||||
function notifyosd-precmd() {
|
||||
retval=$?
|
||||
if [[ ${cmdignore[(r)$cmd_basename]} == $cmd_basename ]]; then
|
||||
return
|
||||
else
|
||||
if [ ! -z "$cmd" ]; then
|
||||
cmd_end=`date +%s`
|
||||
((cmd_secs=$cmd_end - $cmd_start))
|
||||
fi
|
||||
if [ $retval -gt 0 ]; then
|
||||
cmdstat="with warning"
|
||||
sndstat="/usr/share/sounds/gnome/default/alerts/sonar.ogg"
|
||||
urgency="critical"
|
||||
else
|
||||
cmdstat="successfully"
|
||||
sndstat="/usr/share/sounds/gnome/default/alerts/glass.ogg"
|
||||
urgency="normal"
|
||||
fi
|
||||
if [ ! -z "$cmd" -a $cmd_secs -gt 10 ]; then
|
||||
if [ $gnuunits -gt 0 ]; then
|
||||
cmd_time=$(units "$cmd_secs seconds" "centuries;years;months;weeks;days;hours;minutes;seconds" | \
|
||||
sed -e 's/\ +/\,/g' -e s'/\t//')
|
||||
else
|
||||
cmd_time=$(printf '%dh:%dm:%ds\n' $(($cmd_secs/3600)) $(($cmd_secs%3600/60)) $(($cmd_secs%60)))
|
||||
fi
|
||||
if [ ! -z $SSH_TTY ] ; then
|
||||
notify-send -i utilities-terminal \
|
||||
-u $urgency "$cmd_basename on `hostname` completed $cmdstat" "\"$cmd\" took $cmd_time";
|
||||
else
|
||||
notify-send -i utilities-terminal \
|
||||
-u $urgency "$cmd_basename completed $cmdstat" "\"$cmd\" took $cmd_time";
|
||||
fi
|
||||
fi
|
||||
unset cmd
|
||||
fi
|
||||
}
|
||||
|
||||
# make sure this plays nicely with any existing precmd
|
||||
precmd_functions+=( notifyosd-precmd )
|
||||
|
||||
# get command name and start the timer
|
||||
function notifyosd-preexec() {
|
||||
cmd=$1
|
||||
cmd_basename=${${cmd:s/sudo //}[(ws: :)1]}
|
||||
cmd_start=`date +%s`
|
||||
}
|
||||
|
||||
# make sure this plays nicely with any existing preexec
|
||||
preexec_functions+=( notifyosd-preexec )
|
||||
53
shell/.profile
Normal file
53
shell/.profile
Normal file
@@ -0,0 +1,53 @@
|
||||
# ~/.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 zsh
|
||||
if [ -n "$ZSH_VERSION" ]; then
|
||||
# include .bashrc if it exists
|
||||
if [ -f "$HOME/.zshrc" ]; then
|
||||
. "$HOME/.zshrc"
|
||||
fi
|
||||
fi
|
||||
|
||||
# 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/.local/bin" ] ; then
|
||||
PATH="$HOME/.local/bin:$PATH"
|
||||
fi
|
||||
|
||||
|
||||
export PATH="$HOME/.cargo/bin:$PATH"
|
||||
|
||||
# Most applications support several languages for their output.
|
||||
# To make use of this feature, simply uncomment one of the lines below or
|
||||
# add your own one (see /usr/share/locale/locale.alias for more codes)
|
||||
# This overwrites the system default set in /etc/sysconfig/language
|
||||
# in the variable RC_LANG.
|
||||
#
|
||||
#export LANG=de_DE.UTF-8 # uncomment this line for German output
|
||||
#export LANG=fr_FR.UTF-8 # uncomment this line for French output
|
||||
#export LANG=es_ES.UTF-8 # uncomment this line for Spanish output
|
||||
|
||||
|
||||
# Some people don't like fortune. If you uncomment the following lines,
|
||||
# you will have a fortune each time you log in ;-)
|
||||
|
||||
#if [ -x /usr/bin/fortune ] ; then
|
||||
# echo
|
||||
# /usr/bin/fortune
|
||||
# echo
|
||||
#fi
|
||||
10
shell/.zimrc
Normal file
10
shell/.zimrc
Normal file
@@ -0,0 +1,10 @@
|
||||
#!/bin/zsh
|
||||
|
||||
zmodules=(directory environment git git-info history input archive utility \
|
||||
autosuggestions prompt completion syntax-highlighting history-substring-search)
|
||||
zprompt_theme='lean'
|
||||
ztermtitle='%m:%~'
|
||||
# Set to vi or emacs
|
||||
#zinput_mode='emacs'
|
||||
zinput_mode='vi'
|
||||
zhighlighters=(main brackets pattern cursor)
|
||||
5
shell/.zlogin
Normal file
5
shell/.zlogin
Normal file
@@ -0,0 +1,5 @@
|
||||
#
|
||||
# User configuration sourced by login shells
|
||||
#
|
||||
|
||||
|
||||
19
shell/.zprofile
Normal file
19
shell/.zprofile
Normal file
@@ -0,0 +1,19 @@
|
||||
#!/usr/bin/zsh
|
||||
|
||||
export EDITOR='nvim'
|
||||
export VISUAL='nvim'
|
||||
export PAGER='less'
|
||||
export GOPATH="$HOME/go"
|
||||
export GPG_TTY=$(tty)
|
||||
export LESS='-F -g -i -M -R -S -w -X -z-4'
|
||||
|
||||
typeset -gU cdpath fpath mailpath path
|
||||
path+=("$HOME/.dotfiles/bin" "$GOPATH/bin" "$HOME/.local/bin")
|
||||
|
||||
# It looks like this is a login shell, load .profile
|
||||
[ -f "$HOME/.profile" ] && source "$HOME/.profile"
|
||||
|
||||
if [ -z "$DISPLAY" ] && [ -n "$XDG_VTNR" ] && [ "$XDG_VTNR" -eq 1 ]
|
||||
then
|
||||
exec startx > ${HOME}/.xoutput 2>&1
|
||||
fi
|
||||
37
shell/.zsh_aliases
Normal file
37
shell/.zsh_aliases
Normal file
@@ -0,0 +1,37 @@
|
||||
# Pretty csv viewer
|
||||
function pretty_csv {
|
||||
column -t -s, -n "$@" | less -F -S -X -K
|
||||
}
|
||||
|
||||
# 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 ls aliases
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
|
||||
# better less
|
||||
alias less="less -R "
|
||||
|
||||
alias php="php -c ~/workspace/php.ini"
|
||||
|
||||
# Alternative system beep for (not only) when the system has no internal beep
|
||||
export BEEP=/usr/share/sounds/freedesktop/stereo/bell.oga
|
||||
alias beep='paplay $BEEP --volume=32768'
|
||||
|
||||
### Extra aliases added after default:
|
||||
|
||||
# Cheat code indent
|
||||
stylefix ()
|
||||
{
|
||||
for file in $@
|
||||
do
|
||||
indent -linux -l80 -nbad -bap -bc -bbo -bl -bli0 -bls -ncdb -nce -cp1 -c33 -cs -di2 -ndj -nfc1 -nfca -hnl -i8 -ip5 -lp -pcs -psl -nsc -nsob -nut "$PWD/$file"
|
||||
rm "$PWD/$file~"
|
||||
done
|
||||
}
|
||||
alias stylefix=stylefix;
|
||||
alias pkgin='sudo aptitude install'
|
||||
alias pkgrm='sudo aptitude remove'
|
||||
alias wttr='curl http://wttr.in/Porto,Portugal'
|
||||
alias top='htop'
|
||||
17
shell/.zshrc
Normal file
17
shell/.zshrc
Normal file
@@ -0,0 +1,17 @@
|
||||
#!/bin/zsh
|
||||
|
||||
#
|
||||
# User configuration sourced by interactive shells
|
||||
#
|
||||
|
||||
setopt LOCAL_OPTIONS # allow functions to have local options
|
||||
setopt LOCAL_TRAPS # allow functions to have local traps
|
||||
setopt CLOBBER
|
||||
setopt RM_STAR_SILENT # dont ask for confirmation in rm globs
|
||||
setopt CORRECT # auto-correct commands
|
||||
setopt COMPLETE_IN_WORD # dont nice background tasks
|
||||
setopt PROMPT_SUBST # expand prompt sequences
|
||||
|
||||
# Load basic settings
|
||||
source ${HOME}/.basic.zshrc
|
||||
|
||||
197
shell/README.md
Normal file
197
shell/README.md
Normal file
@@ -0,0 +1,197 @@
|
||||
# Scripts for zsh
|
||||
|
||||
Doc for my zsh scripts (`scripts.zsh`).
|
||||
|
||||
## System
|
||||
|
||||
### Update system
|
||||
|
||||
`updatesys`
|
||||
|
||||
Update:
|
||||
* Go binaries
|
||||
* Composer global install
|
||||
* Official Arch linux packages (via Aurman or yay if installed ; otherwise pacman)
|
||||
* AUR packages (via Aurman or yay if installed)
|
||||
|
||||
### Disk backup
|
||||
|
||||
`dback <disk source> <disk output>`
|
||||
|
||||
Use dd to copy an entire hard disk to another disk output. Ask questions to be sure you know what you are doing :)
|
||||
Way safer than using pure dd without any warning message...
|
||||
|
||||
### Create ssh key
|
||||
|
||||
`sshcreate <name>`
|
||||
|
||||
Create a new ssh key at `~/.ssh/<name>` with permission 700.
|
||||
The name will be put as comment in the key as well.
|
||||
|
||||
## Archives
|
||||
|
||||
### Extraction
|
||||
|
||||
`extract <archive_file>`
|
||||
|
||||
Extract any archive automatically. Require `tar` and `unzip`.
|
||||
|
||||
### Compression
|
||||
`compress <folder>`
|
||||
|
||||
Compress a folder - output `tar.gz`
|
||||
|
||||
## Database
|
||||
|
||||
### Postgres
|
||||
|
||||
These commands need `pv` to be installed.
|
||||
|
||||
#### Dump
|
||||
`postgdump <database> <user> <host>`
|
||||
|
||||
Create a dump of a database. Include clean up and create dabatase when imported back.
|
||||
|
||||
The file created will be `<database>`.sql
|
||||
|
||||
`<user>` and `<host>` are not mandatory, default `postgres` and `localhost`.
|
||||
|
||||
#### Import
|
||||
`postgimport <table_name> <user> <host>`
|
||||
|
||||
Import a database. If the file is called `database.sql`, it will try to import into the database named `database`.
|
||||
|
||||
`<user>` and `<host>` are not mandatory, default `postgres` and `localhost`.
|
||||
|
||||
**THE OPERATION WILL OVERWRITE ALL DATA!**
|
||||
|
||||
## Network
|
||||
|
||||
### Ports
|
||||
|
||||
`ports`
|
||||
|
||||
List of port opens, fuzzy searchable via fzf
|
||||
|
||||
## Images
|
||||
|
||||
### Screenshot
|
||||
|
||||
`screenshot <win|scr|area>`
|
||||
|
||||
Take a screenshot of the window / screen / area respectively.
|
||||
|
||||
### Image size
|
||||
|
||||
`imgsize <img>`
|
||||
|
||||
Display width / height of an image.
|
||||
|
||||
### Image resize
|
||||
|
||||
`imgresize <source> <width>`
|
||||
Resize and create a new image named `<source>_<width>.<extension>` following aspect ratio.
|
||||
|
||||
`imgresizeall <extension> <width>`
|
||||
Resize every images with the same extension in the current folder
|
||||
|
||||
`imgoptimize <file>`
|
||||
Optimize the image (conv -strip -interlace Plane -quality 85%) and create a new image
|
||||
|
||||
`Imgoptimize <file>`
|
||||
Optimize the image (conv -strip -interlace Plane -quality 85%) and *replace* the image
|
||||
|
||||
`imgoptimizeall <extension>`
|
||||
Optimize the images with same extension in current folder(conv -strip -interlace Plane -quality 85%) and create new images
|
||||
|
||||
`Imgoptimizeall *.<extension>`
|
||||
Optimize the images with same extension in current folder(conv -strip -interlace Plane -quality 85%) and *replace* them
|
||||
|
||||
|
||||
### Image resize all
|
||||
|
||||
`imgresize <extension> <width>`
|
||||
Resize every images with the extension `<extention>` in the current folder.
|
||||
Use Image resize (see above)
|
||||
|
||||
### Image convert to jpg
|
||||
|
||||
`imgconvjpg <source>`
|
||||
|
||||
Require imagemagick.
|
||||
|
||||
Convert source to a jpg image
|
||||
|
||||
## Git
|
||||
|
||||
`gtD <tag_name> <remote>`
|
||||
|
||||
Delete a tag locally AND on the remote. `<remote>` argument is not mandatory, default `origin`.
|
||||
|
||||
`gtd <tag_name> <remote>`
|
||||
|
||||
Delete a tag ONLY on the remote. `<remote>` argument is not mandatory, default `origin`.
|
||||
|
||||
### FZF
|
||||
|
||||
`fmux`
|
||||
|
||||
Let you choose a tmuxp config
|
||||
|
||||
### FZF meets Git
|
||||
|
||||
#### Checkout
|
||||
|
||||
`fgco`
|
||||
|
||||
Require fzf of course :)
|
||||
Checkout local or remote branch via FZF
|
||||
|
||||
#### Logs
|
||||
|
||||
`fgl`
|
||||
|
||||
Simple way to fuzzy search in the log tree.
|
||||
|
||||
### Stash
|
||||
|
||||
`fstash`
|
||||
|
||||
Fuzzy search in the stash list.
|
||||
|
||||
## Other
|
||||
|
||||
`thriftgen`
|
||||
|
||||
Generate thrift config via thrift on local (docker image doesn't work...)
|
||||
|
||||
`mkcd`
|
||||
|
||||
Create a folder like `mkdir -p` and goes in it.
|
||||
|
||||
`updatezsh`
|
||||
|
||||
Update antibody plugins
|
||||
|
||||
`promptspeed`
|
||||
|
||||
Display the time for the prompt to appear when opening a new zsh instance
|
||||
|
||||
## Fun
|
||||
|
||||
`matrix`
|
||||
|
||||
Display... the matrix!
|
||||
|
||||
`colorblocks`
|
||||
|
||||
Display the main terminal colors configured, in nice blocks. [source](https://github.com/iiPlasma/dots/blob/master/bin/bin/colorblocks).
|
||||
|
||||
`colorcards`
|
||||
|
||||
Display all the terminal colors configured, in nice panes. [source](https://github.com/iiPlasma/dots/blob/master/bin/bin/colorcards).
|
||||
|
||||
`pipes`
|
||||
|
||||
Remember the OpenGL pipes screensaver on windows 9*? The same in the terminal. [source](https://github.com/iiPlasma/dots/blob/master/bin/bin/pipes).
|
||||
|
||||
394
shell/scripts.zsh
Normal file
394
shell/scripts.zsh
Normal file
@@ -0,0 +1,394 @@
|
||||
screencast() {
|
||||
if [ ! -z $1 ] ; then
|
||||
ffmpeg -f x11grab -s $(xdpyinfo | grep dimensions | awk '{print $2}') -i :0.0 -f pulse -i default $1
|
||||
else
|
||||
echo "You need to precise an output file as first argument - eg 'example.mkv'"
|
||||
fi
|
||||
}
|
||||
|
||||
oscreencast() {
|
||||
if [ ! -z $1 ] ; then
|
||||
ffmpeg -f x11grab -s $(xdpyinfo | grep dimensions | awk '{print $2}') -i :0.0 $1
|
||||
else
|
||||
echo "You need to precise an output file as first argument - eg 'example.mkv'"
|
||||
fi
|
||||
}
|
||||
|
||||
updatesys() {
|
||||
sh $DOTFILES/update.sh
|
||||
if hash aurman 2>/dev/null; then
|
||||
aurman -Syu
|
||||
elif hash yay 2>/dev/null; then
|
||||
yay -Syu
|
||||
else
|
||||
sudo pacman -Syu
|
||||
fi
|
||||
}
|
||||
|
||||
extract() {
|
||||
if [ -f $1 ] ; then
|
||||
case $1 in
|
||||
*.tar.bz2) tar xjf $1 ;;
|
||||
*.tar.gz) tar xzf $1 ;;
|
||||
*.bz2) bunzip2 $1 ;;
|
||||
*.rar) rar x $1 ;;
|
||||
*.gz) gunzip $1 ;;
|
||||
*.tar) tar xf $1 ;;
|
||||
*.tbz2) tar xjf $1 ;;
|
||||
*.tgz) tar xzf $1 ;;
|
||||
*.zip) unzip $1 ;;
|
||||
*.Z) uncompress $1 ;;
|
||||
*) echo "'$1' cannot be extracted" ;;
|
||||
esac
|
||||
else
|
||||
echo "'$1' is not a valid file"
|
||||
fi
|
||||
}
|
||||
|
||||
compress() {
|
||||
tar cvzf $1.tar.gz $1
|
||||
}
|
||||
|
||||
screenshot () {
|
||||
DIR="${HOME}/documents/images/screenshots"
|
||||
DATE="$(date +%Y%m%d-%H%M%S)"
|
||||
NAME="${DIR}/screenshot-${DATE}.png"
|
||||
LOG="${DIR}/screenshots.log"
|
||||
|
||||
# Check if the dir to store the screenshots exists, else create it:
|
||||
if [ ! -d "${DIR}" ]; then mkdir -p "${DIR}"; fi
|
||||
|
||||
if [ ! -f "${LOG}" ]; then touch "${LOG}"; fi
|
||||
|
||||
# Screenshot a selected window
|
||||
if [ "$1" = "win" ]; then import -format png "${NAME}"; fi
|
||||
|
||||
# Screenshot the entire screen
|
||||
if [ "$1" = "scr" ]; then import -format png -window root "${NAME}"; fi
|
||||
|
||||
# Screenshot a selected area
|
||||
if [ "$1" = "area" ]; then import -format png "${NAME}"; fi
|
||||
|
||||
if [[ $# = 0 ]]; then
|
||||
# Display a warning if no area defined
|
||||
echo "No screenshot area has been specified. Please choose a command: win, scr, area. Screenshot not taken."
|
||||
echo "${DATE}: No screenshot area has been defined. Screenshot not taken." >> "${LOG}"
|
||||
else
|
||||
# Save the screenshot in the directory and edit the log
|
||||
echo "${NAME}" >> "${LOG}"
|
||||
fi
|
||||
}
|
||||
|
||||
imgsize() {
|
||||
width=$(identify -format "%w" "$1")> /dev/null
|
||||
height=$(identify -format "%h" "$1")> /dev/null
|
||||
|
||||
echo -e "Size of $1: $width*$height"
|
||||
}
|
||||
|
||||
imgresize() {
|
||||
filename=${1%\.*}
|
||||
extension="${1##*.}"
|
||||
separator="_"
|
||||
finalName="$filename$separator$2.$extension"
|
||||
convert $1 -quality 100 -resize $2 $finalName
|
||||
echo "$finalName"
|
||||
}
|
||||
|
||||
imgresizeall() {
|
||||
for f in *.${1}; do
|
||||
imgresize "$f" ${2}
|
||||
done
|
||||
}
|
||||
|
||||
imgoptimize() {
|
||||
filename=${1%\.*}
|
||||
extension="${1##*.}"
|
||||
separator="_"
|
||||
suffix="optimized"
|
||||
finalName="$filename$separator$suffix.$extension"
|
||||
convert $1 -strip -interlace Plane -quality 85% $finalName
|
||||
echo "$finalName created"
|
||||
}
|
||||
|
||||
Imgoptimize() {
|
||||
filename=${1%\.*}
|
||||
extension="${1##*.}"
|
||||
separator="_"
|
||||
suffix="optimized"
|
||||
finalName="$filename$separator$suffix.$extension"
|
||||
convert $1 -strip -interlace Plane -quality 85% $1
|
||||
echo "$1 created"
|
||||
}
|
||||
|
||||
imgoptimizeall() {
|
||||
for f in *.${1}; do
|
||||
imgoptimize "$f"
|
||||
done
|
||||
}
|
||||
|
||||
Imgoptimizeall() {
|
||||
for f in *.${1}; do
|
||||
Imgoptimize "$f"
|
||||
done
|
||||
}
|
||||
|
||||
imgconvjpg() {
|
||||
if [ ! -z "$1" ];
|
||||
then
|
||||
filename=${1%\.*}
|
||||
magick convert $1 "${filename}.jpg"
|
||||
else
|
||||
echo -e "You need to add an image to convert as param!"
|
||||
fi
|
||||
}
|
||||
|
||||
imgconvpng() {
|
||||
if [ ! -z "$1" ];
|
||||
then
|
||||
filename=${1%\.*}
|
||||
magick convert $1 "${filename}.png"
|
||||
else
|
||||
echo -e "You need to add an image to convert as param!"
|
||||
fi
|
||||
}
|
||||
|
||||
gtD() {
|
||||
git tag -d $1
|
||||
if [ ! -z "$2" ];
|
||||
then
|
||||
git push $2 :refs/tags/$1
|
||||
else
|
||||
git push origin :refs/tags/$1
|
||||
fi
|
||||
}
|
||||
|
||||
sshcreate() {
|
||||
if [ ! -z "$1" ];
|
||||
then
|
||||
ssh-keygen -f $HOME/.ssh/$1 -t rsa -N '' -C "$1"
|
||||
chmod 700 $HOME/.ssh/$1*
|
||||
fi
|
||||
}
|
||||
|
||||
dback () {
|
||||
if [ ! -z $1 ] && [ ! -z $2 ];
|
||||
then
|
||||
if [ ! -z $3 ];
|
||||
then
|
||||
BS=$3
|
||||
else
|
||||
BS="512k"
|
||||
fi
|
||||
|
||||
dialog --defaultno --title "Are you sure?" --yesno "This will copy $1 to $2 (bitsize: $BS). Everything on $2 will be deleted.\n\n
|
||||
Are you sure?" 15 60 || exit
|
||||
|
||||
(sudo pv -n $1 | sudo dd of=$2 bs=$BS conv=notrunc,noerror) 2>&1 | dialog --gauge "Backup from disk $1 to disk $2... please wait" 10 70 0
|
||||
else
|
||||
echo "You need to provide an input disk as first argument (i.e /dev/sda) and an output disk as second argument (i.e /dev/sdb)"
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
blimg() {
|
||||
if [ ! -z $1 ] && [ ! -z $2 ] && [ ! -z $3 ];
|
||||
then
|
||||
CYEAR=$(date +'%Y')
|
||||
BASEDIR="${HOME}/workspace/webtechno/static"
|
||||
#Basedir current year
|
||||
BASEDIRY="${HOME}/workspace/webtechno/static/${CYEAR}"
|
||||
|
||||
if [ ! -d $BASEDIRY ];
|
||||
then
|
||||
mkdir $BASEDIRY
|
||||
fi
|
||||
|
||||
#basedir current article
|
||||
BASEDIRC="${BASEDIRY}/${2}"
|
||||
|
||||
if [ ! -d $BASEDIRP ];
|
||||
then
|
||||
mkdir $BASEDIRP
|
||||
fi
|
||||
|
||||
IMGRESIZED=imgresize "${1} 780"
|
||||
echo "$IMGRESIZED"
|
||||
fi
|
||||
}
|
||||
|
||||
postgdump() {
|
||||
USER="postgres"
|
||||
HOST="localhost"
|
||||
if [ ! -z $1 ];
|
||||
then
|
||||
if [ -f "${1}.sql" ];
|
||||
then
|
||||
rm -i "${1}.sql"
|
||||
fi
|
||||
|
||||
if [ $# = 1 ];
|
||||
then
|
||||
pg_dump -c -U $USER -h $HOST $1 | pv --progress > "${1}.sql"
|
||||
echo $1
|
||||
fi
|
||||
|
||||
if [ $# = 2 ];
|
||||
then
|
||||
pg_dump -c -U $2 -h $HOST $1 | pv --progress > "${1}.sql"
|
||||
echo $1
|
||||
fi
|
||||
|
||||
if [ $# = 3 ];
|
||||
then
|
||||
pg_dump -c -U $2 -h $3 $1 | pv --progress > "${1}.sql"
|
||||
echo $1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# = 0 ];
|
||||
then
|
||||
echo "You need at least to provide the database name"
|
||||
fi
|
||||
}
|
||||
|
||||
postgimport() {
|
||||
USER="postgres"
|
||||
HOST="localhost"
|
||||
if [ ! -z $1 ];
|
||||
DB=${1%\.*}
|
||||
then
|
||||
# sed -i "1s/^/CREATE DATABASE $DB;\n/" $1
|
||||
if [ $# = 1 ];
|
||||
then
|
||||
pv --progress ${1} | psql -U $USER -h $HOST $1 -d $DB
|
||||
echo $1
|
||||
fi
|
||||
|
||||
if [ $# = 2 ];
|
||||
then
|
||||
pv --progress ${1} | psql -U $1 -h $HOST $1 -d $DB
|
||||
echo $1
|
||||
fi
|
||||
|
||||
if [ $# = 3 ];
|
||||
then
|
||||
pv --progress ${1} | psql -U $1 -h $2 $1 -d $DB
|
||||
echo $1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $# = 0 ];
|
||||
then
|
||||
echo "You need at least to provide the database name"
|
||||
fi
|
||||
}
|
||||
|
||||
matrix () {
|
||||
lines=$(tput lines)
|
||||
cols=$(tput cols)
|
||||
|
||||
awkscript='
|
||||
{
|
||||
letters="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#$%^&*()"
|
||||
lines=$1
|
||||
random_col=$3
|
||||
c=$4
|
||||
letter=substr(letters,c,1)
|
||||
cols[random_col]=0;
|
||||
for (col in cols) {
|
||||
line=cols[col];
|
||||
cols[col]=cols[col]+1;
|
||||
printf "\033[%s;%sH\033[2;32m%s", line, col, letter;
|
||||
printf "\033[%s;%sH\033[1;37m%s\033[0;0H", cols[col], col, letter;
|
||||
if (cols[col] >= lines) {
|
||||
cols[col]=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
echo -e "\e[1;40m"
|
||||
clear
|
||||
|
||||
while :; do
|
||||
echo $lines $cols $(( $RANDOM % $cols)) $(( $RANDOM % 72 ))
|
||||
sleep 0.05
|
||||
done | awk "$awkscript"
|
||||
}
|
||||
|
||||
pgdump() {
|
||||
pg_dump -U postgres -h localhost x_loc_0bdf08de > pulsecheck_service_test.sql
|
||||
}
|
||||
|
||||
# Loopline system (my job) related
|
||||
thriftgen() {
|
||||
thrift -o . -r --gen php:server -out ./php/gen ./service.thrift
|
||||
thrift -o . -r --gen go -out ./go/pkg/gen ./service.thrift
|
||||
}
|
||||
|
||||
colorblocks() {
|
||||
$DOTFILES/bash/scripts/colorblocks.sh
|
||||
}
|
||||
|
||||
colorcards() {
|
||||
$DOTFILES/bash/scripts/colorcards.sh
|
||||
}
|
||||
|
||||
pipes() {
|
||||
$DOTFILES/bash/scripts/pipes.sh
|
||||
}
|
||||
|
||||
crypt() {
|
||||
[ $# -eq 1 ] && set -- "--encrypt" "$1"
|
||||
|
||||
usage() { >&2 echo "Usage: crypt {-c,-d} <path>"
|
||||
exit 1 ; }
|
||||
|
||||
case "$1" in
|
||||
--encrypt|-c)
|
||||
if [ -d "$2" ] ; then
|
||||
dash ${HOME}/bin/pack "$2"
|
||||
set 2 "${2%/}".tar.xz
|
||||
elif [ -f "$2" ] ; then
|
||||
xz -9 "$2"
|
||||
set 2 "$2".xz
|
||||
else
|
||||
usage
|
||||
fi
|
||||
opts="-salt -e" ;;
|
||||
--decrypt|-d)
|
||||
[ ! -e "$2" ] && usage
|
||||
opts="-d" ;;
|
||||
*) usage
|
||||
esac
|
||||
|
||||
cat "$2" | openssl aes-256-cbc $opts -a -out "$2" &&
|
||||
|
||||
case "$1" in
|
||||
--decrypt|-d)
|
||||
xz -d "$2" 2> /dev/null &&
|
||||
tar xf "${2%.*}" 2> /dev/null &&
|
||||
rm -rf "${2%.*}" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
mkcd()
|
||||
{
|
||||
dir="$*";
|
||||
mkdir -p "$dir" && cd "$dir";
|
||||
}
|
||||
|
||||
updatezsh() {
|
||||
rm -f $DOTFILES/antibody/plugins.sh
|
||||
antibody bundle < $DOTFILES/antibody/plugins.txt > $DOTFILES/antibody/plugins.sh
|
||||
antibody update
|
||||
}
|
||||
|
||||
promptspeed() {
|
||||
for i in $(seq 1 10); do /usr/bin/time zsh -i -c exit; done
|
||||
}
|
||||
|
||||
ports() {
|
||||
sudo netstat -tulpn | grep LISTEN | fzf;
|
||||
}
|
||||
Reference in New Issue
Block a user