diff --git a/Xresources b/Xresources index b9f2436..6a06d00 100644 --- a/Xresources +++ b/Xresources @@ -1,4 +1,4 @@ #include ".Xresources.d/xft" -! #include ".Xresources.d/theme" +#include ".Xresources.d/theme" #include ".Xresources.d/xterm" #include ".Xresources.d/urxvt" diff --git a/Xresources.d/urxvt b/Xresources.d/urxvt index 08f7754..93c9b65 100644 --- a/Xresources.d/urxvt +++ b/Xresources.d/urxvt @@ -22,7 +22,7 @@ URxvt*scrollBar: false ! Font declaration -URxvt.font: xft:DejaVu Sans Mono for Powerline:size=12:antialias=true,xft:Symbola:size=12:antialias=true +URxvt.font: xft:DejaVu Sans Mono for Powerline:size=12:antialias=true,xft:Twemoji:size=12:antialias=true ! Font spacing URxvt.letterSpace: 0 diff --git a/bash_profile b/bash_profile deleted file mode 120000 index aa7da3a..0000000 --- a/bash_profile +++ /dev/null @@ -1 +0,0 @@ -.profile \ No newline at end of file diff --git a/bash_profile b/bash_profile new file mode 100644 index 0000000..c2a182e --- /dev/null +++ b/bash_profile @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +source ~/.config/shell/shenv +source ~/.config/shell/commonenv +source ~/.config/shell/shrc +source ~/.config/shell/commonrc +source ~/.config/shell/bashrc diff --git a/bashrc b/bashrc index b85ce1f..b666d4d 100644 --- a/bashrc +++ b/bashrc @@ -1,188 +1,5 @@ -# -# ~/.bashrc -# - -# ENVIRONMENT VARIABLES - -# Favourite commands -export PAGER=less -export EDITOR=nvim -export VISUAL=nvim -export BROWSER=qutebrowser - -# Some programs need those changes -export PATH="/usr/lib/ccache/bin/:$PATH" -if [ -d /data/data/com.termux/ ]; then - export PATH="$HOME/.termux/scripts:$HOME/.termux/bin:$PATH" -fi -#export PATH="$(echo "$PATH" | sed 's|:|\n|g' | sort | uniq | tr '\n' ':' | sed 's|:$||')" -export JAVA_FONTS=/usr/share/fonts/TTF -export ANDROID_HOME=/opt/android-sdk -export GOPATH=$HOME/.go -export PATH=$GOPATH/bin:$PATH -export XDG_CONFIG_HOME=$HOME/.config -export ARDUINO=/usr/share/arduino -export ARDUINO_DIR=$ARDUINO -export ARDMK_VENDOR=archlinux-arduino -export PYTHONSTARTUP=$HOME/.config/pythonstartup.py - -# ALIASES - -# Completion for existing commands -export LS_OPTIONS='--group-directories-first --time-style=+"%d/%m/%Y %H:%M:%S" --color=auto --file-type --human-readable' -alias ls="ls $LS_OPTIONS" -alias grep='grep --color=tty -d skip' -alias mkdir='mkdir -v' -alias cp="cp -i" -alias mv="mv -iv" -alias dd='dd status=progress' -alias rm='rm -Iv --one-file-system' -alias free='free -m' -alias df='df -h' -alias dmesg='dmesg --ctime' -alias ffmpeg='ffmpeg -hide_banner' -alias ffprobe='ffprobe -hide_banner' -alias ffplay='ffplay -hide_banner' - -# Frequent mistakes -alias sl=ls -alias al=la -alias mdkir=mkdir -alias systemclt=systemctl -alias please=sudo - -# Shortcuts for commonly used commands -alias ll="ls -l $LS_OPTIONS" -alias la="ls -la $LS_OPTIONS" -alias x='startx; logout' -alias nx='nvidia-startx; logout' -alias s='sudo -s -E' -alias tracefiles="strace -f -t -e trace=file" -alias n='urxvtc &' - -# Superseding commands with better ones if they are present -function _do_rank() { # executables... -- arguments... - for ex in "$@" - do - [ "$ex" == "--" ] && break - if which "$ex" &> /dev/null - then - for al in "$@" - do - shift - [ "$al" == "--" ] && break - alias "$al"="$ex" - done - "$ex" "$@" - return $? - fi - done - for ex in "$@" - do - [ "$al" == "--" ] && break - if -z "$list" - then - list=$ex - else - list=$list, $ex - fi - done - echo "Not installed: $list" -} - -function _install_rank() { # executables... - for ex in "$@" - do - list=$@ - alias "$ex"="_do_rank $list --" - done -} - -_install_rank nvim vim vi -_install_rank gopass pass -_install_rank wakeonlan wol -_install_rank neomutt mutt - -# SHELL CUSTOMIZATION - -complete -cf sudo - -shopt -s cdspell -shopt -s checkwinsize -shopt -s cmdhist -shopt -s dotglob -shopt -s expand_aliases -shopt -s extglob -shopt -s histappend -shopt -s hostcomplete - -export HISTSIZE=100000 -export HISTFILESIZE=${HISTSIZE} -export HISTCONTROL=ignorespace:erasedups -export HISTTIMEFORMAT="%y-%m-%d %H:%M:%S " - -# PROMPT CUSTOMIZATION - -if [[ $USER == 'root' ]]; then - col=31; -elif [[ $USER == 'geoffrey' || $USER == 'gbontoux' || $USER == 'gpreud' ]]; then - col=32; -else - col=33; -fi -export PS1="\[\e]2;\u@\h \w\a\]\[\e[0;37m\][\[\e[0;${col}m\]\u\[\e[0;37m\]@\[\e[0;34m\]\h \[\e[0;36m\]\W\[\e[0;37m\]]\$\[\e[0m\] " -export PS2="> " -export PS3="+ " -export PS4="- " -export PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}:${PWD}\007"' - -# CUSTOM SCRIPTS - -export PATH="$HOME/.local/bin/:$HOME/.scripts/:$PATH" -[ -f ~/.gscripts/gprofile ] && source ~/.gscripts/gprofile - -# UTILITIES - -# Theme -[ -f ~/.local/bin/colorSchemeApply ] && source ~/.local/bin/colorSchemeApply -[ -f ~/.local/bin/colorSchemeApplyFzf ] && source ~/.local/bin/colorSchemeApplyFzf - -# Bash completion -[ -f /etc/bash_completion ] && source /etc/bash_completion - -# Fuzzy matching all the way -export FZF_DEFAULT_OPTS="${FZF_DEFAULT_OPTS} --height 100% --layout=default" -export FZF_CTRL_T_OPTS="--preview '[[ -d {} ]] && ls -l --color=always {} || [[ \$(file --mime {}) =~ binary ]] && echo {} is a binary file || (highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500'" -export FZF_COMPLETION_OPTS="${FZF_CTRL_T_OPTS}" -[ -f /usr/share/fzf/completion.bash ] && source /usr/share/fzf/completion.bash -[ -f /usr/share/fzf/key-bindings.bash ] && source /usr/share/fzf/key-bindings.bash - -# Bad day mood-saver -function fuck { - if which thefuck &> /dev/null - then - eval $(thefuck --alias) - fuck $@ - else - echo "thefuck is not installed on this system." - fi -} -alias FUCK='fuck' - -# Node Version Manager -function nvm { - export NVM_DIR="$HOME/.nvm" - if [ -s "$NVM_DIR/nvm.sh" ] - then - . "$NVM_DIR/nvm.sh" - [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" - nvm $@ - else - echo "NVM is not installed on this system." - fi -} - -# Command not found handlers -[ -r /usr/share/doc/pkgfile/command-not-found.bash ] && . /usr/share/doc/pkgfile/command-not-found.bash # Arch -[ -r /etc/profile.d/cnf.sh ] && . /etc/profile.d/cnf.sh # Arch (alternative, for Manjaro mostly) +#!/usr/bin/env bash +source ~/.config/shell/shrc +source ~/.config/shell/commonrc +source ~/.config/shell/bashrc diff --git a/config/autorandr/bg b/config/autorandr/bg index e1bcee1..91b38c0 100644 --- a/config/autorandr/bg +++ b/config/autorandr/bg @@ -1,4 +1,4 @@ -https://i.imgur.com/yVtVucs.jpg # Doctor Who Series 11 +# https://i.imgur.com/yVtVucs.jpg # Doctor Who Series 11 # Derivate of these ones https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-230622.png # https://geoffrey.frogeye.fr/files/backgrounds/VertBleu.png -# https://geoffrey.frogeye.fr/files/backgrounds/BleuVert.png +https://geoffrey.frogeye.fr/files/backgrounds/BleuVert.png diff --git a/config/i3/config b/config/i3/config index e4cd3d7..83e57c8 100644 --- a/config/i3/config +++ b/config/i3/config @@ -38,6 +38,7 @@ bindsym $mod+z kill bindsym button2 kill bindsym $mod+c exec --no-startup-id rofi-pass --last-used +bindsym $mod+i exec --no-startup-id rofimoji --last-used bindsym $mod+plus exec --no-startup-id rofi -modi ssh -show ssh bindsym $mod+ù exec --no-startup-id rofi -modi ssh -show ssh -ssh-command '{terminal} -e {ssh-client} {host} -t "sudo -s -E"' bindsym $mod+Tab exec --no-startup-id rofi -modi window -show window @@ -50,7 +51,8 @@ bindsym $mod+Shift+d exec --no-startup-id rofi -modi drun -show drun bindsym $mod+Return exec urxvtc bindsym $mod+Shift+Return exec urxvt bindsym $mod+p exec thunar -bindsym $mod+m exec qutebrowser --override-restore --backend=webengine +# bindsym $mod+m exec qutebrowser --override-restore --backend=webengine +bindsym $mod+m exec firefox # Volume control bindsym XF86AudioRaiseVolume exec pactl set-sink-mute @DEFAULT_SINK@ false; exec pactl set-sink-volume @DEFAULT_SINK@ +5% @@ -62,17 +64,17 @@ bindsym XF86AudioPrev exec mpc prev bindsym XF86AudioPlay exec mpc toggle bindsym XF86AudioNext exec mpc next bindsym $mod+F10 exec ~/.scripts/showKeyboardLayout -bindsym $mod+F11 exec urxvtc -e 'pacmixer' -bindsym $mod+F12 exec urxvtc -e 'pacmixer' +bindsym $mod+F11 exec xterm -e 'pacmixer' +bindsym $mod+F12 exec xterm -e 'pacmixer' #Brightness control bindsym XF86MonBrightnessDown exec xbacklight -dec 5 -time 0 bindsym XF86MonBrightnessUp exec xbacklight -inc 5 -time 0 # Screenshots -bindsym Print exec scrot -ue 'mv $f ~/Screenshots/' -bindsym $mod+Print exec scrot -e 'mv $f ~/Screenshots/' -bindsym Ctrl+Print exec sleep 1 && scrot -se 'mv $f ~/Screenshots/' +bindsym Print exec scrot -ue 'mv $f ~/Screenshots/ && optipng ~/Screenshots/$f' +bindsym $mod+Print exec scrot -e 'mv $f ~/Screenshots/ && optipng ~/Screenshots/$f' +bindsym Ctrl+Print exec sleep 1 && scrot -se 'mv $f ~/Screenshots/ && optipng ~/Screenshots/$f' focus_follows_mouse no mouse_warping output @@ -303,6 +305,17 @@ mode "Resize" { bindsym $mod+r mode "Resize" +mode "Presentation" { + # These bindings trigger as soon as you enter the resize mode + bindsym e workspace back_and_forth + + # back to normal: Enter or Escape + bindsym Return mode "default" + bindsym Escape mode "default" +} + +bindsym $mod+Shift+p mode "Presentation" + set $mode_screen Screen setup [A] Auto [L] Load [S] Save [R] Remove [D] Default bindsym $mod+t mode "$mode_screen" mode "$mode_screen" { diff --git a/config/lemonbar/providers.py b/config/lemonbar/providers.py index c229607..3211264 100755 --- a/config/lemonbar/providers.py +++ b/config/lemonbar/providers.py @@ -535,7 +535,7 @@ class TaskWarriorProvider(StatefulSection, InotifyUpdater): def fetcher(self): maxi = -math.inf total = 0 - for task in self.taskw.load_tasks()['pending']: + for task in self.taskw.load_tasks('pending')['pending']: urgency = task['urgency'] if urgency > maxi: maxi = urgency diff --git a/config/shell/.gitignore b/config/shell/.gitignore new file mode 100644 index 0000000..d3e4561 --- /dev/null +++ b/config/shell/.gitignore @@ -0,0 +1,2 @@ +*.zwc +.zcompdump diff --git a/config/shell/.zprofile b/config/shell/.zprofile new file mode 100644 index 0000000..ff174ee --- /dev/null +++ b/config/shell/.zprofile @@ -0,0 +1,4 @@ +#!/usr/bin/env zsh + +source ~/.config/shell/shenv +source ~/.config/shell/commonenv diff --git a/config/shell/.zshrc b/config/shell/.zshrc new file mode 100644 index 0000000..c6a82e6 --- /dev/null +++ b/config/shell/.zshrc @@ -0,0 +1,5 @@ +#!/usr/bin/env zsh + +source ~/.config/shell/shrc +source ~/.config/shell/commonrc +source ~/.config/shell/zshrc diff --git a/config/shell/bashrc b/config/shell/bashrc new file mode 100644 index 0000000..4459546 --- /dev/null +++ b/config/shell/bashrc @@ -0,0 +1,42 @@ +#!/usr/bin/env bash + +# +# Bash aliases and customizations +# + +# Shell options + +shopt -s expand_aliases +shopt -s histappend + +HISTCONTROL=ignoreboth:erasedups + +# Prompt customization + +INTERACTIVE_BASHPID_TIMER="${HOME}/.cache/bash_timer_$$" + +PS0='$(echo $SECONDS > "$INTERACTIVE_BASHPID_TIMER")' + +function _update_ps1() { + local __ERRCODE=$? + + local __DURATION=0 + if [ -e "$INTERACTIVE_BASHPID_TIMER" ]; then + local __END=$SECONDS + local __START=$(cat "$INTERACTIVE_BASHPID_TIMER") + __DURATION="$(($__END - ${__START:-__END}))" + \rm -f "$INTERACTIVE_BASHPID_TIMER" + fi + + # echo -en "… $\r" + eval "$(powerline-go -shell bash -eval -duration $__DURATION -error $__ERRCODE "${POWERLINE_GO_DEFAULT_OPTS[@]}")" +} + +PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND" + +# Completion +trysource /usr/share/bash-completion/bash_completion + +# Fuzzy matching all the way +trysource /usr/share/fzf/completion.bash +trysource /usr/share/fzf/key-bindings.bash diff --git a/config/shell/commonenv b/config/shell/commonenv new file mode 100644 index 0000000..3da0b9c --- /dev/null +++ b/config/shell/commonenv @@ -0,0 +1,8 @@ +#!/usr/bin/env sh + +# +# Bash / ZSH common environment variables and functions +# + +export TIME_STYLE='+%Y-%m-%d %H:%M:%S' +eval $(dircolors --sh) diff --git a/config/shell/commonrc b/config/shell/commonrc new file mode 100644 index 0000000..5ec15d4 --- /dev/null +++ b/config/shell/commonrc @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +# +# Bash / ZSH aliases and customizations +# + +# Shell options + +HISTSIZE=100000 +HISTFILE="$HOME/.cache/shell_history" + +## COMMAND CONFIGURATION + +# Completion for existing commands + +alias cp="cp -i --reflink=auto" +alias grep="grep --color=tty" +alias dd='dd status=progress' +alias rm='rm -Iv --one-file-system' +alias free='free -m' +alias dmesg='dmesg --ctime' + +# [ -f ~/.local/bin/colorSchemeApplyFzf ] && . ~/.local/bin/colorSchemeApplyFzf # Only applies RGB colors... +POWERLINE_GO_DEFAULT_OPTS=(-colorize-hostname -max-width 25 -cwd-max-dir-size 10 -modules 'user,host,venv,cwd,perms,git' -modules-right 'jobs,exit,duration,load') # For reading by shell profiles +FZF_DEFAULT_OPTS="--height 40% --layout=default" +FZF_CTRL_T_OPTS="--preview '[[ -d {} ]] && ls -l --color=always {} || [[ \$(file --mime {}) =~ binary ]] && file --brief {} || (highlight -O ansi -l {} || coderay {} || rougify {} || cat {}) 2> /dev/null | head -500'" +FZF_COMPLETION_OPTS="${FZF_CTRL_T_OPTS}" + +## FUNCTIONS + +## MISC +trysource ~/.gscripts/gprofile diff --git a/config/shell/shenv b/config/shell/shenv new file mode 100644 index 0000000..3e829a8 --- /dev/null +++ b/config/shell/shenv @@ -0,0 +1,51 @@ +#!/usr/bin/env sh + +# +# Shell common environment variables and functions (BusyBox compatible) +# + +# Favourite commands +export PAGER=less +export EDITOR=nvim +export VISUAL=nvim +export BROWSER=firefox + +# Program-specific + +[ -z "$SSH_AUTH_SOCK" ] && [ -x "$(command -v ssh-agent)" ] && eval "$(ssh-agent -s)" +export GOPATH=$HOME/.cache/go +# export JAVA_FONTS=/usr/share/fonts/TTF +# export ANDROID_HOME=/opt/android-sdk +# export ARDUINO=/usr/share/arduino +# export ARDUINO_DIR=$ARDUINO +# export ARDMK_VENDOR=archlinux-arduino + +# Path + +# Function stolen from Arch Linux /etc/profile +appendpath() { + if [ ! -d "$1" ]; then + return + fi + case ":$PATH:" in + *:"$1":*) ;; + + *) + # TODO Reverse order: I want the latest ones to supersedes the older ones + export PATH="${PATH:+$PATH:}$1" + ;; + esac +} + +appendpath '/usr/lib/ccache/bin' +appendpath "$GOPATH" +appendpath "$HOME/.local/bin" +appendpath "$HOME/.scripts" + +# If running on termux, load those extra scripts +[ -d /data/data/com.termux/ ] && ( + appendpath "$HOME/.termux/scripts" + appendpath "$HOME/.termux/bin" +) + +# For superseding commands with better ones if they are present diff --git a/config/shell/shrc b/config/shell/shrc new file mode 100644 index 0000000..cf4ba75 --- /dev/null +++ b/config/shell/shrc @@ -0,0 +1,79 @@ +#!/usr/bin/env sh + +# +# Shell common aliases and customizations (BusyBox compatible) +# + +## COMMAND CONFIGURATION + +# Completion for existing commands +alias ls='ls -h --color=auto' +alias mkdir='mkdir -v' +alias cp="cp -i" +alias mv="mv -iv" +alias free='free -h' +alias df='df -h' + +alias ffmpeg='ffmpeg -hide_banner' +alias ffprobe='ffprobe -hide_banner' +alias ffplay='ffplay -hide_banner' + +# ALIASES + +# Frequent mistakes +alias sl=ls +alias al=la +alias mdkir=mkdir +alias systemclt=systemctl +alias please=sudo + +# Shortcuts for commonly used commands +alias ll="ls -l" +alias la="ls -la" +alias s='sudo -s -E' +alias n='urxvtc &' +alias x='startx; logout' +alias nx='nvidia-xrun; logout' + +# FUNCTIONS +trysource() { + if [ -f "$1" ] + then + . "$1" + else + return 1 + fi +} + +_i_prefer() { # executables... + for candidate in "$@" + do + if [ -x "$(command -v "$candidate")" ] + then + choice="$candidate" + break + fi + done + if [ -z "$choice" ] + then + return + fi + for candidate in "$@" + do + if [ "$candidate" != "$choice" ] + then + alias "$candidate"="$choice" + fi + done +} +_i_prefer nvim vim vi +_i_prefer gopass pass +_i_prefer wakeonlan wol +_i_prefer neomutt mutt +unset _i_prefer + +## COLORS + +trysource ~/.local/bin/colorSchemeApply +# Needed because xterm/urxvt won't use the last color, needed for vim + diff --git a/config/shell/zshrc b/config/shell/zshrc new file mode 100644 index 0000000..3382a09 --- /dev/null +++ b/config/shell/zshrc @@ -0,0 +1,200 @@ +#!/usr/bin/env zsh + +# +# ZSH aliases and customizations +# + +# TODO Learn `setopt extendedglob` +# TODO Add asdf (oh-my-zsh plugin is air, git clone is the way (aur package outdated)) + +# Approximate RGB colors by terminal colors +[[ "$COLORTERM" == (24bit|truecolor) || "${terminfo[colors]}" -eq '16777216' ]] || zmodload zsh/nearcolor + +# Plugins +ADOTDIR=~/.cache/antigen +mkdir -p $ADOTDIR +typeset -a ANTIGEN_CHECK_FILES=(~/.config/shell/zshrc) + +[ -f ~/.local/share/zsh/antigen.zsh ] || (mkdir -p ~/.local/share/zsh/ && curl -L git.io/antigen > ~/.local/share/zsh/antigen.zsh) +source ~/.local/share/zsh/antigen.zsh + +# This is better to have them installed as system since we can use them as root +# pacman -S zsh-autosuggestions zsh-history-substring-search zsh-syntax-highlighting zsh-completions --needed +function plugin() { + if [ -d "/usr/share/licenses/$2" ] + then + trysource "/usr/share/zsh/plugins/$2/$2.zsh" + # It's ok if it fails + else + antigen bundle "$1/$2" + fi +} +plugin zsh-users zsh-completions +plugin zsh-users zsh-syntax-highlighting +plugin zsh-users zsh-autosuggestions +plugin zsh-users zsh-history-substring-search +antigen apply + + +# Prompt customization +zmodload zsh/datetime + +function preexec() { + __TIMER=$EPOCHREALTIME +} + +function powerline_precmd() { + local __ERRCODE=$? + local __DURATION=0 + + if [ -n $__TIMER ]; then + local __ERT=$EPOCHREALTIME + __DURATION="$(($__ERT - ${__TIMER:-__ERT}))" + fi + + # echo -en "… $\r" + eval "$(powerline-go -shell zsh -eval -duration $__DURATION -error $__ERRCODE "${POWERLINE_GO_DEFAULT_OPTS[@]}")" + unset __TIMER +} + +function install_powerline_precmd() { + for s in "${precmd_functions[@]}"; do + if [ "$s" = "powerline_precmd" ]; then + return + fi + done + precmd_functions+=(powerline_precmd) +} + +install_powerline_precmd + +# Cursor based on mode +if [ $TERM = "linux" ]; then + _LINE_CURSOR="\e[?0c" + _BLOCK_CURSOR="\e[?8c" +else + _LINE_CURSOR="\e[6 q" + _BLOCK_CURSOR="\e[2 q" +fi +function zle-keymap-select zle-line-init +{ + case $KEYMAP in + vicmd) print -n -- "$_BLOCK_CURSOR";; + viins|main) print -n -- "$_LINE_CURSOR";; + esac + + # zle reset-prompt + # zle -R +} + +function zle-line-finish +{ + print -n -- "$_BLOCK_CURSOR" +} + +zle -N zle-line-init +zle -N zle-line-finish +zle -N zle-keymap-select + +# Should I really put a comment to explain what this does? +bindkey 'jk' vi-cmd-mode + +# Edit command line +autoload edit-command-line +zle -N edit-command-line +bindkey -M vicmd v edit-command-line + +# History search +# bind UP and DOWN arrow keys +zmodload zsh/terminfo +bindkey "$terminfo[kcuu1]" history-substring-search-up +bindkey "$terminfo[kcud1]" history-substring-search-down + +# bind UP and DOWN arrow keys (compatibility fallback +# for Ubuntu 12.04, Fedora 21, and MacOSX 10.9 users) +bindkey '^[[A' history-substring-search-up +bindkey '^[[B' history-substring-search-down + +# bind P and N for EMACS mode +bindkey -M emacs '^P' history-substring-search-up +bindkey -M emacs '^N' history-substring-search-down + +# bind k and j for VI mode +bindkey -M vicmd 'k' history-substring-search-up +bindkey -M vicmd 'j' history-substring-search-down + +# Autocompletion +autoload -Uz promptinit +promptinit + +# Color common prefix +zstyle -e ':completion:*:default' list-colors 'reply=("${PREFIX:+=(#bi)($PREFIX:t)(?)*==35=00}:${(s.:.)LS_COLORS}")' + +setopt GLOBDOTS # Complete hidden files + +setopt NO_BEEP # that annoying beep goes away +# setopt NO_LIST_BEEP # beeping is only turned off for ambiguous completions +setopt AUTO_LIST # when the completion is ambiguous you get a list without having to type ^D +# setopt BASH_AUTO_LIST # the list only happens the second time you hit tab on an ambiguous completion +# setopt LIST_AMBIGUOUS # this is modified so that nothing is listed if there is an unambiguous prefix or suffix to be inserted --- this can be combined with BASH_AUTO_LIST, so that where both are applicable you need to hit tab three times for a listing +unsetopt REC_EXACT # if the string on the command line exactly matches one of the possible completions, it is accepted, even if there is another completion (i.e. that string with something else added) that also matches +unsetopt MENU_COMPLETE # one completion is always inserted completely, then when you hit TAB it changes to the next, and so on until you get back to where you started +unsetopt AUTO_MENU # you only get the menu behaviour when you hit TAB again on the ambiguous completion. +unsetopt AUTO_REMOVE_SLASH + +# Fuzzy matching all the way +# trysource /usr/share/fzf/completion.zsh +trysource /usr/share/fzf/key-bindings.zsh + +# Help +# TODO Doesn't work (how ironic) +autoload -Uz run-help +unalias run-help +alias help=run-help +autoload -Uz run-help-git +autoload -Uz run-help-ip +autoload -Uz run-help-openssl +autoload -Uz run-help-p4 +autoload -Uz run-help-sudo +autoload -Uz run-help-svk +autoload -Uz run-help-svn + +# Dir stack +DIRSTACKFILE="$HOME/.cache/zsh/dirs" +if [[ -f $DIRSTACKFILE ]] && [[ $#dirstack -eq 0 ]]; then + dirstack=( ${(f)"$(< $DIRSTACKFILE)"} ) + # [[ -d $dirstack[1] ]] && cd $dirstack[1] +fi +chpwd() { + print -l $PWD ${(u)dirstack} >$DIRSTACKFILE +} + +DIRSTACKSIZE=100 + +setopt AUTO_PUSHD PUSHD_SILENT PUSHD_TO_HOME +setopt PUSHD_IGNORE_DUPS # Remove duplicate entries +setopt PUSHD_MINUS # This reverts the +/- operators. + + +# Command not found +# (since we have syntax highlighting we are not forced to wait to see that we typed crap) +trysource /usr/share/doc/pkgfile/command-not-found.zsh + +# History + +# From https://unix.stackexchange.com/a/273863 +SAVEHIST=$HISTSIZE +setopt BANG_HIST # Treat the '!' character specially during expansion. +unsetopt EXTENDED_HISTORY # Write the history file in the ":start:elapsed;command" format. +setopt INC_APPEND_HISTORY # Write to the history file immediately, not when the shell exits. +setopt SHARE_HISTORY # Share history between all sessions. +setopt HIST_EXPIRE_DUPS_FIRST # Expire duplicate entries first when trimming history. +setopt HIST_IGNORE_DUPS # Don't record an entry that was just recorded again. +setopt HIST_IGNORE_ALL_DUPS # Delete old recorded entry if new entry is a duplicate. +setopt HIST_FIND_NO_DUPS # Do not display a line previously found. +setopt HIST_IGNORE_SPACE # Don't record an entry starting with a space. +setopt HIST_SAVE_NO_DUPS # Don't write duplicate entries in the history file. +setopt HIST_REDUCE_BLANKS # Remove superfluous blanks before recording entry. +unsetopt HIST_VERIFY # Don't execute immediately upon history expansion. +unsetopt HIST_BEEP # Beep when accessing nonexistent history. + diff --git a/config/systemd/user/default.target.wants/psd.service b/config/systemd/user/default.target.wants/psd.service deleted file mode 120000 index 6f74548..0000000 --- a/config/systemd/user/default.target.wants/psd.service +++ /dev/null @@ -1 +0,0 @@ -/usr/lib/systemd/user/psd.service \ No newline at end of file diff --git a/config/systemd/user/x0vncserver.service b/config/systemd/user/x0vncserver.service new file mode 100644 index 0000000..5c06eb8 --- /dev/null +++ b/config/systemd/user/x0vncserver.service @@ -0,0 +1,13 @@ +[Unit] +Description=Remote desktop service (VNC) + +[Service] +Type=simple +# wait for Xorg started by ${USER} +ExecStartPre=/bin/sh -c 'while ! pgrep -U "$USER" Xorg; do sleep 2; done' +ExecStart=/usr/bin/x0vncserver -rfbauth /home/${USER}/.vnc/passwd +# or login with your username & password +#ExecStart=/usr/bin/x0vncserver -PAMService=login -PlainUsers=${USER} -SecurityTypes=TLSPlain + +[Install] +WantedBy=default.target diff --git a/config/vdirsyncer/config b/config/vdirsyncer/config index 7ef5e40..0f6f246 100644 --- a/config/vdirsyncer/config +++ b/config/vdirsyncer/config @@ -43,7 +43,7 @@ fileext = ".vcf" [storage geoffrey_contacts_remote] type = "carddav" -url = "https://dav.frogeye.fr/caldav.php/" +url = "https://cloud.frogeye.fr/remote.php/dav" username = "geoffrey" password.fetch = ["command", "sh", "-c", "cat ~/.config/vdirsyncer/pass"] @@ -65,6 +65,6 @@ fileext = ".ics" [storage geoffrey_calendar_remote] type = "caldav" -url = "https://dav.frogeye.fr/caldav.php/" +url = "https://cloud.frogeye.fr/remote.php/dav" username = "geoffrey" password.fetch = ["command", "sh", "-c", "cat ~/.config/vdirsyncer/pass"] diff --git a/gitignore b/gitignore index 55b5b75..05df6db 100644 --- a/gitignore +++ b/gitignore @@ -1,3 +1,4 @@ *.swp *.swo *.ycm_extra_conf.py +tags diff --git a/go b/go deleted file mode 120000 index 3f37a1f..0000000 --- a/go +++ /dev/null @@ -1 +0,0 @@ -.cache/go \ No newline at end of file diff --git a/inputrc b/inputrc index bb2af3c..0a994f6 100644 --- a/inputrc +++ b/inputrc @@ -1,7 +1,8 @@ $include /etc/inputrc set bell-style none +set colored-completion-prefix on +set colored-stats on set completion-ignore-case on -set completion-prefix-display-length 4 set completion-query-items 200 set editing-mode vi set history-preserve-point on @@ -11,25 +12,37 @@ set mark-directories on set mark-modified-lines off set mark-symlinked-directories on set match-hidden-files on +set menu-complete-display-prefix on set page-completions on -set print-completions-horizontally on +set print-completions-horizontally off set revert-all-at-newline off set show-all-if-ambiguous on set show-all-if-unmodified on +set show-mode-in-prompt on set skip-completed-text on -set visible-stats on +set visible-stats off $if mode=vi + # these are for vi-command mode set keymap vi-command - # these are for vi-command mode - "\e[A": history-search-backward - "\e[B": history-search-forward - Control-l: clear-screen + "\e[A": history-search-backward + "\e[B": history-search-forward + Control-l: clear-screen + + # these are for vi-insert mode set keymap vi-insert - # these are for vi-insert mode - "jk": vi-movement-mode - "\e[A": history-search-backward - "\e[B": history-search-forward - Control-l: clear-screen + "jk": vi-movement-mode + "\e[A": history-search-backward + "\e[B": history-search-forward + Control-l: clear-screen + + # Switch between thin cursor and thicc block depending on vi mode + $if term=linux + set vi-ins-mode-string \1\e[?0c\2 + set vi-cmd-mode-string \1\e[?8c\2 + $else + set vi-ins-mode-string \1\e[6 q\2 + set vi-cmd-mode-string \1\e[2 q\2 + $endif $endif diff --git a/profile b/profile index 27e9836..664271f 100644 --- a/profile +++ b/profile @@ -1,9 +1,4 @@ -# -# ~/.profile -# +#!/usr/bin/env sh -# SSH agent -[[ -z "$SSH_AUTH_SOCK" && -x "$(which ssh-agent)" ]] && eval `ssh-agent -s` &> /dev/null - -# Bashrc -[ -f ~/.bashrc ] && source ~/.bashrc +. ~/.config/shell/shenv +. ~/.config/shell/shrc diff --git a/scripts/beep b/scripts/beep index 15bfa68..5cd87e2 100755 --- a/scripts/beep +++ b/scripts/beep @@ -1,2 +1,3 @@ #!/usr/bin/env sh play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null +# echo  diff --git a/scripts/changeColors b/scripts/changeColors index e80fd4a..9abb14b 100755 --- a/scripts/changeColors +++ b/scripts/changeColors @@ -41,6 +41,9 @@ curl "https://raw.githubusercontent.com/theova/base16-qutebrowser/master/themes/ # TODO highlight (there IS a template but the colors look different from vim and mostly the same from when there's no config) # Reload a bunch of things to make changes immediate -source ~/.bashrc -xrdb -load ~/.Xresources -i3-msg reload +~/.local/bin/colorSchemeApply +~/.local/bin/colorSchemeApplyFzf +# Error masking in case X not running +xrdb -load ~/.Xresources 2> /dev/null +i3-msg reload 2> /dev/null + diff --git a/scripts/install-prefs b/scripts/install-prefs index 38f2c27..8b50453 100755 --- a/scripts/install-prefs +++ b/scripts/install-prefs @@ -233,8 +233,8 @@ if [ $GUI == 1 ]; then # Desktop manager inst dunst feh i3-wm i3lock numlockx qutebrowser rofi rxvt-unicode scrot trayer unclutter xautolock xclip if [ $ARCH == 1 ]; then - inst xorg-xinit xorg-xbacklight ttf-dejavu - altInst lemonbar-xft-git autorandr-git keynav-enhanced pacmixer rofi-pass + inst xorg-xinit xorg-xbacklight ttf-dejavu autorandr + altInst lemonbar-xft-git keynav-enhanced pacmixer rofi-pass elif [ $DEBIAN == 1 ]; then # TODO autorandr pacmixer rofi-pass ttf-dejavu inst lemonbar keynav xbacklight diff --git a/scripts/machines b/scripts/machines index fbc6b51..209f9cb 100755 --- a/scripts/machines +++ b/scripts/machines @@ -7,14 +7,15 @@ MACHINES_HOME=$HOME MACHINES_CONFIG=$HOME/.config/machines MACHINES_API=https://machines.frogeye.fr -mkdir -p $MACHINES_HOME &> /dev/null -mkdir -p $MACHINES_CONFIG &> /dev/null +mkdir -p "$MACHINES_HOME" &> /dev/null +mkdir -p "$MACHINES_CONFIG" &> /dev/null # COMMON function prompt { # text - while true; do - read -p "$1 [yn] " yn + while true + do + read -r -p "$1 [yn] " yn case $yn in [Yy]* ) return 1;; [Nn]* ) return 0;; @@ -32,7 +33,7 @@ urlencode() { # string for (( i = 0; i < length; i++ )); do local c="${1:i:1}" case $c in - [a-zA-Z0-9.~_-]) printf "$c" ;; + [a-zA-Z0-9.~_-]) printf "%s" "$c" ;; *) printf '%%%02X' "'$c" ;; esac done @@ -49,7 +50,7 @@ urldecode() { # string function _machines-api { route=$1 shift - wget $MACHINES_API/$route --content-on-error --quiet --output-document=- "$@" + wget "$MACHINES_API/$route" --content-on-error --quiet --output-document=- "$@" result=$? if [ $result != 0 ]; then echo "[ERROR] wget returned $result for route $route" 1>&2; @@ -58,53 +59,53 @@ function _machines-api { } function _machines-apiToken { - read -p 'TOTP token: ' token + read -r -p 'TOTP token: ' token _machines-api "$@" --header="X-TOTP: $token" } function _machines-apiSigned { _machines-ensureAdmin - _machines-api "$@" --certificate=$MACHINES_CONFIG/machines.crt --private-key=$MACHINES_CONFIG/machines.key + _machines-api "$@" --certificate="$MACHINES_CONFIG/machines.crt" --private-key="$MACHINES_CONFIG/machines.key" } # APPLICATION KEYS & CERTIFICATE function _machines-pubFromCrt { - openssl x509 -in $MACHINES_CONFIG/machines.crt -pubkey -noout > $MACHINES_CONFIG/machines.pub + openssl x509 -in "$MACHINES_CONFIG/machines.crt" -pubkey -noout > "$MACHINES_CONFIG/machines.pub" } function _machines-verifyCertificate { return - if openssl verify $MACHINES_CONFIG/machines.crt | grep -v 'error 18' | grep 'error' --quiet; then + if openssl verify "$MACHINES_CONFIG/machines.crt" | grep -v 'error 18' | grep 'error' --quiet; then echo "[ERROR] Invalid certificate" 1>&2; exit 1 fi } function _machines-ensurePub { - if [ ! -f $MACHINES_CONFIG/machines.crt ]; then + if [ ! -f "$MACHINES_CONFIG/machines.crt" ]; then CERT_FILE=$(mktemp) echo "[INFO] Downloading certificate..." - _machines-api cert > $CERT_FILE - openssl x509 -fingerprint -in $CERT_FILE | grep Fingerprint --color=never + _machines-api cert > "$CERT_FILE" + openssl x509 -fingerprint -in "$CERT_FILE" | grep Fingerprint --color=never prompt "Is this correct ?" if [ $? == 1 ]; then - mv $CERT_FILE $MACHINES_CONFIG/machines.crt &> /dev/null + mv "$CERT_FILE" "$MACHINES_CONFIG/machines.crt" &> /dev/null else echo "[ERROR] Certificate rejected." 1>&2; exit 1 fi fi _machines-verifyCertificate - if [ ! -f $MACHINES_CONFIG/machines.pub ]; then + if [ ! -f "$MACHINES_CONFIG/machines.pub" ]; then _machines-pubFromCrt fi return 0 } function _machines-ensureAdmin { - if [ ! -f $MACHINES_CONFIG/machines.key ]; then + if [ ! -f "$MACHINES_CONFIG/machines.key" ]; then echo "[ERROR] You need have to have the private key to do that" 1>&2; exit 1 fi @@ -115,52 +116,52 @@ function _machines-ensureAdmin { function _machines-signAkey { # network KEY_FILE=$(mktemp) SIGN_FILE=$(mktemp) - _machines-apiSigned akey/$1?unsigned > $KEY_FILE - openssl dgst -sha256 -sign $MACHINES_CONFIG/machines.key -out $SIGN_FILE $KEY_FILE - _machines-apiSigned akey/$1 --method=PUT --body-file=$SIGN_FILE - rm $KEY_FILE $SIGN_FILE &> /dev/null + _machines-apiSigned "akey/$1?unsigned" > "$KEY_FILE" + openssl dgst -sha256 -sign "$MACHINES_CONFIG/machines.key" -out "$SIGN_FILE" "$KEY_FILE" + _machines-apiSigned "akey/$1" --method=PUT --body-file="$SIGN_FILE" + rm "$KEY_FILE" "$SIGN_FILE" &> /dev/null } function _machines-getAkey { # network _machines-ensurePub KEY_FILE=$(mktemp) SIGN_FILE=$(mktemp) - _machines-api akey/$1 > $KEY_FILE - _machines-api akey/$1?signature > $SIGN_FILE - md5sum $KEY_FILE &1>&2; - md5sum $SIGN_FILE &1>&2; - md5sum $MACHINES_CONFIG/machines.pub &1>&2; + _machines-api "akey/$1" > "$KEY_FILE" + _machines-api "akey/$1?signature" > "$SIGN_FILE" + md5sum "$KEY_FILE" 1>&2; + md5sum "$SIGN_FILE" 1>&2; + md5sum "$MACHINES_CONFIG/machines.pub" 1>&2; - openssl dgst -sha256 -verify $MACHINES_CONFIG/machines.pub -signature $SIGN_FILE $KEY_FILE &> /dev/null - if [ $? == 0 ]; then - cat $KEY_FILE - rm $KEY_FILE $SIGN_FILE &> /dev/null + if openssl dgst -sha256 -verify "$MACHINES_CONFIG/machines.pub" -signature "$SIGN_FILE" "$KEY_FILE" &> /dev/null + then + cat "$KEY_FILE" + \rm "$KEY_FILE" "$SIGN_FILE" return 0 else - rm $KEY_FILE $SIGN_FILE &> /dev/null + \rm "$KEY_FILE" "$SIGN_FILE" exit 1 fi } function _machines-updateAkey { MYKEY_FILE=$(mktemp) - network=$(cat $MACHINES_CONFIG/this | grep '^network=' | cut -d '=' -f 2) - _machines-getAkey $network > "$MYKEY_FILE" - if [ $? == 0 ]; then - yes | mv $MYKEY_FILE $MACHINES_HOME/.ssh/authorized_keys &> /dev/null + network=$(grep '^network=' "$MACHINES_CONFIG/this" | cut -d '=' -f 2) + if _machines-getAkey "$network" > "$MYKEY_FILE" + then + \mv -f "$MYKEY_FILE" "$MACHINES_HOME/.ssh/authorized_keys" return 0 else - cat $MYKEY_FILE + cat "$MYKEY_FILE" echo "[ERROR] Authorized keys are not properly signed" 1>&2; - rm $MYKEY_FILE + \rm "$MYKEY_FILE" exit 1 fi } function _machines-postFile { # filename - cat $1 | while read line; do - parameter=$(echo $line | cut -d '=' -f 1) - value="$(echo $line | sed 's/^[a-zA-Z0-9]\+\(\[\]\)\?=//')" + cat $1 | while read -r line; do + parameter=$(echo "$line" | cut -d '=' -f 1) + value="$(echo "$line" | sed 's/^[a-zA-Z0-9]\+\(\[\]\)\?=//')" echo -n "&$parameter=$(urlencode "$value")" done } @@ -168,44 +169,47 @@ function _machines-postFile { # filename function _machines-addElement { # element elementType default FILE=$(mktemp) - echo -e $3 > $FILE - $EDITOR $FILE - data=$(_machines-postFile $FILE) - rm $FILE &> /dev/null - _machines-apiSigned $2 --post-data "name=$1$data" + echo -e "$3" > "$FILE" + $EDITOR "$FILE" + data=$(_machines-postFile "$FILE") + \rm "$FILE" + _machines-apiSigned "$2" --post-data "name=$1$data" +} + +function _machines-viewElement { # element elementType + _machines-apiSigned "$2/$1" } function _machines-editElement { # element elementType FILE=$(mktemp) - _machines-apiSigned $2/$1 > $FILE - $EDITOR $FILE - data=$(_machines-postFile $FILE) - rm $FILE &> /dev/null - err=$(_machines-apiSigned $2/$1 --post-data "$data") + _machines-apiSigned "$2/$1" > "$FILE" + $EDITOR "$FILE" + data=$(_machines-postFile "$FILE") + rm "$FILE" &> /dev/null + err=$(_machines-apiSigned "$2/$1" --post-data "$data") } function _machines-deleteElement { # element elementType - err=$(_machines-apiSigned $2/$1 --method=DELETE) + err=$(_machines-apiSigned "$2/$1" --method=DELETE) } # USER ADMIN FUNCTIONS function machines_history { - if [ -f $MACHINES_CONFIG/lastVerifiedLog ]; then + if [ -f "$MACHINES_CONFIG/lastVerifiedLog" ]; then from=$(<"$MACHINES_CONFIG/lastVerifiedLog") else from=0 fi d=$(date +%s) _machines-apiSigned log?from=$from | less - prompt "Is this OK?" - if [ $? == 1 ]; then - echo $d > $MACHINES_CONFIG/lastVerifiedLog - return 0 - else - echo "Houston, we have a problem..." + if prompt "Is this OK?" + then exit 1 + else + echo "$d" > "$MACHINES_CONFIG/lastVerifiedLog" + return 0 fi } @@ -213,7 +217,7 @@ function machines_sign { machines_history echo "Signing default network authorized_keys..." _machines-signAkey - _machines-apiSigned network | while read network; do + _machines-apiSigned network | while read -r network; do echo "Signing network $network authorized_keys..." _machines-signAkey $network done @@ -235,11 +239,11 @@ function machines_machine_add_help { return 0 } function machines_machine_add { # machine - if [ -z $1 ]; then + if [ -z "$1" ]; then machines_machine_add_help exit 1 fi - _machines-addElement $1 machine "host[]=\nnetwork=\nuserkey=\nhostkey=\nuser=" + _machines-addElement "$1" machine "host[]=\nnetwork=\nuserkey=\nhostkey=\nuser=" } function machines_network_add_help { @@ -249,42 +253,75 @@ function machines_network_add_help { echo " NETWORK Network to add" return 0 } + function machines_network_add { # network - if [ -z $1 ]; then + if [ -z "$1" ]; then machines_network_add_help exit 1 fi - _machines-addElement $1 network "allowed[]=\nsecure=false" + _machines-addElement "$1" network "allowed[]=\nsecure=false" +} + +function machines_machine_view_help { + echo "Usage: $0 machine|mac|m view MACHINE" + echo + echo "Arguments:" + echo " MACHINE machine to view" + return 0 +} + +function machines_machine_view { # machine + if [ -z "$1" ]; then + machines_machine_view_help + exit 1 + fi + _machines-viewElement "$1" machine +} + +function machines_network_view_help { + echo "Usage: $0 network|net|n view NETWORK" + echo + echo "Arguments:" + echo " NETWORK Network to view" + return 0 +} +function machines_network_view { # network + if [ -z "$1" ]; then + machines_network_view_help + exit 1 + fi + _machines-viewElement "$1" network } function machines_machine_edit_help { echo "Usage: $0 machine|mac|m edit MACHINE" echo echo "Arguments:" - echo " MACHINE machine to remove" + echo " MACHINE machine to edit" return 0 } + function machines_machine_edit { # machine - if [ -z $1 ]; then + if [ -z "$1" ]; then machines_machine_edit_help exit 1 fi - _machines-editElement $1 machine + _machines-editElement "$1" machine } function machines_network_edit_help { echo "Usage: $0 network|net|n edit NETWORK" echo echo "Arguments:" - echo " NETWORK Network to remove" + echo " NETWORK Network to edit" return 0 } function machines_network_edit { # network - if [ -z $1 ]; then + if [ -z "$1" ]; then machines_network_edit_help exit 1 fi - _machines-editElement $1 network + _machines-editElement "$1" network } function machines_machine_delete_help { @@ -295,11 +332,11 @@ function machines_machine_delete_help { return 0 } function machines_machine_delete { # machine - if [ -z $1 ]; then + if [ -z "$1" ]; then machines_machine_delete_help exit 1 fi - _machines-deleteElement $1 machine + _machines-deleteElement "$1" machine } function machines_network_delete_help { @@ -310,11 +347,11 @@ function machines_network_delete_help { return 0 } function machines_network_delete { # network - if [ -z $1 ]; then + if [ -z "$1" ]; then machines_network_delete_help exit 1 fi - _machines-deleteElement $1 network + _machines-deleteElement "$1" network } function machines_machine_help { @@ -323,6 +360,7 @@ function machines_machine_help { echo "Commands:" echo " list List all machines" echo " add Interactively add a machine" + echo " view Display a machine" echo " edit Interactively edit a specified machine" echo " delete Remove a specified machine" echo " help Get help with commands" @@ -344,6 +382,7 @@ function machines_network_help { echo "Commands:" echo " list List all networks" echo " add Interactively add a network" + echo " view Display a network" echo " edit Interactively edit a specified network" echo " delete Remove a specified network" echo " help Get help with commands" @@ -369,10 +408,9 @@ machines_net_help() { machines_network_help "$@"; } machines_n_help() { machines_network_help "$@"; } function machines_update-all { - machines_machine_list | while read machine; do + machines_machine_list | while read -r machine; do echo "Updating $machine..." - ssh $machine 'machines update' & - ssh $machine 'cd .dotfiles && git pull' & + ssh "$machine" 'cd .dotfiles && git pull; machines update' & done } @@ -381,10 +419,10 @@ function machines_regen-keys { echo "[ERROR] Please delete the pem files manually to prove you know what you're doing." 1>&2; exit 1 else - openssl genrsa -out $MACHINES_CONFIG/machines.key 4096 - chmod 600 $MACHINES_CONFIG/machines.key - openssl req -key $MACHINES_CONFIG/machines.key -new -out $MACHINES_CONFIG/machines.csr - openssl x509 -req -days 1826 -in $MACHINES_CONFIG/machines.csr -signkey $MACHINES_CONFIG/machines.key -out $MACHINES_CONFIG/machines.crt + openssl genrsa -out "$MACHINES_CONFIG/machines.key" 4096 + chmod 600 "$MACHINES_CONFIG/machines.key" + openssl req -key "$MACHINES_CONFIG/machines.key" -new -out "$MACHINES_CONFIG/machines.csr" + openssl x509 -req -days 1826 -in "$MACHINES_CONFIG/machines.csr" -signkey "$MACHINES_CONFIG/machines.key" -out "$MACHINES_CONFIG/machines.crt" _machines-pubFromCrt fi } @@ -393,7 +431,7 @@ function machines_regen-keys { # USER FUNCTIONS function machines_setup { - if [ -e $MACHINES_CONFIG/this.name ]; then + if [ -e "$MACHINES_CONFIG/this.name" ]; then echo "[ERROR] This machine is already set up" 1>&2; exit 1 fi @@ -401,13 +439,13 @@ function machines_setup { _machines-ensurePub # Variables - read -p 'Machine name? ' name - read -p 'Hosts (separated by spaces)? ' hosts + read -r -p 'Machine name? ' name + read -r -p 'Hosts (separated by spaces)? ' hosts # User key - mkdir -p $MACHINES_HOME/.ssh &> /dev/null + mkdir -p "$MACHINES_HOME/.ssh" &> /dev/null if [[ ! -f $MACHINES_HOME/.ssh/id_rsa || ! -f $MACHINES_HOME/.ssh/id_rsa.pub ]]; then - ssh-keygen -b 4096 -C "$name@machines.frogeye.fr" -f $MACHINES_HOME/.ssh/id_rsa -t rsa + ssh-keygen -b 4096 -C "$name@machines.frogeye.fr" -f "$MACHINES_HOME/.ssh/id_rsa" -t rsa fi userkey=$(<"$MACHINES_HOME/.ssh/id_rsa.pub") @@ -427,12 +465,12 @@ function machines_setup { _machines-apiToken machine --post-data "$data" - echo $name > $MACHINES_CONFIG/this.name + echo "$name" > "$MACHINES_CONFIG/this.name" machines_update } function machines_update { - _machines-api machine/$(cat $MACHINES_CONFIG/this.name) > $MACHINES_CONFIG/this + _machines-api "machine/$(cat "$MACHINES_CONFIG/this.name")" > "$MACHINES_CONFIG/this" _machines-updateAkey } @@ -475,5 +513,5 @@ shift if type "machines_$command" &> /dev/null; then "machines_$command" "$@" else - machines_help + machines_help "$@" fi diff --git a/scripts/pw b/scripts/pw new file mode 100755 index 0000000..3bd63fe --- /dev/null +++ b/scripts/pw @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +# Generate strong enough password(s) + +# This generates a password with ln((26*2+10)**32)/ln(2) ≅ 190 bits of entropy, +# which is a bit above the recommended standars (128 bits) while still having +# a 0 probability that the service will break because of incompatible character + +pwgen 32 -s diff --git a/scripts/ter b/scripts/ter new file mode 100755 index 0000000..6185e9f --- /dev/null +++ b/scripts/ter @@ -0,0 +1,65 @@ +#!/usr/bin/env python3 + +import sys +from math import inf + +gares = sys.argv[1:] + +N = len(gares) + +if N < 2: + print("Ben reste chez toi alors.") + sys.exit(1) + +def trajet_str(a, b): + return f"{gares[a]} → {gares[b]}" + +def chemin_str(stack): + return ", ".join([trajet_str(stack[i], stack[i+1]) for i in range(len(stack)-1)]) + +# Demande des prix des trajets + +prices = dict() + +for i in range(N): + for j in range(N-1, i, -1): + p = None + while not isinstance(p, float): + try: + p = float(input(f"Prix du trajet {trajet_str(i, j)} ? ").replace(',', '.')) + except ValueError: + print("C'est pas un prix ça !") + if i not in prices: + prices[i] = dict() + prices[i][j] = float(p) + +# Calcul des prix des chemins + +miniPrice = +inf +miniStack = None +maxiPrice = -inf +maxiStack = None + +def register_path(stack): + price = sum([prices[stack[i]][stack[i+1]]for i in range(len(stack)-1)]) + + global miniPrice, maxiPrice, miniStack, maxiStack + if price < miniPrice: + miniPrice = price + miniStack = stack.copy() + if price > maxiPrice: + maxiPrice = price + maxiStack = stack.copy() + print(f"{chemin_str(stack)} = {price:.2f} €") + +stack = [0] +while stack[0] == 0: + if stack[-1] >= N - 1: + register_path(stack) + stack.pop() + stack[-1] += 1 + else: + stack.append(stack[-1]+1) + +print(f"Prix minimum: {chemin_str(miniStack)} = {miniPrice:.2f} €") +print(f"Prix maximum: {chemin_str(maxiStack)} = {maxiPrice:.2f} €") diff --git a/scripts/totask b/scripts/totask new file mode 100755 index 0000000..841595d --- /dev/null +++ b/scripts/totask @@ -0,0 +1,21 @@ +#!/usr/bin/env python3 + +import taskw +import sys + +tw = taskw.TaskWarrior() + +total = 0 +number = 0 +statuses = set() +for task in tw._get_task_objects(*sys.argv[1:], 'export'): + statuses.add(task['status']) + if task['status'] not in {'pending', 'waiting'}: + continue + urgency = task['urgency'] + if urgency <= 0: + continue + total += urgency + number += 1 + +print(f"Σ{total:.3f} #{number}") diff --git a/scripts/tracefiles b/scripts/tracefiles new file mode 100755 index 0000000..c123783 --- /dev/null +++ b/scripts/tracefiles @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +strace -f -t -e trace=file diff --git a/scripts/unziptree b/scripts/unziptree index d109c0b..5cf5ab9 100755 --- a/scripts/unziptree +++ b/scripts/unziptree @@ -6,7 +6,19 @@ import subprocess for root, dirs, files in os.walk("."): for name in files: base, ext = os.path.splitext(name) - if ext.lower() != ".zip": + if name.endswith(".zip"): + cmd = ["unzip"] + elif name.endswith(".7z"): + cmd = ["7z", "e"] + elif name.endswith(".rar"): + cmd = ["unrar", "x"] + elif name.endswith('.tar'): + cmd = ["tar", "xf"] + elif name.endswith('.tar.gz'): + cmd = ["tar", "xzf"] + elif name.endswith('.tar.xz'): + cmd = ["tar", "xJf"] + else: continue filepath = os.path.join(root, name) @@ -15,7 +27,7 @@ for root, dirs, files in os.walk("."): os.mkdir(dirpath) - cmd = ["unzip", os.path.realpath(filepath)] + cmd.append(os.path.realpath(filepath)) r = subprocess.run(cmd, cwd=dirpath) r.check_returncode() diff --git a/scripts/updateCompressedMusic b/scripts/updateCompressedMusic index 6fb60cc..fa5517e 100755 --- a/scripts/updateCompressedMusic +++ b/scripts/updateCompressedMusic @@ -14,7 +14,7 @@ SOURCE_FOLDER = os.path.join(os.path.expanduser("~"), "Musiques") OUTPUT_FOLDER = os.path.join(os.path.expanduser("~"), ".musicCompressed") CONVERSIONS = {"flac": "opus"} FORBIDDEN_EXTENSIONS = ["jpg", "pdf", "ffs_db"] -FORGIVEN_FILENAMES = ["cover.jpg"] +FORGIVEN_FILENAMES = ["cover.jpg", "front.jpg"] IGNORED_EMPTY_FOLDER = [".stfolder"] # TODO FEAT Make the directory structure the same as the base one and diff --git a/tmux.conf b/tmux.conf new file mode 100644 index 0000000..78b7ec0 --- /dev/null +++ b/tmux.conf @@ -0,0 +1,11 @@ +# List of plugins +set -g @plugin 'tmux-plugins/tpm' +set -g @plugin 'tmux-plugins/tmux-sensible' + +set -g @plugin 'jimeh/tmux-themepack' +set -g @themepack 'powerline/block/green' + +set-environment -g TMUX_PLUGIN_MANAGER_PATH '~/.cache/tmuxplugins/' + +# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf) +run -b '~/.cache/tmuxplugins/tpm/tpm' diff --git a/vimrc b/vimrc index 9ee290a..9d17254 100644 --- a/vimrc +++ b/vimrc @@ -31,11 +31,10 @@ Plug 'vim-airline/vim-airline' Plug 'vim-airline/vim-airline-themes' Plug 'airblade/vim-gitgutter' Plug 'mbbill/undotree' -Plug 'xolox/vim-misc' " Required for 'xolox/vim-easytags' -Plug 'xolox/vim-easytags' +Plug 'ludovicchabant/vim-gutentags' Plug 'majutsushi/tagbar' Plug 'wellle/targets.vim' -Plug 'Chiel92/vim-autoformat' +" Plug 'Chiel92/vim-autoformat' Plug 'tomtom/tcomment_vim' " Plug 'Shougo/denite.nvim' " Plug 'tomlion/vim-solidity' @@ -43,16 +42,16 @@ Plug 'tomtom/tcomment_vim' " Plug 'jrozner/vim-antlr' " " Plug 'maralla/completor.vim' -if has('nvim') - Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } -else - Plug 'Shougo/deoplete.nvim' - Plug 'roxma/nvim-yarp' - Plug 'roxma/vim-hug-neovim-rpc' -endif -Plug 'zchee/deoplete-jedi' +" if has('nvim') +" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } +" else +" Plug 'Shougo/deoplete.nvim' +" Plug 'roxma/nvim-yarp' +" Plug 'roxma/vim-hug-neovim-rpc' +" endif +" Plug 'zchee/deoplete-jedi' -Plug 'python-mode/python-mode', { 'branch': 'develop' } +" Plug 'python-mode/python-mode', { 'branch': 'develop' } Plug 'junegunn/fzf', {'do': './install --bin'} Plug 'junegunn/fzf.vim' Plug 'ervandew/supertab' @@ -60,12 +59,19 @@ Plug 'dpelle/vim-LanguageTool' Plug 'terryma/vim-smooth-scroll' Plug 'vim-pandoc/vim-pandoc' Plug 'vim-pandoc/vim-pandoc-syntax' +Plug 'idanarye/vim-vebugger' +Plug 'w0rp/ale' call plug#end() -""" COMPLETOR """ +""" ALE """ -let g:deoplete#enable_at_startup = 1 +nmap :ALEFix + +let g:ale_sign_error = '×' +let g:ale_sign_warning = '!' +let g:ale_completion_enabled = 1 +let g:ale_fixers = ['shfmt', 'uncrustify', 'remove_trailing_lines', 'trim_whitespace'] """ UNDOTREE """ @@ -87,27 +93,11 @@ let g:airline_section_a = airline#section#create(['mode']) let g:airline_section_b = airline#section#create(['branch', 'hunks']) " let g:airline_section_z = airline#section#create(['%B', '@', '%l', ':', '%c']) let g:airline_theme = 'base16_monokai' - -""" AUTOFORMAT """ -nmap :Autoformat - -""" PYMODE """ - -let g:pymode_virtualenv = 1 -let g:pymode_lint_ignore = ["W0401"] -let g:pymode_lint_cwindow = 0 -let g:pymode_lint_on_fly = 1 -" let g:pymode_lint_checkers = ['pyflakes', 'pep8', 'mccabe'] -let g:pymode_lint_checkers = ['pyflakes', 'mccabe'] -" Pymode temporarly disabled for battle dev - -" TODO Even with magic pymod_motion complains about the option `magic&` being not set :/ -let g:pymode_motion = 0 -set magic +let g:airline#extensions#ale#enabled = 1 """ FZF """ -let g:fzf_layout = { 'down': '~100%' } +let g:fzf_layout = { 'down': '~40%' } let g:fzf_colors = \ { 'fg': ['fg', 'Normal'], \ 'bg': ['bg', 'Normal'], diff --git a/zshenv b/zshenv new file mode 100644 index 0000000..f78ec50 --- /dev/null +++ b/zshenv @@ -0,0 +1,3 @@ +#!/usr/bin/env zsh + +ZDOTDIR=~/.config/shell