Whitespace changes
Delete unnecessary indentation and convert all spaces to tabs.
This commit is contained in:
@@ -8,177 +8,177 @@
|
|||||||
# Initialization code that may require console input (password prompts, [y/n]
|
# Initialization code that may require console input (password prompts, [y/n]
|
||||||
# confirmations, etc.) must go above this block; everything else may go below.
|
# confirmations, etc.) must go above this block; everything else may go below.
|
||||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export ZSH_CONF="$ZDOTDIR/plugins"
|
export ZSH_CONF="$ZDOTDIR/plugins"
|
||||||
|
|
||||||
# https://github.com/romkatv/dotfiles-public/blob/7e49fc4fb71d/.zshrc#L35
|
# https://github.com/romkatv/dotfiles-public/blob/7e49fc4fb71d/.zshrc#L35
|
||||||
comp-conf() {
|
comp-conf() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
[ ! "$1.zwc" -nt "$1" ] && [ -w "${1:h}" ] || return 0
|
[ ! "$1.zwc" -nt "$1" ] && [ -w "${1:h}" ] || return 0
|
||||||
zmodload -F zsh/files b:zf_mv b:zf_rm
|
zmodload -F zsh/files b:zf_mv b:zf_rm
|
||||||
local tmp="$1.tmp.$$.zwc"
|
local tmp="$1.tmp.$$.zwc"
|
||||||
{
|
{
|
||||||
zcompile -R -- "$tmp" "$1" && zf_mv -f -- "$tmp" "$1.zwc" || return 1
|
zcompile -R -- "$tmp" "$1" && zf_mv -f -- "$tmp" "$1.zwc" || return 1
|
||||||
} always {
|
} always {
|
||||||
(( ! $? )) || zf_rm -f -- "$tmp"
|
(( ! $? )) || zf_rm -f -- "$tmp"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# https://github.com/romkatv/dotfiles-public/blob/7e49fc4fb71d/.zshrc#L47
|
# https://github.com/romkatv/dotfiles-public/blob/7e49fc4fb71d/.zshrc#L47
|
||||||
comp-source() {
|
comp-source() {
|
||||||
emulate -L zsh
|
emulate -L zsh
|
||||||
[ -e "$1" ] && comp-conf "$1" && source -- "$1"
|
[ -e "$1" ] && comp-conf "$1" && source -- "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
## set zshoptions
|
## set zshoptions
|
||||||
setopt AUTO_CONTINUE # Stopped jobs with 'disown' are automatically sent a CONT signal to make them running.
|
setopt AUTO_CONTINUE # Stopped jobs with 'disown' are automatically sent a CONT signal to make them running.
|
||||||
setopt AUTO_LIST # Automatically list choices on an ambiguous completion.
|
setopt AUTO_LIST # Automatically list choices on an ambiguous completion.
|
||||||
setopt AUTO_PARAM_SLASH # Add a trailing slash when completing directories
|
setopt AUTO_PARAM_SLASH # Add a trailing slash when completing directories
|
||||||
setopt AUTO_PUSHD # Make cd push the old directory onto the directory stack.
|
setopt AUTO_PUSHD # Make cd push the old directory onto the directory stack.
|
||||||
setopt NO_AUTO_REMOVE_SLASH # Keeps trailing slash for directories when auto completing.
|
setopt NO_AUTO_REMOVE_SLASH # Keeps trailing slash for directories when auto completing.
|
||||||
# (Beware: commands will act on the target directory not the symlink with the slash)
|
# (Beware: commands will act on the target directory not the symlink with the slash)
|
||||||
setopt NO_BEEP # Do not beep on error in ZLE.
|
setopt NO_BEEP # Do not beep on error in ZLE.
|
||||||
setopt C_BASES # Output hexadecimal numbers in the standard C format ('16#FF' -> '0xFF').
|
setopt C_BASES # Output hexadecimal numbers in the standard C format ('16#FF' -> '0xFF').
|
||||||
setopt CHASE_LINKS # Resolve symbolic links to their true values when changing directory.
|
setopt CHASE_LINKS # Resolve symbolic links to their true values when changing directory.
|
||||||
setopt NO_CLOBBER # '>!' or '>|' must be used to truncate a file, and '>>!' or '>>|' to create a file.
|
setopt NO_CLOBBER # '>!' or '>|' must be used to truncate a file, and '>>!' or '>>|' to create a file.
|
||||||
setopt COMPLETE_IN_WORD # Complete from the cursor rather than from the end of the word
|
setopt COMPLETE_IN_WORD # Complete from the cursor rather than from the end of the word
|
||||||
setopt CORRECT # Try to correct the spelling of a command
|
setopt CORRECT # Try to correct the spelling of a command
|
||||||
setopt CORRECT_ALL # Try to correct the spelling of all arguments
|
setopt CORRECT_ALL # Try to correct the spelling of all arguments
|
||||||
export CORRECT_IGNORE_FILE=".*" # Do not offer hidden files as correction
|
export CORRECT_IGNORE_FILE=".*" # Do not offer hidden files as correction
|
||||||
setopt EXTENDED_HISTORY # Save in format : <beginning time>:<elapsed seconds>;<command>
|
setopt EXTENDED_HISTORY # Save in format : <beginning time>:<elapsed seconds>;<command>
|
||||||
setopt EXTENDED_GLOB # Treat the `#', `~' and `^' characters as part of patterns for filename generation, etc.
|
setopt EXTENDED_GLOB # Treat the `#', `~' and `^' characters as part of patterns for filename generation, etc.
|
||||||
setopt NO_FLOW_CONTROL # Disables output flow control in the shell's editor via start/stop characters (usually ^S/^Q).
|
setopt NO_FLOW_CONTROL # Disables output flow control in the shell's editor via start/stop characters (usually ^S/^Q).
|
||||||
setopt GLOB_DOTS # Do not require a leading `.' in a filename to be matched explicitly.
|
setopt GLOB_DOTS # Do not require a leading `.' in a filename to be matched explicitly.
|
||||||
setopt HIST_IGNORE_DUPS # Do not enter command lines into the history list if they are duplicates of the previous event.
|
setopt HIST_IGNORE_DUPS # Do not enter command lines into the history list if they are duplicates of the previous event.
|
||||||
setopt HIST_IGNORE_SPACE # History should ignore commands beginning with a space
|
setopt HIST_IGNORE_SPACE # History should ignore commands beginning with a space
|
||||||
setopt HIST_VERIFY # perform history expansion and reload line in editing buffer instead of executing it directly
|
setopt HIST_VERIFY # perform history expansion and reload line in editing buffer instead of executing it directly
|
||||||
setopt NO_INC_APPEND_HISTORY # Do not write lines as soon as they are entered (breaks exec time otherwise)
|
setopt NO_INC_APPEND_HISTORY # Do not write lines as soon as they are entered (breaks exec time otherwise)
|
||||||
setopt INC_APPEND_HISTORY_TIME # Write lines after they are finished
|
setopt INC_APPEND_HISTORY_TIME # Write lines after they are finished
|
||||||
setopt INTERACTIVE_COMMENTS # Allow comments even in interactive shells.
|
setopt INTERACTIVE_COMMENTS # Allow comments even in interactive shells.
|
||||||
setopt LIST_AMBIGUOUS # Insert unabmbiguous prefix without completion list (auto_list set)
|
setopt LIST_AMBIGUOUS # Insert unabmbiguous prefix without completion list (auto_list set)
|
||||||
setopt LIST_PACKED # Make completion list smaller by printing matches in columns with different widths.
|
setopt LIST_PACKED # Make completion list smaller by printing matches in columns with different widths.
|
||||||
setopt NO_MENU_COMPLETE # Do not autoselect the first entry when completing
|
setopt NO_MENU_COMPLETE # Do not autoselect the first entry when completing
|
||||||
setopt PUSHD_IGNORE_DUPS # Don't push multiple copies of the same directory onto the directory stack.
|
setopt PUSHD_IGNORE_DUPS # Don't push multiple copies of the same directory onto the directory stack.
|
||||||
setopt NO_SHARE_HISTORY # Do not write + read history after every command (messes up exec time otherwise)
|
setopt NO_SHARE_HISTORY # Do not write + read history after every command (messes up exec time otherwise)
|
||||||
setopt SH_WORD_SPLIT # Causes field splitting to be performed on unquoted parameter expansions
|
setopt SH_WORD_SPLIT # Causes field splitting to be performed on unquoted parameter expansions
|
||||||
|
|
||||||
autoload -U select-word-style && select-word-style bash
|
autoload -U select-word-style && select-word-style bash
|
||||||
|
|
||||||
## Setup the prompt
|
## Setup the prompt
|
||||||
# use bright version of colors when printing bold
|
# use bright version of colors when printing bold
|
||||||
if [ -e "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors/dircolors" ]; then
|
if [ -e "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors/dircolors" ]; then
|
||||||
eval "$(dircolors -b "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors/dircolors")"
|
eval "$(dircolors -b "${XDG_CONFIG_HOME:-$HOME/.config}/dircolors/dircolors")"
|
||||||
else
|
else
|
||||||
eval "$(dircolors -b)"
|
eval "$(dircolors -b)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -e "$ZSH_CONF/powerlevel10k/powerlevel10k.zsh-theme" ]; then
|
if [ -e "$ZSH_CONF/powerlevel10k/powerlevel10k.zsh-theme" ]; then
|
||||||
comp-source "$ZSH_CONF/powerlevel10k/powerlevel10k.zsh-theme"
|
comp-source "$ZSH_CONF/powerlevel10k/powerlevel10k.zsh-theme"
|
||||||
# To customize prompt, run `p10k configure` or edit $ZSH_CONF/p10k.zsh-theme.
|
# To customize prompt, run `p10k configure` or edit $ZSH_CONF/p10k.zsh-theme.
|
||||||
comp-source "$ZSH_CONF/p10k.zsh-theme"
|
comp-source "$ZSH_CONF/p10k.zsh-theme"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## Setup zsh completion system
|
## Setup zsh completion system
|
||||||
[ ! -d "$ZSH_CONF/completion" ] || fpath=("$ZSH_CONF/completion" $fpath)
|
[ ! -d "$ZSH_CONF/completion" ] || fpath=("$ZSH_CONF/completion" $fpath)
|
||||||
|
|
||||||
autoload -Uz compinit
|
autoload -Uz compinit
|
||||||
compinit -d "${XDG_CACHE_HOME:-$HOME/.cache}/zsh/zcompdump-$ZSH_VERSION"
|
compinit -d "${XDG_CACHE_HOME:-$HOME/.cache}/zsh/zcompdump-$ZSH_VERSION"
|
||||||
|
|
||||||
zstyle ':completion:*' auto-description 'specify: %d'
|
zstyle ':completion:*' auto-description 'specify: %d'
|
||||||
zstyle ':completion:*' completer _expand _complete _correct _approximate
|
zstyle ':completion:*' completer _expand _complete _correct _approximate
|
||||||
zstyle ':completion:*' format 'Completing %d'
|
zstyle ':completion:*' format 'Completing %d'
|
||||||
zstyle ':completion:*' group-name ''
|
zstyle ':completion:*' group-name ''
|
||||||
zstyle ':completion:*' menu select=2
|
zstyle ':completion:*' menu select=2
|
||||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||||
zstyle ':completion:*' list-colors ''
|
zstyle ':completion:*' list-colors ''
|
||||||
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
|
zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s
|
||||||
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
|
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*'
|
||||||
zstyle ':completion:*' menu select=long
|
zstyle ':completion:*' menu select=long
|
||||||
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
|
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
|
||||||
zstyle ':completion:*' use-compctl false
|
zstyle ':completion:*' use-compctl false
|
||||||
zstyle ':completion:*' verbose true
|
zstyle ':completion:*' verbose true
|
||||||
|
|
||||||
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'
|
||||||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
|
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
|
||||||
|
|
||||||
zstyle ':completion:*' menu select
|
zstyle ':completion:*' menu select
|
||||||
|
|
||||||
zstyle -e ':completion:*:users' users 'local user; getent passwd | while IFS=: read -rA user; do (( user[3] >= 1000 || user[3] == 0 )) && reply+=($user[1]); done'
|
zstyle -e ':completion:*:users' users 'local user; getent passwd | while IFS=: read -rA user; do (( user[3] >= 1000 || user[3] == 0 )) && reply+=($user[1]); done'
|
||||||
_comp_options+=(globdots) # Include hidden files
|
_comp_options+=(globdots) # Include hidden files
|
||||||
# Don't complete the same twice for diff/meld (http://leahneukirchen.org/dotfiles/.zshrc)
|
# Don't complete the same twice for diff/meld (http://leahneukirchen.org/dotfiles/.zshrc)
|
||||||
zstyle ':completion:*:(diff|meld):*' ignore-line yes
|
zstyle ':completion:*:(diff|meld):*' ignore-line yes
|
||||||
|
|
||||||
|
|
||||||
## Load external config files and modules
|
## Load external config files and modules
|
||||||
autoload edit-command-line; zle -N edit-command-line
|
autoload edit-command-line; zle -N edit-command-line
|
||||||
autoload zmv
|
autoload zmv
|
||||||
! alias run-help >/dev/null 2>&1 || unalias run-help
|
! alias run-help >/dev/null 2>&1 || unalias run-help
|
||||||
autoload run-help
|
autoload run-help
|
||||||
# stderred
|
# stderred
|
||||||
if [ -e "$ZSH_CONF/stderred/build/libstderred.so" ]; then
|
if [ -e "$ZSH_CONF/stderred/build/libstderred.so" ]; then
|
||||||
export LD_PRELOAD="$ZSH_CONF/stderred/build/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"
|
export LD_PRELOAD="$ZSH_CONF/stderred/build/libstderred.so${LD_PRELOAD:+:$LD_PRELOAD}"
|
||||||
export STDERRED_ESC_CODE="$(tput bold && tput setaf 1)"
|
export STDERRED_ESC_CODE="$(tput bold && tput setaf 1)"
|
||||||
export STDERRED_BLACKLIST="^(git|curl|wget|swipl)$"
|
export STDERRED_BLACKLIST="^(git|curl|wget|swipl)$"
|
||||||
fi
|
fi
|
||||||
comp-source "$ZSH_CONF/functionsPre.zsh"
|
comp-source "$ZSH_CONF/functionsPre.zsh"
|
||||||
comp-source "$ZSH_CONF/alias.zsh"
|
comp-source "$ZSH_CONF/alias.zsh"
|
||||||
comp-source "$ZSH_CONF/functionsPost.zsh"
|
comp-source "$ZSH_CONF/functionsPost.zsh"
|
||||||
comp-source "$ZSH_CONF/transfer.zsh"
|
comp-source "$ZSH_CONF/transfer.zsh"
|
||||||
comp-source "$ZSH_CONF/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
comp-source "$ZSH_CONF/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
||||||
comp-source "$ZSH_CONF/completion.zsh"
|
comp-source "$ZSH_CONF/completion.zsh"
|
||||||
# comp-source "$ZSH_CONF/zsh-async/async.zsh"
|
# comp-source "$ZSH_CONF/zsh-async/async.zsh"
|
||||||
# async_init
|
# async_init
|
||||||
### syntax-highlight > history-substring > keys
|
### syntax-highlight > history-substring > keys
|
||||||
# syntax highlighting
|
# syntax highlighting
|
||||||
if [ -e "$ZSH_CONF/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then
|
if [ -e "$ZSH_CONF/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh" ]; then
|
||||||
comp-source "$ZSH_CONF/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
comp-source "$ZSH_CONF/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
|
||||||
comp-source "$ZSH_CONF/zsh-syntax-highlighting.zsh-theme"
|
comp-source "$ZSH_CONF/zsh-syntax-highlighting.zsh-theme"
|
||||||
fi
|
fi
|
||||||
# history substr search
|
# history substr search
|
||||||
if [ -e "$ZSH_CONF/zsh-history-substring-search/zsh-history-substring-search.zsh" ]; then
|
if [ -e "$ZSH_CONF/zsh-history-substring-search/zsh-history-substring-search.zsh" ]; then
|
||||||
comp-source "$ZSH_CONF/zsh-history-substring-search/zsh-history-substring-search.zsh"
|
comp-source "$ZSH_CONF/zsh-history-substring-search/zsh-history-substring-search.zsh"
|
||||||
HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=true
|
HISTORY_SUBSTRING_SEARCH_ENSURE_UNIQUE=true
|
||||||
HISTORY_SUBSTRING_SEARCH_FUZZY=true
|
HISTORY_SUBSTRING_SEARCH_FUZZY=true
|
||||||
fi
|
fi
|
||||||
comp-source "$ZSH_CONF/keys.zsh"
|
comp-source "$ZSH_CONF/keys.zsh"
|
||||||
|
|
||||||
## Env variables that have nothing to do with zsh
|
## Env variables that have nothing to do with zsh
|
||||||
export EDITOR=nvim
|
export EDITOR=nvim
|
||||||
|
|
||||||
# `sudo nano` won't work without this (?)
|
# `sudo nano` won't work without this (?)
|
||||||
if [ "$TERM" = "xterm-kitty" ]; then
|
if [ "$TERM" = "xterm-kitty" ]; then
|
||||||
export TERM=xterm-256color
|
export TERM=xterm-256color
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## https://www.tecmint.com/view-colored-man-pages-in-linux/
|
## https://www.tecmint.com/view-colored-man-pages-in-linux/
|
||||||
## First seen in Fox Kiesters dotfiles
|
## First seen in Fox Kiesters dotfiles
|
||||||
export LESS_TERMCAP_mb=$'\e[1;32m'
|
export LESS_TERMCAP_mb=$'\e[1;32m'
|
||||||
export LESS_TERMCAP_md=$'\e[1;32m'
|
export LESS_TERMCAP_md=$'\e[1;32m'
|
||||||
export LESS_TERMCAP_me=$'\e[0m'
|
export LESS_TERMCAP_me=$'\e[0m'
|
||||||
export LESS_TERMCAP_se=$'\e[0m'
|
export LESS_TERMCAP_se=$'\e[0m'
|
||||||
export LESS_TERMCAP_so=$'\E[01;44;33m'
|
export LESS_TERMCAP_so=$'\E[01;44;33m'
|
||||||
export LESS_TERMCAP_ue=$'\e[0m'
|
export LESS_TERMCAP_ue=$'\e[0m'
|
||||||
export LESS_TERMCAP_us=$'\e[1;4;31m'
|
export LESS_TERMCAP_us=$'\e[1;4;31m'
|
||||||
|
|
||||||
## Less clutter in $HOME by enforcing the XDG base directory standard
|
## Less clutter in $HOME by enforcing the XDG base directory standard
|
||||||
export ATOM_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/atom"
|
export ATOM_HOME="${XDG_DATA_HOME:-$HOME/.local/share}/atom"
|
||||||
export GOPATH="${XDG_DATA_HOME:-$HOME/.local/share}/go"
|
export GOPATH="${XDG_DATA_HOME:-$HOME/.local/share}/go"
|
||||||
export LESSHISTFILE=-
|
export LESSHISTFILE=-
|
||||||
export SQLITE_HISTORY="${XDG_DATA_HOME:-$HOME/.local/share}/sqlite3/sqlite_history"
|
export SQLITE_HISTORY="${XDG_DATA_HOME:-$HOME/.local/share}/sqlite3/sqlite_history"
|
||||||
|
|
||||||
export ANDROID_SDK_HOME="${XDG_CONFIG_HOME:-$HOME/.config}/android"
|
export ANDROID_SDK_HOME="${XDG_CONFIG_HOME:-$HOME/.config}/android"
|
||||||
export VIMINIT='let $MYVIMRC="/home/user/.config/vim/xdg.vim" | source $MYVIMRC'
|
export VIMINIT='let $MYVIMRC="/home/user/.config/vim/xdg.vim" | source $MYVIMRC'
|
||||||
|
|
||||||
## Setup asynchronous jobs
|
## Setup asynchronous jobs
|
||||||
# async_start_worker msg_completion
|
# async_start_worker msg_completion
|
||||||
# async_job msg_completion tg-completion
|
# async_job msg_completion tg-completion
|
||||||
|
|
||||||
## Setup zle
|
## Setup zle
|
||||||
zle_highlight=('paste:none')
|
zle_highlight=('paste:none')
|
||||||
|
|
||||||
## History
|
## History
|
||||||
HISTSIZE=1000000
|
HISTSIZE=1000000
|
||||||
SAVEHIST=1000000
|
SAVEHIST=1000000
|
||||||
HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/.zsh_history"
|
HISTFILE="${XDG_DATA_HOME:-$HOME/.local/share}/zsh/.zsh_history"
|
||||||
|
|||||||
@@ -2,106 +2,106 @@
|
|||||||
## Created: 2019-01-16
|
## Created: 2019-01-16
|
||||||
|
|
||||||
## Add fslint-directory to PATH
|
## Add fslint-directory to PATH
|
||||||
PATH=$PATH:/usr/share/fslint/fslint
|
PATH=$PATH:/usr/share/fslint/fslint
|
||||||
|
|
||||||
|
|
||||||
## Add flags or shorten commands that I cannot remember
|
## Add flags or shorten commands that I cannot remember
|
||||||
alias getclip="xclip -selection c -o"
|
alias getclip="xclip -selection c -o"
|
||||||
alias setclip="perl -pe 'chomp if eof' | xclip -selection c"
|
alias setclip="perl -pe 'chomp if eof' | xclip -selection c"
|
||||||
alias pdfviewer='evince'
|
alias pdfviewer='evince'
|
||||||
alias pdf='launch evince'
|
alias pdf='launch evince'
|
||||||
alias darkpdf='launch zathura'
|
alias darkpdf='launch zathura'
|
||||||
alias geeqie='launch qeeqie'
|
alias geeqie='launch qeeqie'
|
||||||
alias grep='grep --color'
|
alias grep='grep --color'
|
||||||
alias igrep='grep -i'
|
alias igrep='grep -i'
|
||||||
alias emacs-game='emacs -batch -l dunnet'
|
alias emacs-game='emacs -batch -l dunnet'
|
||||||
alias trash-restore='restore-trash'
|
alias trash-restore='restore-trash'
|
||||||
alias cp='cp -i'
|
alias cp='cp -i'
|
||||||
alias mv='mv -i' # --backup=t ??
|
alias mv='mv -i' # --backup=t ??
|
||||||
alias rm='rm -I'
|
alias rm='rm -I'
|
||||||
alias less='less -N'
|
alias less='less -N'
|
||||||
alias lsblk='lsblk -f'
|
alias lsblk='lsblk -f'
|
||||||
alias rd='rmdir'
|
alias rd='rmdir'
|
||||||
alias md='mkdir -p'
|
alias md='mkdir -p'
|
||||||
alias o='xdg-open'
|
alias o='xdg-open'
|
||||||
alias p='pwd'
|
alias p='pwd'
|
||||||
alias :q='exit'
|
alias :q='exit'
|
||||||
alias :Q=:q
|
alias :Q=:q
|
||||||
alias update='sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y; [ ! -e /var/run/reboot-required ] || printf "\n\nSystem restart required.\n"'
|
alias update='sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y; [ ! -e /var/run/reboot-required ] || printf "\n\nSystem restart required.\n"'
|
||||||
alias pdf2text='pdftotext'
|
alias pdf2text='pdftotext'
|
||||||
alias pdf2txt='pdftotext'
|
alias pdf2txt='pdftotext'
|
||||||
alias rm='printf "\033[1;031mUse trash!\n\033[0m"; false'
|
alias rm='printf "\033[1;031mUse trash!\n\033[0m"; false'
|
||||||
alias bat='upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "to full|percentage" | tr -d " " | sed "s/:/: /"'
|
alias bat='upower -i /org/freedesktop/UPower/devices/battery_BAT0 | grep -E "to full|percentage" | tr -d " " | sed "s/:/: /"'
|
||||||
alias battery='bat'
|
alias battery='bat'
|
||||||
alias qrdecode='zbarimg'
|
alias qrdecode='zbarimg'
|
||||||
alias pdfmerge='pdfunite'
|
alias pdfmerge='pdfunite'
|
||||||
alias loadhist='fc -RI'
|
alias loadhist='fc -RI'
|
||||||
alias wget='wget --config=${XDG_CONFIG_HOME:-$HOME/.config}/wget/wgetrc --hsts-file="${XDG_DATA_HOME:-$HOME/.local/share}/wget/wget-hsts"'
|
alias wget='wget --config=${XDG_CONFIG_HOME:-$HOME/.config}/wget/wgetrc --hsts-file="${XDG_DATA_HOME:-$HOME/.local/share}/wget/wget-hsts"'
|
||||||
alias -g G='| grep '
|
alias -g G='| grep '
|
||||||
alias -g no2='2>/dev/null'
|
alias -g no2='2>/dev/null'
|
||||||
alias hex=xxd
|
alias hex=xxd
|
||||||
alias bin='xxd -b -c4 | cut -d" " -f2-5'
|
alias bin='xxd -b -c4 | cut -d" " -f2-5'
|
||||||
alias vim=nvim
|
alias vim=nvim
|
||||||
alias vi=nvim
|
alias vi=nvim
|
||||||
alias tmux='tmux -f "$HOME/.config/tmux/tmux.conf"'
|
alias tmux='tmux -f "$HOME/.config/tmux/tmux.conf"'
|
||||||
alias resetCursor='echo -ne "\e[5 q"'
|
alias resetCursor='echo -ne "\e[5 q"'
|
||||||
alias makeThisScratchpad='echo -ne "\033]0;scratchpad-terminal\007"'
|
alias makeThisScratchpad='echo -ne "\033]0;scratchpad-terminal\007"'
|
||||||
alias tmsu='tmsu -D "${XDG_DATA_HOME:-$HOME/.local/share}/tmsu/db"'
|
alias tmsu='tmsu -D "${XDG_DATA_HOME:-$HOME/.local/share}/tmsu/db"'
|
||||||
alias grepdate='grep -E "(={8})|([0-9]{4}([: -_][0-9]{2}){5})|([0-9]{8}[ -_][0-9]{6})"'
|
alias grepdate='grep -E "(={8})|([0-9]{4}([: -_][0-9]{2}){5})|([0-9]{8}[ -_][0-9]{6})"'
|
||||||
alias feh='feh -.'
|
alias feh='feh -.'
|
||||||
# 'Temporary' shell in alternate mode that does not mess with the scrollback history
|
# 'Temporary' shell in alternate mode that does not mess with the scrollback history
|
||||||
alias tmpshell='tput smcup && zsh && tput rmcup'
|
alias tmpshell='tput smcup && zsh && tput rmcup'
|
||||||
|
|
||||||
## functions
|
## functions
|
||||||
alias trash=_trash_list_default
|
alias trash=_trash_list_default
|
||||||
alias nemo=_nemo_wd_default
|
alias nemo=_nemo_wd_default
|
||||||
|
|
||||||
## git
|
## git
|
||||||
alias gs='git status --short' # overrides ghostscript
|
alias gs='git status --short' # overrides ghostscript
|
||||||
alias gits='gs'
|
alias gits='gs'
|
||||||
alias gstat='gs'
|
alias gstat='gs'
|
||||||
alias gitstat='gs'
|
alias gitstat='gs'
|
||||||
alias ga='git add'
|
alias ga='git add'
|
||||||
alias gaa='git add -A'
|
alias gaa='git add -A'
|
||||||
alias gc='git commit -m'
|
alias gc='git commit -m'
|
||||||
alias gpsh='git push'
|
alias gpsh='git push'
|
||||||
alias gpush='git push'
|
alias gpush='git push'
|
||||||
alias gpll='git pull'
|
alias gpll='git pull'
|
||||||
alias gpull='git pull'
|
alias gpull='git pull'
|
||||||
alias gdiff='git diff'
|
alias gdiff='git diff'
|
||||||
alias gd='git diff'
|
alias gd='git diff'
|
||||||
|
|
||||||
## Navigation
|
## Navigation
|
||||||
alias ls='_ls_show_hidden --color=auto --group-directories-first -p -v'
|
alias ls='_ls_show_hidden --color=auto --group-directories-first -p -v'
|
||||||
alias sl='ls'
|
alias sl='ls'
|
||||||
alias la='ls -A'
|
alias la='ls -A'
|
||||||
alias l='ls -lh --time-style=long-iso'
|
alias l='ls -lh --time-style=long-iso'
|
||||||
alias ll='l -A'
|
alias ll='l -A'
|
||||||
alias cd..='cd ..'
|
alias cd..='cd ..'
|
||||||
alias cd~='cd ~'
|
alias cd~='cd ~'
|
||||||
|
|
||||||
## Hashes for often visited folders
|
## Hashes for often visited folders
|
||||||
hash -d Desktop=$HOME/Desktop/
|
hash -d Desktop=$HOME/Desktop/
|
||||||
hash -d Documents=$HOME/Documents/
|
hash -d Documents=$HOME/Documents/
|
||||||
hash -d Pictures=$HOME/Pictures/
|
hash -d Pictures=$HOME/Pictures/
|
||||||
hash -d Downloads=$HOME/Downloads/
|
hash -d Downloads=$HOME/Downloads/
|
||||||
hash -d Projects=$HOME/Projects/
|
hash -d Projects=$HOME/Projects/
|
||||||
hash -d dot=~Projects/dotfiles/
|
hash -d dot=~Projects/dotfiles/
|
||||||
hash -d dots=~dot
|
hash -d dots=~dot
|
||||||
|
|
||||||
local UNI="$HOME/Documents/uni"
|
local UNI="$HOME/Documents/uni"
|
||||||
hash -d cheat=$HOME/Documents/Cheat\ Sheet/
|
hash -d cheat=$HOME/Documents/Cheat\ Sheet/
|
||||||
hash -d uni=$UNI/
|
hash -d uni=$UNI/
|
||||||
# hash for current/last wise
|
# hash for current/last wise
|
||||||
local YEAR=$(date +"%y")
|
local YEAR=$(date +"%y")
|
||||||
if [ -d "$UNI/$YEAR-WiSe" ]; then
|
if [ -d "$UNI/$YEAR-WiSe" ]; then
|
||||||
hash -d wise="$UNI/$YEAR-WiSe/"
|
hash -d wise="$UNI/$YEAR-WiSe/"
|
||||||
elif [ -d "$UNI/$(($YEAR - 1))-WiSe" ]; then
|
elif [ -d "$UNI/$(($YEAR - 1))-WiSe" ]; then
|
||||||
hash -d wise="$UNI/$(($YEAR - 1))-WiSe/"
|
hash -d wise="$UNI/$(($YEAR - 1))-WiSe/"
|
||||||
fi
|
fi
|
||||||
# hash for current/last sose
|
# hash for current/last sose
|
||||||
if [ -d "$UNI/$YEAR-SoSe" ]; then
|
if [ -d "$UNI/$YEAR-SoSe" ]; then
|
||||||
hash -d sose="$UNI/$YEAR-SoSe"/
|
hash -d sose="$UNI/$YEAR-SoSe"/
|
||||||
elif [ -d "$UNI/$(($YEAR - 1))-SoSe" ]; then
|
elif [ -d "$UNI/$(($YEAR - 1))-SoSe" ]; then
|
||||||
hash -d sose="$UNI/$(($YEAR - 1))-SoSe/"
|
hash -d sose="$UNI/$(($YEAR - 1))-SoSe/"
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -3,149 +3,151 @@
|
|||||||
|
|
||||||
## change into dir and print accordingly
|
## change into dir and print accordingly
|
||||||
function cl() {
|
function cl() {
|
||||||
cd "$@" && ls
|
cd "$@" && ls
|
||||||
}
|
}
|
||||||
|
|
||||||
## Copy file and append .bkp extension
|
## Copy file and append .bkp extension
|
||||||
function bkp() {
|
function bkp() {
|
||||||
for file in "$@"; do
|
for file in "$@"; do
|
||||||
cp -i "$file" "$file.bkp"
|
cp -i "$file" "$file.bkp"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
## Launches program and detaches it from the shell
|
## Launches program and detaches it from the shell
|
||||||
function launch() {
|
function launch() {
|
||||||
# eval "$@" ## does not work with special characters?
|
# eval "$@" ## does not work with special characters?
|
||||||
launch_command="$1"
|
launch_command="$1"
|
||||||
shift
|
shift
|
||||||
$launch_command "$@" &>/dev/null & disown
|
$launch_command "$@" &>/dev/null & disown
|
||||||
}
|
}
|
||||||
|
|
||||||
## Compares two pdfs based on the result of pdftotext
|
## Compares two pdfs based on the result of pdftotext
|
||||||
function pdfdiff() {
|
function pdfdiff() {
|
||||||
if [[ $# -eq 2 && -r "$1" && -r "$2" ]]; then
|
if [[ $# -eq 2 && -r "$1" && -r "$2" ]]; then
|
||||||
diff <(pdftotext "$1" -) <(pdftotext "$2" -)
|
diff <(pdftotext "$1" -) <(pdftotext "$2" -)
|
||||||
else
|
else
|
||||||
echo "something went wrong" 2>&1
|
echo "something went wrong" 2>&1
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Gets Passwd from bitwarden and copies it into the clipboard
|
## Gets Passwd from bitwarden and copies it into the clipboard
|
||||||
function bwpwd() {
|
function bwpwd() {
|
||||||
if bw "get" "password" "$@" >/dev/null; then
|
if bw "get" "password" "$@" >/dev/null; then
|
||||||
bw "get" "password" "$@" | tr -d '\n' | setclip
|
bw "get" "password" "$@" | tr -d '\n' | setclip
|
||||||
else
|
else
|
||||||
bw "get" "password" "$@"
|
bw "get" "password" "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## creates directory and changes into it
|
## creates directory and changes into it
|
||||||
function mkcd () {
|
function mkcd () {
|
||||||
mkdir "$@" # create directory
|
# Create directory
|
||||||
while [ $# -gt 1 ]; do # shift arguments if mkdir options were used
|
mkdir "$@"
|
||||||
shift
|
# shift arguments if mkdir options were used
|
||||||
done
|
while [ $# -gt 1 ]; do
|
||||||
if [ -d "$1" ]; then
|
shift
|
||||||
cd "$1"
|
done
|
||||||
pwd
|
if [ -d "$1" ]; then
|
||||||
fi
|
cd "$1"
|
||||||
|
pwd
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Send a message over telegram by using the -e flag
|
## Send a message over telegram by using the -e flag
|
||||||
function msg() {
|
function msg() {
|
||||||
if [ $# -ge 2 ]; then
|
if [ $# -ge 2 ]; then
|
||||||
telegram-cli -W -e "msg $*" | grep -E "${${*/ /.*}//_/ }"
|
telegram-cli -W -e "msg $*" | grep -E "${${*/ /.*}//_/ }"
|
||||||
# | grep -E "$(echo "$*" | sed 's/ /.*/; s/_/ /g')"
|
# | grep -E "$(echo "$*" | sed 's/ /.*/; s/_/ /g')"
|
||||||
else
|
else
|
||||||
printf "\033[1;31mPlease specify a contact and a message.\n\033[0m" >&2
|
printf "\033[1;31mPlease specify a contact and a message.\n\033[0m" >&2
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Execute tg -e command but cuts of the uninteresting parts
|
## Execute tg -e command but cuts of the uninteresting parts
|
||||||
function tg() {
|
function tg() {
|
||||||
tg="telegram-cli"
|
tg="telegram-cli"
|
||||||
if [ "$1" = "-e" ]; then
|
if [ "$1" = "-e" ]; then
|
||||||
shift
|
shift
|
||||||
$tg -N -W -e "$@" | tail -n +9 | head -n -2
|
$tg -N -W -e "$@" | tail -n +9 | head -n -2
|
||||||
else
|
else
|
||||||
$tg -N -W "$@"
|
$tg -N -W "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Encode and decode qr-codes
|
## Encode and decode qr-codes
|
||||||
function qr() {
|
function qr() {
|
||||||
if [[ $# -eq 1 && -r "$1" ]]; then
|
if [[ $# -eq 1 && -r "$1" ]]; then
|
||||||
zbarimg "$1"
|
zbarimg "$1"
|
||||||
else
|
else
|
||||||
qrencode "$@"
|
qrencode "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Edit config file
|
## Edit config file
|
||||||
function conf() {
|
function conf() {
|
||||||
# default to vim if no editor is set
|
# default to vim if no editor is set
|
||||||
local CONF_EDITOR=${EDITOR:-vim}
|
local CONF_EDITOR=${EDITOR:-vim}
|
||||||
|
|
||||||
# parse otions
|
# parse otions
|
||||||
while getopts "e:" opt 2>/dev/null; do
|
while getopts "e:" opt 2>/dev/null; do
|
||||||
case $opt in
|
case $opt in
|
||||||
e) CONF_EDITOR="$OPTARG";;
|
e) CONF_EDITOR="$OPTARG";;
|
||||||
*) printf "\033[1;31mUsage: $0 [-e <editor>] <program>[/subdirs] [<config_file>]\n\033[0m" >&2
|
*) printf "\033[1;31mUsage: $0 [-e <editor>] <program>[/subdirs] [<config_file>]\n\033[0m" >&2
|
||||||
return 1 ;;
|
return 1 ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(($OPTIND - 1 ))
|
shift $(($OPTIND - 1 ))
|
||||||
|
|
||||||
# CONF_EDITOR=( $(resolve -s $CONF_EDITOR) )
|
# CONF_EDITOR=( $(resolve -s $CONF_EDITOR) )
|
||||||
|
|
||||||
# conf needs an argument
|
# conf needs an argument
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
printf "\033[1;31mPlease specify a config.\n\033[0m" >&2
|
printf "\033[1;31mPlease specify a config.\n\033[0m" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
# search for program name in XDG_CONFIG_HOME and $HOME
|
# search for program name in XDG_CONFIG_HOME and $HOME
|
||||||
local CONF_DIR="$(_get_config_dir "$1")"
|
local CONF_DIR="$(_get_config_dir "$1")"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
printf "\033[1;31mFalling back to $HOME.\n\033[0m" >&2
|
printf "\033[1;31mFalling back to $HOME.\n\033[0m" >&2
|
||||||
CONF_DIR="$HOME"
|
CONF_DIR="$HOME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# open file with specified name if
|
# open file with specified name if
|
||||||
if [ $# -gt 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
if [ -r "$CONF_DIR/$2" ]; then
|
if [ -r "$CONF_DIR/$2" ]; then
|
||||||
$CONF_EDITOR "$CONF_DIR/$2"
|
$CONF_EDITOR "$CONF_DIR/$2"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
printf "\033[1;31mCould not find config file with that name.\n\033[0m" >&2
|
printf "\033[1;31mCould not find config file with that name.\n\033[0m" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# possible config-file names + same in hidden
|
# possible config-file names + same in hidden
|
||||||
local -a CONF_PATTERNS
|
local -a CONF_PATTERNS
|
||||||
CONF_PATTERNS=(
|
CONF_PATTERNS=(
|
||||||
"$1.conf"
|
"$1.conf"
|
||||||
"$1.config"
|
"$1.config"
|
||||||
"${1}rc"
|
"${1}rc"
|
||||||
"config"
|
"config"
|
||||||
"conf"
|
"conf"
|
||||||
"$1.yml"
|
"$1.yml"
|
||||||
"$1.yaml"
|
"$1.yaml"
|
||||||
"config.ini"
|
"config.ini"
|
||||||
"$1"
|
"$1"
|
||||||
)
|
)
|
||||||
|
|
||||||
# check if config file exists
|
# check if config file exists
|
||||||
for config in $CONF_PATTERNS; do
|
for config in $CONF_PATTERNS; do
|
||||||
if [ -r "$CONF_DIR/$config" ]; then
|
if [ -r "$CONF_DIR/$config" ]; then
|
||||||
$CONF_EDITOR "$CONF_DIR/$config"
|
$CONF_EDITOR "$CONF_DIR/$config"
|
||||||
return 0
|
return 0
|
||||||
elif [ -r "$CONF_DIR/.$config" ]; then
|
elif [ -r "$CONF_DIR/.$config" ]; then
|
||||||
$CONF_EDITOR "$CONF_DIR/.$config"
|
$CONF_EDITOR "$CONF_DIR/.$config"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# if no config was found in a location other than HOME, look again in HOME.
|
# if no config was found in a location other than HOME, look again in HOME.
|
||||||
# (For cases like default vim with ~/.vim/ and ~/.vimrc)
|
# (For cases like default vim with ~/.vim/ and ~/.vimrc)
|
||||||
@@ -159,163 +161,163 @@ function conf() {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf "\033[1;31mCould not find config file.\n\033[0m" >&2
|
printf "\033[1;31mCould not find config file.\n\033[0m" >&2
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
## Change into config dir
|
## Change into config dir
|
||||||
function c() {
|
function c() {
|
||||||
CONF_DIR="$(_get_config_dir $*)"
|
CONF_DIR="$(_get_config_dir $*)"
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
cd "$CONF_DIR"
|
cd "$CONF_DIR"
|
||||||
else
|
else
|
||||||
printf "$CONF_DIR" >&2
|
printf "$CONF_DIR" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
## Get config directory
|
## Get config directory
|
||||||
function _get_config_dir() {
|
function _get_config_dir() {
|
||||||
if [ $# -gt 1 ]; then
|
if [ $# -gt 1 ]; then
|
||||||
printf "\033[1;31mPlease specify one config.\n\033[0m" >&2
|
printf "\033[1;31mPlease specify one config.\n\033[0m" >&2
|
||||||
return 1
|
return 1
|
||||||
elif [ $# -eq 0 ]; then
|
elif [ $# -eq 0 ]; then
|
||||||
echo "${XDG_CONFIG_HOME:-$HOME/.config}"
|
echo "${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
elif [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/$1" ]; then
|
elif [ -d "${XDG_CONFIG_HOME:-$HOME/.config}/$1" ]; then
|
||||||
echo "${XDG_CONFIG_HOME:-$HOME/.config}/$1"
|
echo "${XDG_CONFIG_HOME:-$HOME/.config}/$1"
|
||||||
elif [ -d "$HOME/.$1" ]; then
|
elif [ -d "$HOME/.$1" ]; then
|
||||||
echo "$HOME/.$1"
|
echo "$HOME/.$1"
|
||||||
else
|
else
|
||||||
printf "\033[1;31mCould not find config home.\n\033[0m" >&2
|
printf "\033[1;31mCould not find config home.\n\033[0m" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Function that resolves a command to the end
|
## Function that resolves a command to the end
|
||||||
function resolve() {
|
function resolve() {
|
||||||
# TODO: comment!!
|
# TODO: comment!!
|
||||||
# In script mode only the result and its arguments are printed
|
# In script mode only the result and its arguments are printed
|
||||||
# The result can then be used directly by other scripts without further
|
# The result can then be used directly by other scripts without further
|
||||||
# manipulation
|
# manipulation
|
||||||
typeset SCRIPT_MODE VERBOSE_MODE 1>&2
|
typeset SCRIPT_MODE VERBOSE_MODE 1>&2
|
||||||
while getopts "sv" opt 2>/dev/null; do
|
while getopts "sv" opt 2>/dev/null; do
|
||||||
case $opt in
|
case $opt in
|
||||||
s) SCRIPT_MODE=1;;
|
s) SCRIPT_MODE=1;;
|
||||||
v) VERBOSE_MODE=1;;
|
v) VERBOSE_MODE=1;;
|
||||||
*) echo "Unknown flag!" >&2
|
*) echo "Unknown flag!" >&2
|
||||||
return 1;;
|
return 1;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
shift $(( $OPTIND - 1 ))
|
shift $(( $OPTIND - 1 ))
|
||||||
|
|
||||||
if (( $SCRIPT_MODE )) && (( $VERBOSE_MODE )); then
|
if (( $SCRIPT_MODE )) && (( $VERBOSE_MODE )); then
|
||||||
echo "Script and verbose mode do no work together." >&2
|
echo "Script and verbose mode do no work together." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
typeset THIS THIS_COMMAND THIS_ARGUMENTS 1>&2
|
typeset THIS THIS_COMMAND THIS_ARGUMENTS 1>&2
|
||||||
# When receiving a command with arguments, do not differ between
|
# When receiving a command with arguments, do not differ between
|
||||||
# one and multiple arguments.
|
# one and multiple arguments.
|
||||||
THIS="$*"
|
THIS="$*"
|
||||||
THIS_COMMAND="${THIS%% *}"
|
THIS_COMMAND="${THIS%% *}"
|
||||||
# ${THIS%%* } would result in THIS_COMMAND when no arguements are specified.
|
# ${THIS%%* } would result in THIS_COMMAND when no arguements are specified.
|
||||||
# We want an empty string in this case.
|
# We want an empty string in this case.
|
||||||
THIS_ARGUMENTS="${THIS#${THIS_COMMAND}}"
|
THIS_ARGUMENTS="${THIS#${THIS_COMMAND}}"
|
||||||
|
|
||||||
# Resolve all aliases
|
# Resolve all aliases
|
||||||
while [[ "$(which $THIS_COMMAND | head -n1)" =~ "^${THIS_COMMAND}: aliased to " ]]; do
|
while [[ "$(which $THIS_COMMAND | head -n1)" =~ "^${THIS_COMMAND}: aliased to " ]]; do
|
||||||
if (( $VERBOSE_MODE )); then
|
if (( $VERBOSE_MODE )); then
|
||||||
echo $THIS_COMMAND$THIS_ARGUMENTS
|
echo $THIS_COMMAND$THIS_ARGUMENTS
|
||||||
fi
|
fi
|
||||||
THIS="$(which "$THIS_COMMAND" | cut -d' ' -f4-)"
|
THIS="$(which "$THIS_COMMAND" | cut -d' ' -f4-)"
|
||||||
THIS_COMMAND="${THIS%% *}"
|
THIS_COMMAND="${THIS%% *}"
|
||||||
THIS_ARGUMENTS="${THIS#${THIS_COMMAND}}$THIS_ARGUMENTS"
|
THIS_ARGUMENTS="${THIS#${THIS_COMMAND}}$THIS_ARGUMENTS"
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
command_type="$(type $THIS_COMMAND)"
|
command_type="$(type $THIS_COMMAND)"
|
||||||
if [[ "$command_type" =~ "^$THIS_COMMAND is a shell function from " ]]; then
|
if [[ "$command_type" =~ "^$THIS_COMMAND is a shell function from " ]]; then
|
||||||
if (( $SCRIPT_MODE )); then
|
if (( $SCRIPT_MODE )); then
|
||||||
echo -n "$THIS_COMMAND$THIS_ARGUMENTS"
|
echo -n "$THIS_COMMAND$THIS_ARGUMENTS"
|
||||||
return 0
|
return 0
|
||||||
elif (( $VERBOSE_MODE )); then
|
elif (( $VERBOSE_MODE )); then
|
||||||
echo "$THIS_COMMAND$THIS_ARGUMENTS"
|
echo "$THIS_COMMAND$THIS_ARGUMENTS"
|
||||||
else
|
else
|
||||||
echo "$* is resolved to:\n$THIS_COMMAND$THIS_ARGUMENTS"
|
echo "$* is resolved to:\n$THIS_COMMAND$THIS_ARGUMENTS"
|
||||||
fi
|
fi
|
||||||
echo -n "${command_type}:"
|
echo -n "${command_type}:"
|
||||||
from_file="$(echo $command_type | cut -d' ' -f7-)"
|
from_file="$(echo $command_type | cut -d' ' -f7-)"
|
||||||
# from_file=${command_type##* }
|
# from_file=${command_type##* }
|
||||||
grep -En -m1 "(function[ \t]+${THIS_COMMAND}[ \t]*(\(\)|)[ \t]*{|${THIS_COMMAND}[ \t]*\(\)[ \t]*{)" "$from_file" \
|
grep -En -m1 "(function[ \t]+${THIS_COMMAND}[ \t]*(\(\)|)[ \t]*{|${THIS_COMMAND}[ \t]*\(\)[ \t]*{)" "$from_file" \
|
||||||
| cut -d: -f1
|
| cut -d: -f1
|
||||||
else
|
else
|
||||||
if (( $VERBOSE_MODE )); then
|
if (( $VERBOSE_MODE )); then
|
||||||
echo "$THIS_COMMAND$THIS_ARGUMENTS"
|
echo "$THIS_COMMAND$THIS_ARGUMENTS"
|
||||||
fi
|
fi
|
||||||
THIS_COMMAND="$(which $THIS_COMMAND)"
|
THIS_COMMAND="$(which $THIS_COMMAND)"
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "${THIS_COMMAND%% *} not found." >&2
|
echo "${THIS_COMMAND%% *} not found." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
if (( $VERBOSE_MODE )); then
|
if (( $VERBOSE_MODE )); then
|
||||||
echo -n "$THIS_COMMAND"
|
echo -n "$THIS_COMMAND"
|
||||||
NEXT_STEP="$(file -bh $THIS_COMMAND | cut -d' ' -f4-)"
|
NEXT_STEP="$(file -bh $THIS_COMMAND | cut -d' ' -f4-)"
|
||||||
if [ "${NEXT_STEP:0:1}" != '/' ]; then
|
if [ "${NEXT_STEP:0:1}" != '/' ]; then
|
||||||
NEXT_STEP="${THIS_COMMAND%/*}/$NEXT_STEP"
|
NEXT_STEP="${THIS_COMMAND%/*}/$NEXT_STEP"
|
||||||
fi
|
fi
|
||||||
while [[ "$(file -bh $THIS_COMMAND)" =~ "^symbolic link to" && "$NEXT_STEP" != "$THIS_COMMAND" ]]; do
|
while [[ "$(file -bh $THIS_COMMAND)" =~ "^symbolic link to" && "$NEXT_STEP" != "$THIS_COMMAND" ]]; do
|
||||||
THIS_COMMAND=$NEXT_STEP
|
THIS_COMMAND=$NEXT_STEP
|
||||||
NEXT_STEP="$(file -bh $THIS_COMMAND | cut -d' ' -f4-)"
|
NEXT_STEP="$(file -bh $THIS_COMMAND | cut -d' ' -f4-)"
|
||||||
if [ "${NEXT_STEP:0:1}" != '/' ]; then
|
if [ "${NEXT_STEP:0:1}" != '/' ]; then
|
||||||
NEXT_STEP="${THIS_COMMAND%/*}/$NEXT_STEP"
|
NEXT_STEP="${THIS_COMMAND%/*}/$NEXT_STEP"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -n "\n$THIS_COMMAND"
|
echo -n "\n$THIS_COMMAND"
|
||||||
done
|
done
|
||||||
echo $THIS_ARGUMENTS
|
echo $THIS_ARGUMENTS
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
THIS_COMMAND="$(realpath $THIS_COMMAND)"
|
THIS_COMMAND="$(realpath $THIS_COMMAND)"
|
||||||
if (( $SCRIPT_MODE )); then
|
if (( $SCRIPT_MODE )); then
|
||||||
echo -n "$THIS_COMMAND$THIS_ARGUMENTS"
|
echo -n "$THIS_COMMAND$THIS_ARGUMENTS"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
echo "$* is resolved to:\n$THIS_COMMAND$THIS_ARGUMENTS"
|
echo "$* is resolved to:\n$THIS_COMMAND$THIS_ARGUMENTS"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Grep a keyword at the beginning of a line (ignoring whitespace) in a man page
|
## Grep a keyword at the beginning of a line (ignoring whitespace) in a man page
|
||||||
function mangrep() {
|
function mangrep() {
|
||||||
mangrep_file="$1"
|
mangrep_file="$1"
|
||||||
mangrep_pattern="$2"
|
mangrep_pattern="$2"
|
||||||
shift
|
shift
|
||||||
shift
|
shift
|
||||||
man -P 'less -p "^ *'"${mangrep_pattern}\"" "$@" "${mangrep_file}"
|
man -P 'less -p "^ *'"${mangrep_pattern}\"" "$@" "${mangrep_file}"
|
||||||
unset mangrep_{file,pattern}
|
unset mangrep_{file,pattern}
|
||||||
}
|
}
|
||||||
|
|
||||||
## Grep in zsh history file
|
## Grep in zsh history file
|
||||||
function histgrep() {
|
function histgrep() {
|
||||||
grep "$@" "${HISTFILE:-$HOME/.zsh_history}"
|
grep "$@" "${HISTFILE:-$HOME/.zsh_history}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function format() {
|
function format() {
|
||||||
# TODO: respect manual changes made in meld
|
# TODO: respect manual changes made in meld
|
||||||
CLANG_FORMAT_FILE="$HOME/Projects/C/.clang.format"
|
CLANG_FORMAT_FILE="$HOME/Projects/C/.clang.format"
|
||||||
FORMAT="{$(sed -E '/^\s*$/d' "$CLANG_FORMAT_FILE" | tr '\n' ',' | sed 's/,$//')}"
|
FORMAT="{$(sed -E '/^\s*$/d' "$CLANG_FORMAT_FILE" | tr '\n' ',' | sed 's/,$//')}"
|
||||||
if [ $# -eq 1 ]; then
|
if [ $# -eq 1 ]; then
|
||||||
meld <(clang-format -style="$FORMAT" $1) $1
|
meld <(clang-format -style="$FORMAT" $1) $1
|
||||||
fi
|
fi
|
||||||
echo -n "Are you happy? [yn] "
|
echo -n "Are you happy? [yn] "
|
||||||
read yn
|
read yn
|
||||||
if [ $yn = "y" ]; then
|
if [ $yn = "y" ]; then
|
||||||
clang-format -i -style="$FORMAT" $1
|
clang-format -i -style="$FORMAT" $1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function urlenc() {
|
function urlenc() {
|
||||||
python3 -c "from urllib import parse; print(parse.quote('$@'), end='')"
|
python3 -c "from urllib import parse; print(parse.quote('$@'), end='')"
|
||||||
}
|
}
|
||||||
|
|
||||||
function urldec() {
|
function urldec() {
|
||||||
python3 -c "from urllib import parse; print(parse.unquote('$@'), end='')"
|
python3 -c "from urllib import parse; print(parse.unquote('$@'), end='')"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,43 +3,43 @@
|
|||||||
|
|
||||||
## List items in trash if no argument is specified
|
## List items in trash if no argument is specified
|
||||||
function _trash_list_default() {
|
function _trash_list_default() {
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
trash-list
|
trash-list
|
||||||
else
|
else
|
||||||
\trash "$@"
|
\trash "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## Open nemo in current directory if no argument is specified
|
## Open nemo in current directory if no argument is specified
|
||||||
function _nemo_wd_default() {
|
function _nemo_wd_default() {
|
||||||
if [ $# -eq 0 ]; then
|
if [ $# -eq 0 ]; then
|
||||||
\nemo ./
|
\nemo ./
|
||||||
else
|
else
|
||||||
\nemo "$@"
|
\nemo "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
## ls function that prints hidden files when there are no regular files
|
## ls function that prints hidden files when there are no regular files
|
||||||
## or if we are in a directory that matches the regex in LS_SHOW_ALL_DIRS
|
## or if we are in a directory that matches the regex in LS_SHOW_ALL_DIRS
|
||||||
function _ls_show_hidden() {
|
function _ls_show_hidden() {
|
||||||
# Can be overwritten by settings it before calling
|
# Can be overwritten by settings it before calling
|
||||||
local LS_SHOW_ALL_DIRS=${LS_SHOW_ALL_DIRS:-"dotfiles|\.config"}
|
local LS_SHOW_ALL_DIRS=${LS_SHOW_ALL_DIRS:-"dotfiles|\.config"}
|
||||||
|
|
||||||
# if a path is given, target will contain the given directory or the directory in which the
|
# if a path is given, target will contain the given directory or the directory in which the
|
||||||
# given file is located
|
# given file is located
|
||||||
local target
|
local target
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
if [ -d "$arg" ]; then
|
if [ -d "$arg" ]; then
|
||||||
target="$arg"
|
target="$arg"
|
||||||
break
|
break
|
||||||
elif [ -d "${arg%/*}" ]; then
|
elif [ -d "${arg%/*}" ]; then
|
||||||
target="${arg%/*}"
|
target="${arg%/*}"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
if [[ -z "$(command ls "$@")" || "$( (cd "$target"; pwd) )" =~ "${LS_SHOW_ALL_DIRS:-^$}" ]]; then
|
if [[ -z "$(command ls "$@")" || "$( (cd "$target"; pwd) )" =~ "${LS_SHOW_ALL_DIRS:-^$}" ]]; then
|
||||||
command ls -A "$@"
|
command ls -A "$@"
|
||||||
else
|
else
|
||||||
command ls "$@"
|
command ls "$@"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,74 +2,75 @@
|
|||||||
## Created: 2019-04-17
|
## Created: 2019-04-17
|
||||||
|
|
||||||
## Setup keybindings
|
## Setup keybindings
|
||||||
bindkey -v
|
bindkey -v
|
||||||
# no delay when switching into NORMAL
|
# no delay when switching into NORMAL
|
||||||
export KEYTIMEOUT=1
|
export KEYTIMEOUT=1
|
||||||
|
|
||||||
function zle-line-init zle-keymap-select {
|
function zle-line-init zle-keymap-select {
|
||||||
# Switch cursor style depending on mode
|
# Switch cursor style depending on mode
|
||||||
case $KEYMAP in
|
case $KEYMAP in
|
||||||
vicmd) echo -ne "\e[1 q";; # block
|
vicmd) echo -ne "\e[1 q";; # block
|
||||||
viins|main) echo -ne "\e[5 q";; # beam
|
viins|main) echo -ne "\e[5 q";; # beam
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Make sure that the terminal is in application mode when zle is active, since
|
# Make sure that the terminal is in application mode when zle is active, since
|
||||||
# only then values from $terminfo are valid
|
# only then values from $terminfo are valid
|
||||||
echoti smkx
|
echoti smkx
|
||||||
}
|
}
|
||||||
zle -N zle-line-init
|
zle -N zle-line-init
|
||||||
zle -N zle-keymap-select
|
zle -N zle-keymap-select
|
||||||
|
|
||||||
# See above (echoti smkx)
|
# See above (echoti smkx)
|
||||||
function zle-line-finish { echoti rmkx; }
|
function zle-line-finish { echoti rmkx; }
|
||||||
zle -N zle-line-finish
|
zle -N zle-line-finish
|
||||||
|
|
||||||
|
bindkey '^[h' run-help
|
||||||
|
|
||||||
bindkey '^[h' run-help
|
|
||||||
## History
|
## History
|
||||||
## Alternatives to check out: {up,down}-line-or-search
|
## Alternatives to check out: {up,down}-line-or-search
|
||||||
bindkey '^[[A' history-substring-search-up
|
bindkey '^[[A' history-substring-search-up
|
||||||
bindkey "$terminfo[kcuu1]" history-substring-search-up
|
bindkey "$terminfo[kcuu1]" history-substring-search-up
|
||||||
bindkey '^[[B' history-substring-search-down
|
bindkey '^[[B' history-substring-search-down
|
||||||
bindkey "$terminfo[kcud1]" history-substring-search-down
|
bindkey "$terminfo[kcud1]" history-substring-search-down
|
||||||
bindkey '^R' history-incremental-search-backward
|
bindkey '^R' history-incremental-search-backward
|
||||||
|
|
||||||
## Navigation
|
## Navigation
|
||||||
bindkey '^[[Z' reverse-menu-complete # shift-tab
|
bindkey '^[[Z' reverse-menu-complete # shift-tab
|
||||||
bindkey '^K' kill-whole-line # ctrl-K
|
bindkey '^K' kill-whole-line # ctrl-K
|
||||||
bindkey '^Q' push-input # ctrl-Q
|
bindkey '^Q' push-input # ctrl-Q
|
||||||
bindkey '\e[H' beginning-of-line # home
|
bindkey '\e[H' beginning-of-line # home
|
||||||
bindkey "$terminfo[khome]" beginning-of-line # home
|
bindkey "$terminfo[khome]" beginning-of-line # home
|
||||||
bindkey '\e[F' end-of-line # end
|
bindkey '\e[F' end-of-line # end
|
||||||
bindkey "$terminfo[kend]" end-of-line # end
|
bindkey "$terminfo[kend]" end-of-line # end
|
||||||
bindkey -v '^?' backward-delete-char # normal delete not vim-bac...
|
bindkey -v '^?' backward-delete-char # normal delete not vim-bac...
|
||||||
bindkey '^[[P' delete-char # delete
|
bindkey '^[[P' delete-char # delete
|
||||||
bindkey '^[[3~' delete-char # delete
|
bindkey '^[[3~' delete-char # delete
|
||||||
bindkey '^[[1;5D' backward-word # ctrl-left
|
bindkey '^[[1;5D' backward-word # ctrl-left
|
||||||
bindkey '^[[1;5C' forward-word # ctrl-right
|
bindkey '^[[1;5C' forward-word # ctrl-right
|
||||||
bindkey '^H' backward-kill-word # ctrl-backspace
|
bindkey '^H' backward-kill-word # ctrl-backspace
|
||||||
bindkey '^[[3;5~' kill-word # ctrl-delete
|
bindkey '^[[3;5~' kill-word # ctrl-delete
|
||||||
bindkey "$terminfo[kmous]" kill-word # ctrl-delete
|
bindkey "$terminfo[kmous]" kill-word # ctrl-delete
|
||||||
|
|
||||||
## From https://github.com/nicoulaj/dotfiles/blob/1c7dd1b621bc8bae895bafc438562482ea245d7e/.config/zsh/functions/widgets/rationalize-dots
|
## From https://github.com/nicoulaj/dotfiles/blob/1c7dd1b621bc8bae895bafc438562482ea245d7e/.config/zsh/functions/widgets/rationalize-dots
|
||||||
function _expandDots {
|
function _expandDots {
|
||||||
#[[ $LBUFFER = *.. ]] && LBUFFER+=/.. || LBUFFER+=.
|
#[[ $LBUFFER = *.. ]] && LBUFFER+=/.. || LBUFFER+=.
|
||||||
setopt localoptions nonomatch
|
setopt localoptions nonomatch
|
||||||
local MATCH dir split
|
local MATCH dir split
|
||||||
split=(${(z)LBUFFER})
|
split=(${(z)LBUFFER})
|
||||||
(( $#split > 1 )) && dir=$split[-1] || dir=$split
|
(( $#split > 1 )) && dir=$split[-1] || dir=$split
|
||||||
if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\.$' ]]; then
|
if [[ $LBUFFER =~ '(^|/| | |'$'\n''|\||;|&)\.\.$' ]]; then
|
||||||
LBUFFER+=/
|
LBUFFER+=/
|
||||||
zle self-insert
|
zle self-insert
|
||||||
zle self-insert
|
zle self-insert
|
||||||
[[ -e $dir ]] && zle -M ${dir:a:h}
|
[[ -e $dir ]] && zle -M ${dir:a:h}
|
||||||
elif [[ $LBUFFER[-1] == '.' ]]; then
|
elif [[ $LBUFFER[-1] == '.' ]]; then
|
||||||
zle self-insert
|
zle self-insert
|
||||||
[[ -e $dir ]] && zle -M ${dir:a:h}
|
[[ -e $dir ]] && zle -M ${dir:a:h}
|
||||||
else
|
else
|
||||||
zle self-insert
|
zle self-insert
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
#autoload _expandDots
|
#autoload _expandDots
|
||||||
zle -N _expandDots
|
zle -N _expandDots
|
||||||
bindkey . _expandDots
|
bindkey . _expandDots
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user