Merge branch 'master' of frogit:geoffrey/dotfiles
This commit is contained in:
commit
bda0ee2263
|
@ -1,4 +1,4 @@
|
||||||
#include ".Xresources.d/xft"
|
#include ".Xresources.d/xft"
|
||||||
! #include ".Xresources.d/theme"
|
#include ".Xresources.d/theme"
|
||||||
#include ".Xresources.d/xterm"
|
#include ".Xresources.d/xterm"
|
||||||
#include ".Xresources.d/urxvt"
|
#include ".Xresources.d/urxvt"
|
||||||
|
|
|
@ -22,7 +22,7 @@ URxvt*scrollBar: false
|
||||||
|
|
||||||
|
|
||||||
! Font declaration
|
! 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
|
! Font spacing
|
||||||
URxvt.letterSpace: 0
|
URxvt.letterSpace: 0
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
.profile
|
|
7
bash_profile
Normal file
7
bash_profile
Normal file
|
@ -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
|
191
bashrc
191
bashrc
|
@ -1,188 +1,5 @@
|
||||||
#
|
#!/usr/bin/env bash
|
||||||
# ~/.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)
|
|
||||||
|
|
||||||
|
source ~/.config/shell/shrc
|
||||||
|
source ~/.config/shell/commonrc
|
||||||
|
source ~/.config/shell/bashrc
|
||||||
|
|
|
@ -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
|
# 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/VertBleu.png
|
||||||
# https://geoffrey.frogeye.fr/files/backgrounds/BleuVert.png
|
https://geoffrey.frogeye.fr/files/backgrounds/BleuVert.png
|
||||||
|
|
|
@ -38,6 +38,7 @@ bindsym $mod+z kill
|
||||||
bindsym button2 kill
|
bindsym button2 kill
|
||||||
|
|
||||||
bindsym $mod+c exec --no-startup-id rofi-pass --last-used
|
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+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+ù 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
|
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+Return exec urxvtc
|
||||||
bindsym $mod+Shift+Return exec urxvt
|
bindsym $mod+Shift+Return exec urxvt
|
||||||
bindsym $mod+p exec thunar
|
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
|
# Volume control
|
||||||
bindsym XF86AudioRaiseVolume exec pactl set-sink-mute @DEFAULT_SINK@ false; exec pactl set-sink-volume @DEFAULT_SINK@ +5%
|
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 XF86AudioPlay exec mpc toggle
|
||||||
bindsym XF86AudioNext exec mpc next
|
bindsym XF86AudioNext exec mpc next
|
||||||
bindsym $mod+F10 exec ~/.scripts/showKeyboardLayout
|
bindsym $mod+F10 exec ~/.scripts/showKeyboardLayout
|
||||||
bindsym $mod+F11 exec urxvtc -e 'pacmixer'
|
bindsym $mod+F11 exec xterm -e 'pacmixer'
|
||||||
bindsym $mod+F12 exec urxvtc -e 'pacmixer'
|
bindsym $mod+F12 exec xterm -e 'pacmixer'
|
||||||
|
|
||||||
#Brightness control
|
#Brightness control
|
||||||
bindsym XF86MonBrightnessDown exec xbacklight -dec 5 -time 0
|
bindsym XF86MonBrightnessDown exec xbacklight -dec 5 -time 0
|
||||||
bindsym XF86MonBrightnessUp exec xbacklight -inc 5 -time 0
|
bindsym XF86MonBrightnessUp exec xbacklight -inc 5 -time 0
|
||||||
|
|
||||||
# Screenshots
|
# Screenshots
|
||||||
bindsym Print exec scrot -ue 'mv $f ~/Screenshots/'
|
bindsym Print exec scrot -ue 'mv $f ~/Screenshots/ && optipng ~/Screenshots/$f'
|
||||||
bindsym $mod+Print exec scrot -e 'mv $f ~/Screenshots/'
|
bindsym $mod+Print exec scrot -e 'mv $f ~/Screenshots/ && optipng ~/Screenshots/$f'
|
||||||
bindsym Ctrl+Print exec sleep 1 && scrot -se 'mv $f ~/Screenshots/'
|
bindsym Ctrl+Print exec sleep 1 && scrot -se 'mv $f ~/Screenshots/ && optipng ~/Screenshots/$f'
|
||||||
|
|
||||||
focus_follows_mouse no
|
focus_follows_mouse no
|
||||||
mouse_warping output
|
mouse_warping output
|
||||||
|
@ -303,6 +305,17 @@ mode "Resize" {
|
||||||
|
|
||||||
bindsym $mod+r 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
|
set $mode_screen Screen setup [A] Auto [L] Load [S] Save [R] Remove [D] Default
|
||||||
bindsym $mod+t mode "$mode_screen"
|
bindsym $mod+t mode "$mode_screen"
|
||||||
mode "$mode_screen" {
|
mode "$mode_screen" {
|
||||||
|
|
|
@ -535,7 +535,7 @@ class TaskWarriorProvider(StatefulSection, InotifyUpdater):
|
||||||
def fetcher(self):
|
def fetcher(self):
|
||||||
maxi = -math.inf
|
maxi = -math.inf
|
||||||
total = 0
|
total = 0
|
||||||
for task in self.taskw.load_tasks()['pending']:
|
for task in self.taskw.load_tasks('pending')['pending']:
|
||||||
urgency = task['urgency']
|
urgency = task['urgency']
|
||||||
if urgency > maxi:
|
if urgency > maxi:
|
||||||
maxi = urgency
|
maxi = urgency
|
||||||
|
|
2
config/shell/.gitignore
vendored
Normal file
2
config/shell/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*.zwc
|
||||||
|
.zcompdump
|
4
config/shell/.zprofile
Normal file
4
config/shell/.zprofile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
source ~/.config/shell/shenv
|
||||||
|
source ~/.config/shell/commonenv
|
5
config/shell/.zshrc
Normal file
5
config/shell/.zshrc
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env zsh
|
||||||
|
|
||||||
|
source ~/.config/shell/shrc
|
||||||
|
source ~/.config/shell/commonrc
|
||||||
|
source ~/.config/shell/zshrc
|
42
config/shell/bashrc
Normal file
42
config/shell/bashrc
Normal file
|
@ -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
|
8
config/shell/commonenv
Normal file
8
config/shell/commonenv
Normal file
|
@ -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)
|
32
config/shell/commonrc
Normal file
32
config/shell/commonrc
Normal file
|
@ -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
|
51
config/shell/shenv
Normal file
51
config/shell/shenv
Normal file
|
@ -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
|
79
config/shell/shrc
Normal file
79
config/shell/shrc
Normal file
|
@ -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
|
||||||
|
|
200
config/shell/zshrc
Normal file
200
config/shell/zshrc
Normal file
|
@ -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.
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
/usr/lib/systemd/user/psd.service
|
|
13
config/systemd/user/x0vncserver.service
Normal file
13
config/systemd/user/x0vncserver.service
Normal file
|
@ -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
|
|
@ -43,7 +43,7 @@ fileext = ".vcf"
|
||||||
|
|
||||||
[storage geoffrey_contacts_remote]
|
[storage geoffrey_contacts_remote]
|
||||||
type = "carddav"
|
type = "carddav"
|
||||||
url = "https://dav.frogeye.fr/caldav.php/"
|
url = "https://cloud.frogeye.fr/remote.php/dav"
|
||||||
username = "geoffrey"
|
username = "geoffrey"
|
||||||
password.fetch = ["command", "sh", "-c", "cat ~/.config/vdirsyncer/pass"]
|
password.fetch = ["command", "sh", "-c", "cat ~/.config/vdirsyncer/pass"]
|
||||||
|
|
||||||
|
@ -65,6 +65,6 @@ fileext = ".ics"
|
||||||
|
|
||||||
[storage geoffrey_calendar_remote]
|
[storage geoffrey_calendar_remote]
|
||||||
type = "caldav"
|
type = "caldav"
|
||||||
url = "https://dav.frogeye.fr/caldav.php/"
|
url = "https://cloud.frogeye.fr/remote.php/dav"
|
||||||
username = "geoffrey"
|
username = "geoffrey"
|
||||||
password.fetch = ["command", "sh", "-c", "cat ~/.config/vdirsyncer/pass"]
|
password.fetch = ["command", "sh", "-c", "cat ~/.config/vdirsyncer/pass"]
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
*.swp
|
*.swp
|
||||||
*.swo
|
*.swo
|
||||||
*.ycm_extra_conf.py
|
*.ycm_extra_conf.py
|
||||||
|
tags
|
||||||
|
|
37
inputrc
37
inputrc
|
@ -1,7 +1,8 @@
|
||||||
$include /etc/inputrc
|
$include /etc/inputrc
|
||||||
set bell-style none
|
set bell-style none
|
||||||
|
set colored-completion-prefix on
|
||||||
|
set colored-stats on
|
||||||
set completion-ignore-case on
|
set completion-ignore-case on
|
||||||
set completion-prefix-display-length 4
|
|
||||||
set completion-query-items 200
|
set completion-query-items 200
|
||||||
set editing-mode vi
|
set editing-mode vi
|
||||||
set history-preserve-point on
|
set history-preserve-point on
|
||||||
|
@ -11,25 +12,37 @@ set mark-directories on
|
||||||
set mark-modified-lines off
|
set mark-modified-lines off
|
||||||
set mark-symlinked-directories on
|
set mark-symlinked-directories on
|
||||||
set match-hidden-files on
|
set match-hidden-files on
|
||||||
|
set menu-complete-display-prefix on
|
||||||
set page-completions on
|
set page-completions on
|
||||||
set print-completions-horizontally on
|
set print-completions-horizontally off
|
||||||
set revert-all-at-newline off
|
set revert-all-at-newline off
|
||||||
set show-all-if-ambiguous on
|
set show-all-if-ambiguous on
|
||||||
set show-all-if-unmodified on
|
set show-all-if-unmodified on
|
||||||
|
set show-mode-in-prompt on
|
||||||
set skip-completed-text on
|
set skip-completed-text on
|
||||||
set visible-stats on
|
set visible-stats off
|
||||||
|
|
||||||
$if mode=vi
|
$if mode=vi
|
||||||
|
# these are for vi-command mode
|
||||||
set keymap vi-command
|
set keymap vi-command
|
||||||
# these are for vi-command mode
|
"\e[A": history-search-backward
|
||||||
"\e[A": history-search-backward
|
"\e[B": history-search-forward
|
||||||
"\e[B": history-search-forward
|
Control-l: clear-screen
|
||||||
Control-l: clear-screen
|
|
||||||
|
# these are for vi-insert mode
|
||||||
set keymap vi-insert
|
set keymap vi-insert
|
||||||
# these are for vi-insert mode
|
"jk": vi-movement-mode
|
||||||
"jk": vi-movement-mode
|
"\e[A": history-search-backward
|
||||||
"\e[A": history-search-backward
|
"\e[B": history-search-forward
|
||||||
"\e[B": history-search-forward
|
Control-l: clear-screen
|
||||||
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
|
$endif
|
||||||
|
|
||||||
|
|
11
profile
11
profile
|
@ -1,9 +1,4 @@
|
||||||
#
|
#!/usr/bin/env sh
|
||||||
# ~/.profile
|
|
||||||
#
|
|
||||||
|
|
||||||
# SSH agent
|
. ~/.config/shell/shenv
|
||||||
[[ -z "$SSH_AUTH_SOCK" && -x "$(which ssh-agent)" ]] && eval `ssh-agent -s` &> /dev/null
|
. ~/.config/shell/shrc
|
||||||
|
|
||||||
# Bashrc
|
|
||||||
[ -f ~/.bashrc ] && source ~/.bashrc
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
#!/usr/bin/env sh
|
#!/usr/bin/env sh
|
||||||
play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null
|
play -n synth sine E5 sine A4 remix 1-2 fade 0.5 1.2 0.5 2> /dev/null
|
||||||
|
# echo
|
||||||
|
|
|
@ -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)
|
# 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
|
# Reload a bunch of things to make changes immediate
|
||||||
source ~/.bashrc
|
~/.local/bin/colorSchemeApply
|
||||||
xrdb -load ~/.Xresources
|
~/.local/bin/colorSchemeApplyFzf
|
||||||
i3-msg reload
|
# Error masking in case X not running
|
||||||
|
xrdb -load ~/.Xresources 2> /dev/null
|
||||||
|
i3-msg reload 2> /dev/null
|
||||||
|
|
||||||
|
|
|
@ -233,8 +233,8 @@ if [ $GUI == 1 ]; then
|
||||||
# Desktop manager
|
# Desktop manager
|
||||||
inst dunst feh i3-wm i3lock numlockx qutebrowser rofi rxvt-unicode scrot trayer unclutter xautolock xclip
|
inst dunst feh i3-wm i3lock numlockx qutebrowser rofi rxvt-unicode scrot trayer unclutter xautolock xclip
|
||||||
if [ $ARCH == 1 ]; then
|
if [ $ARCH == 1 ]; then
|
||||||
inst xorg-xinit xorg-xbacklight ttf-dejavu
|
inst xorg-xinit xorg-xbacklight ttf-dejavu autorandr
|
||||||
altInst lemonbar-xft-git autorandr-git keynav-enhanced pacmixer rofi-pass
|
altInst lemonbar-xft-git keynav-enhanced pacmixer rofi-pass
|
||||||
elif [ $DEBIAN == 1 ]; then
|
elif [ $DEBIAN == 1 ]; then
|
||||||
# TODO autorandr pacmixer rofi-pass ttf-dejavu
|
# TODO autorandr pacmixer rofi-pass ttf-dejavu
|
||||||
inst lemonbar keynav xbacklight
|
inst lemonbar keynav xbacklight
|
||||||
|
|
212
scripts/machines
212
scripts/machines
|
@ -7,14 +7,15 @@ MACHINES_HOME=$HOME
|
||||||
MACHINES_CONFIG=$HOME/.config/machines
|
MACHINES_CONFIG=$HOME/.config/machines
|
||||||
MACHINES_API=https://machines.frogeye.fr
|
MACHINES_API=https://machines.frogeye.fr
|
||||||
|
|
||||||
mkdir -p $MACHINES_HOME &> /dev/null
|
mkdir -p "$MACHINES_HOME" &> /dev/null
|
||||||
mkdir -p $MACHINES_CONFIG &> /dev/null
|
mkdir -p "$MACHINES_CONFIG" &> /dev/null
|
||||||
|
|
||||||
# COMMON
|
# COMMON
|
||||||
|
|
||||||
function prompt { # text
|
function prompt { # text
|
||||||
while true; do
|
while true
|
||||||
read -p "$1 [yn] " yn
|
do
|
||||||
|
read -r -p "$1 [yn] " yn
|
||||||
case $yn in
|
case $yn in
|
||||||
[Yy]* ) return 1;;
|
[Yy]* ) return 1;;
|
||||||
[Nn]* ) return 0;;
|
[Nn]* ) return 0;;
|
||||||
|
@ -32,7 +33,7 @@ urlencode() { # string
|
||||||
for (( i = 0; i < length; i++ )); do
|
for (( i = 0; i < length; i++ )); do
|
||||||
local c="${1:i:1}"
|
local c="${1:i:1}"
|
||||||
case $c in
|
case $c in
|
||||||
[a-zA-Z0-9.~_-]) printf "$c" ;;
|
[a-zA-Z0-9.~_-]) printf "%s" "$c" ;;
|
||||||
*) printf '%%%02X' "'$c" ;;
|
*) printf '%%%02X' "'$c" ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -49,7 +50,7 @@ urldecode() { # string
|
||||||
function _machines-api {
|
function _machines-api {
|
||||||
route=$1
|
route=$1
|
||||||
shift
|
shift
|
||||||
wget $MACHINES_API/$route --content-on-error --quiet --output-document=- "$@"
|
wget "$MACHINES_API/$route" --content-on-error --quiet --output-document=- "$@"
|
||||||
result=$?
|
result=$?
|
||||||
if [ $result != 0 ]; then
|
if [ $result != 0 ]; then
|
||||||
echo "[ERROR] wget returned $result for route $route" 1>&2;
|
echo "[ERROR] wget returned $result for route $route" 1>&2;
|
||||||
|
@ -58,53 +59,53 @@ function _machines-api {
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-apiToken {
|
function _machines-apiToken {
|
||||||
read -p 'TOTP token: ' token
|
read -r -p 'TOTP token: ' token
|
||||||
_machines-api "$@" --header="X-TOTP: $token"
|
_machines-api "$@" --header="X-TOTP: $token"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-apiSigned {
|
function _machines-apiSigned {
|
||||||
_machines-ensureAdmin
|
_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
|
# APPLICATION KEYS & CERTIFICATE
|
||||||
|
|
||||||
function _machines-pubFromCrt {
|
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 {
|
function _machines-verifyCertificate {
|
||||||
return
|
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;
|
echo "[ERROR] Invalid certificate" 1>&2;
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-ensurePub {
|
function _machines-ensurePub {
|
||||||
if [ ! -f $MACHINES_CONFIG/machines.crt ]; then
|
if [ ! -f "$MACHINES_CONFIG/machines.crt" ]; then
|
||||||
CERT_FILE=$(mktemp)
|
CERT_FILE=$(mktemp)
|
||||||
echo "[INFO] Downloading certificate..."
|
echo "[INFO] Downloading certificate..."
|
||||||
_machines-api cert > $CERT_FILE
|
_machines-api cert > "$CERT_FILE"
|
||||||
openssl x509 -fingerprint -in $CERT_FILE | grep Fingerprint --color=never
|
openssl x509 -fingerprint -in "$CERT_FILE" | grep Fingerprint --color=never
|
||||||
prompt "Is this correct ?"
|
prompt "Is this correct ?"
|
||||||
if [ $? == 1 ]; then
|
if [ $? == 1 ]; then
|
||||||
mv $CERT_FILE $MACHINES_CONFIG/machines.crt &> /dev/null
|
mv "$CERT_FILE" "$MACHINES_CONFIG/machines.crt" &> /dev/null
|
||||||
else
|
else
|
||||||
echo "[ERROR] Certificate rejected." 1>&2;
|
echo "[ERROR] Certificate rejected." 1>&2;
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
_machines-verifyCertificate
|
_machines-verifyCertificate
|
||||||
if [ ! -f $MACHINES_CONFIG/machines.pub ]; then
|
if [ ! -f "$MACHINES_CONFIG/machines.pub" ]; then
|
||||||
_machines-pubFromCrt
|
_machines-pubFromCrt
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-ensureAdmin {
|
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;
|
echo "[ERROR] You need have to have the private key to do that" 1>&2;
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -115,52 +116,52 @@ function _machines-ensureAdmin {
|
||||||
function _machines-signAkey { # network
|
function _machines-signAkey { # network
|
||||||
KEY_FILE=$(mktemp)
|
KEY_FILE=$(mktemp)
|
||||||
SIGN_FILE=$(mktemp)
|
SIGN_FILE=$(mktemp)
|
||||||
_machines-apiSigned akey/$1?unsigned > $KEY_FILE
|
_machines-apiSigned "akey/$1?unsigned" > "$KEY_FILE"
|
||||||
openssl dgst -sha256 -sign $MACHINES_CONFIG/machines.key -out $SIGN_FILE $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
|
_machines-apiSigned "akey/$1" --method=PUT --body-file="$SIGN_FILE"
|
||||||
rm $KEY_FILE $SIGN_FILE &> /dev/null
|
rm "$KEY_FILE" "$SIGN_FILE" &> /dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-getAkey { # network
|
function _machines-getAkey { # network
|
||||||
_machines-ensurePub
|
_machines-ensurePub
|
||||||
KEY_FILE=$(mktemp)
|
KEY_FILE=$(mktemp)
|
||||||
SIGN_FILE=$(mktemp)
|
SIGN_FILE=$(mktemp)
|
||||||
_machines-api akey/$1 > $KEY_FILE
|
_machines-api "akey/$1" > "$KEY_FILE"
|
||||||
_machines-api akey/$1?signature > $SIGN_FILE
|
_machines-api "akey/$1?signature" > "$SIGN_FILE"
|
||||||
md5sum $KEY_FILE &1>&2;
|
md5sum "$KEY_FILE" 1>&2;
|
||||||
md5sum $SIGN_FILE &1>&2;
|
md5sum "$SIGN_FILE" 1>&2;
|
||||||
md5sum $MACHINES_CONFIG/machines.pub &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 openssl dgst -sha256 -verify "$MACHINES_CONFIG/machines.pub" -signature "$SIGN_FILE" "$KEY_FILE" &> /dev/null
|
||||||
if [ $? == 0 ]; then
|
then
|
||||||
cat $KEY_FILE
|
cat "$KEY_FILE"
|
||||||
rm $KEY_FILE $SIGN_FILE &> /dev/null
|
\rm "$KEY_FILE" "$SIGN_FILE"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
rm $KEY_FILE $SIGN_FILE &> /dev/null
|
\rm "$KEY_FILE" "$SIGN_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-updateAkey {
|
function _machines-updateAkey {
|
||||||
MYKEY_FILE=$(mktemp)
|
MYKEY_FILE=$(mktemp)
|
||||||
network=$(cat $MACHINES_CONFIG/this | grep '^network=' | cut -d '=' -f 2)
|
network=$(grep '^network=' "$MACHINES_CONFIG/this" | cut -d '=' -f 2)
|
||||||
_machines-getAkey $network > "$MYKEY_FILE"
|
if _machines-getAkey "$network" > "$MYKEY_FILE"
|
||||||
if [ $? == 0 ]; then
|
then
|
||||||
yes | mv $MYKEY_FILE $MACHINES_HOME/.ssh/authorized_keys &> /dev/null
|
\mv -f "$MYKEY_FILE" "$MACHINES_HOME/.ssh/authorized_keys"
|
||||||
return 0
|
return 0
|
||||||
else
|
else
|
||||||
cat $MYKEY_FILE
|
cat "$MYKEY_FILE"
|
||||||
echo "[ERROR] Authorized keys are not properly signed" 1>&2;
|
echo "[ERROR] Authorized keys are not properly signed" 1>&2;
|
||||||
rm $MYKEY_FILE
|
\rm "$MYKEY_FILE"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-postFile { # filename
|
function _machines-postFile { # filename
|
||||||
cat $1 | while read line; do
|
cat $1 | while read -r line; do
|
||||||
parameter=$(echo $line | cut -d '=' -f 1)
|
parameter=$(echo "$line" | cut -d '=' -f 1)
|
||||||
value="$(echo $line | sed 's/^[a-zA-Z0-9]\+\(\[\]\)\?=//')"
|
value="$(echo "$line" | sed 's/^[a-zA-Z0-9]\+\(\[\]\)\?=//')"
|
||||||
echo -n "&$parameter=$(urlencode "$value")"
|
echo -n "&$parameter=$(urlencode "$value")"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
@ -168,44 +169,47 @@ function _machines-postFile { # filename
|
||||||
|
|
||||||
function _machines-addElement { # element elementType default
|
function _machines-addElement { # element elementType default
|
||||||
FILE=$(mktemp)
|
FILE=$(mktemp)
|
||||||
echo -e $3 > $FILE
|
echo -e "$3" > "$FILE"
|
||||||
$EDITOR $FILE
|
$EDITOR "$FILE"
|
||||||
data=$(_machines-postFile $FILE)
|
data=$(_machines-postFile "$FILE")
|
||||||
rm $FILE &> /dev/null
|
\rm "$FILE"
|
||||||
_machines-apiSigned $2 --post-data "name=$1$data"
|
_machines-apiSigned "$2" --post-data "name=$1$data"
|
||||||
|
}
|
||||||
|
|
||||||
|
function _machines-viewElement { # element elementType
|
||||||
|
_machines-apiSigned "$2/$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-editElement { # element elementType
|
function _machines-editElement { # element elementType
|
||||||
FILE=$(mktemp)
|
FILE=$(mktemp)
|
||||||
_machines-apiSigned $2/$1 > $FILE
|
_machines-apiSigned "$2/$1" > "$FILE"
|
||||||
$EDITOR $FILE
|
$EDITOR "$FILE"
|
||||||
data=$(_machines-postFile $FILE)
|
data=$(_machines-postFile "$FILE")
|
||||||
rm $FILE &> /dev/null
|
rm "$FILE" &> /dev/null
|
||||||
err=$(_machines-apiSigned $2/$1 --post-data "$data")
|
err=$(_machines-apiSigned "$2/$1" --post-data "$data")
|
||||||
}
|
}
|
||||||
|
|
||||||
function _machines-deleteElement { # element elementType
|
function _machines-deleteElement { # element elementType
|
||||||
err=$(_machines-apiSigned $2/$1 --method=DELETE)
|
err=$(_machines-apiSigned "$2/$1" --method=DELETE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
# USER ADMIN FUNCTIONS
|
# USER ADMIN FUNCTIONS
|
||||||
|
|
||||||
function machines_history {
|
function machines_history {
|
||||||
if [ -f $MACHINES_CONFIG/lastVerifiedLog ]; then
|
if [ -f "$MACHINES_CONFIG/lastVerifiedLog" ]; then
|
||||||
from=$(<"$MACHINES_CONFIG/lastVerifiedLog")
|
from=$(<"$MACHINES_CONFIG/lastVerifiedLog")
|
||||||
else
|
else
|
||||||
from=0
|
from=0
|
||||||
fi
|
fi
|
||||||
d=$(date +%s)
|
d=$(date +%s)
|
||||||
_machines-apiSigned log?from=$from | less
|
_machines-apiSigned log?from=$from | less
|
||||||
prompt "Is this OK?"
|
if prompt "Is this OK?"
|
||||||
if [ $? == 1 ]; then
|
then
|
||||||
echo $d > $MACHINES_CONFIG/lastVerifiedLog
|
|
||||||
return 0
|
|
||||||
else
|
|
||||||
echo "Houston, we have a problem..."
|
|
||||||
exit 1
|
exit 1
|
||||||
|
else
|
||||||
|
echo "$d" > "$MACHINES_CONFIG/lastVerifiedLog"
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +217,7 @@ function machines_sign {
|
||||||
machines_history
|
machines_history
|
||||||
echo "Signing default network authorized_keys..."
|
echo "Signing default network authorized_keys..."
|
||||||
_machines-signAkey
|
_machines-signAkey
|
||||||
_machines-apiSigned network | while read network; do
|
_machines-apiSigned network | while read -r network; do
|
||||||
echo "Signing network $network authorized_keys..."
|
echo "Signing network $network authorized_keys..."
|
||||||
_machines-signAkey $network
|
_machines-signAkey $network
|
||||||
done
|
done
|
||||||
|
@ -235,11 +239,11 @@ function machines_machine_add_help {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
function machines_machine_add { # machine
|
function machines_machine_add { # machine
|
||||||
if [ -z $1 ]; then
|
if [ -z "$1" ]; then
|
||||||
machines_machine_add_help
|
machines_machine_add_help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
_machines-addElement $1 machine "host[]=\nnetwork=\nuserkey=\nhostkey=\nuser="
|
_machines-addElement "$1" machine "host[]=\nnetwork=\nuserkey=\nhostkey=\nuser="
|
||||||
}
|
}
|
||||||
|
|
||||||
function machines_network_add_help {
|
function machines_network_add_help {
|
||||||
|
@ -249,42 +253,75 @@ function machines_network_add_help {
|
||||||
echo " NETWORK Network to add"
|
echo " NETWORK Network to add"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function machines_network_add { # network
|
function machines_network_add { # network
|
||||||
if [ -z $1 ]; then
|
if [ -z "$1" ]; then
|
||||||
machines_network_add_help
|
machines_network_add_help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
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 {
|
function machines_machine_edit_help {
|
||||||
echo "Usage: $0 machine|mac|m edit MACHINE"
|
echo "Usage: $0 machine|mac|m edit MACHINE"
|
||||||
echo
|
echo
|
||||||
echo "Arguments:"
|
echo "Arguments:"
|
||||||
echo " MACHINE machine to remove"
|
echo " MACHINE machine to edit"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
function machines_machine_edit { # machine
|
function machines_machine_edit { # machine
|
||||||
if [ -z $1 ]; then
|
if [ -z "$1" ]; then
|
||||||
machines_machine_edit_help
|
machines_machine_edit_help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
_machines-editElement $1 machine
|
_machines-editElement "$1" machine
|
||||||
}
|
}
|
||||||
|
|
||||||
function machines_network_edit_help {
|
function machines_network_edit_help {
|
||||||
echo "Usage: $0 network|net|n edit NETWORK"
|
echo "Usage: $0 network|net|n edit NETWORK"
|
||||||
echo
|
echo
|
||||||
echo "Arguments:"
|
echo "Arguments:"
|
||||||
echo " NETWORK Network to remove"
|
echo " NETWORK Network to edit"
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
function machines_network_edit { # network
|
function machines_network_edit { # network
|
||||||
if [ -z $1 ]; then
|
if [ -z "$1" ]; then
|
||||||
machines_network_edit_help
|
machines_network_edit_help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
_machines-editElement $1 network
|
_machines-editElement "$1" network
|
||||||
}
|
}
|
||||||
|
|
||||||
function machines_machine_delete_help {
|
function machines_machine_delete_help {
|
||||||
|
@ -295,11 +332,11 @@ function machines_machine_delete_help {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
function machines_machine_delete { # machine
|
function machines_machine_delete { # machine
|
||||||
if [ -z $1 ]; then
|
if [ -z "$1" ]; then
|
||||||
machines_machine_delete_help
|
machines_machine_delete_help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
_machines-deleteElement $1 machine
|
_machines-deleteElement "$1" machine
|
||||||
}
|
}
|
||||||
|
|
||||||
function machines_network_delete_help {
|
function machines_network_delete_help {
|
||||||
|
@ -310,11 +347,11 @@ function machines_network_delete_help {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
function machines_network_delete { # network
|
function machines_network_delete { # network
|
||||||
if [ -z $1 ]; then
|
if [ -z "$1" ]; then
|
||||||
machines_network_delete_help
|
machines_network_delete_help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
_machines-deleteElement $1 network
|
_machines-deleteElement "$1" network
|
||||||
}
|
}
|
||||||
|
|
||||||
function machines_machine_help {
|
function machines_machine_help {
|
||||||
|
@ -323,6 +360,7 @@ function machines_machine_help {
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " list List all machines"
|
echo " list List all machines"
|
||||||
echo " add Interactively add a machine"
|
echo " add Interactively add a machine"
|
||||||
|
echo " view Display a machine"
|
||||||
echo " edit Interactively edit a specified machine"
|
echo " edit Interactively edit a specified machine"
|
||||||
echo " delete Remove a specified machine"
|
echo " delete Remove a specified machine"
|
||||||
echo " help Get help with commands"
|
echo " help Get help with commands"
|
||||||
|
@ -344,6 +382,7 @@ function machines_network_help {
|
||||||
echo "Commands:"
|
echo "Commands:"
|
||||||
echo " list List all networks"
|
echo " list List all networks"
|
||||||
echo " add Interactively add a network"
|
echo " add Interactively add a network"
|
||||||
|
echo " view Display a network"
|
||||||
echo " edit Interactively edit a specified network"
|
echo " edit Interactively edit a specified network"
|
||||||
echo " delete Remove a specified network"
|
echo " delete Remove a specified network"
|
||||||
echo " help Get help with commands"
|
echo " help Get help with commands"
|
||||||
|
@ -369,10 +408,9 @@ machines_net_help() { machines_network_help "$@"; }
|
||||||
machines_n_help() { machines_network_help "$@"; }
|
machines_n_help() { machines_network_help "$@"; }
|
||||||
|
|
||||||
function machines_update-all {
|
function machines_update-all {
|
||||||
machines_machine_list | while read machine; do
|
machines_machine_list | while read -r machine; do
|
||||||
echo "Updating $machine..."
|
echo "Updating $machine..."
|
||||||
ssh $machine 'machines update' &
|
ssh "$machine" 'cd .dotfiles && git pull; machines update' &
|
||||||
ssh $machine 'cd .dotfiles && git pull' &
|
|
||||||
done
|
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;
|
echo "[ERROR] Please delete the pem files manually to prove you know what you're doing." 1>&2;
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
openssl genrsa -out $MACHINES_CONFIG/machines.key 4096
|
openssl genrsa -out "$MACHINES_CONFIG/machines.key" 4096
|
||||||
chmod 600 $MACHINES_CONFIG/machines.key
|
chmod 600 "$MACHINES_CONFIG/machines.key"
|
||||||
openssl req -key $MACHINES_CONFIG/machines.key -new -out $MACHINES_CONFIG/machines.csr
|
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 x509 -req -days 1826 -in "$MACHINES_CONFIG/machines.csr" -signkey "$MACHINES_CONFIG/machines.key" -out "$MACHINES_CONFIG/machines.crt"
|
||||||
_machines-pubFromCrt
|
_machines-pubFromCrt
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -393,7 +431,7 @@ function machines_regen-keys {
|
||||||
# USER FUNCTIONS
|
# USER FUNCTIONS
|
||||||
|
|
||||||
function machines_setup {
|
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;
|
echo "[ERROR] This machine is already set up" 1>&2;
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -401,13 +439,13 @@ function machines_setup {
|
||||||
_machines-ensurePub
|
_machines-ensurePub
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
read -p 'Machine name? ' name
|
read -r -p 'Machine name? ' name
|
||||||
read -p 'Hosts (separated by spaces)? ' hosts
|
read -r -p 'Hosts (separated by spaces)? ' hosts
|
||||||
|
|
||||||
# User key
|
# 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
|
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
|
fi
|
||||||
userkey=$(<"$MACHINES_HOME/.ssh/id_rsa.pub")
|
userkey=$(<"$MACHINES_HOME/.ssh/id_rsa.pub")
|
||||||
|
|
||||||
|
@ -427,12 +465,12 @@ function machines_setup {
|
||||||
|
|
||||||
_machines-apiToken machine --post-data "$data"
|
_machines-apiToken machine --post-data "$data"
|
||||||
|
|
||||||
echo $name > $MACHINES_CONFIG/this.name
|
echo "$name" > "$MACHINES_CONFIG/this.name"
|
||||||
machines_update
|
machines_update
|
||||||
}
|
}
|
||||||
|
|
||||||
function 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
|
_machines-updateAkey
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,5 +513,5 @@ shift
|
||||||
if type "machines_$command" &> /dev/null; then
|
if type "machines_$command" &> /dev/null; then
|
||||||
"machines_$command" "$@"
|
"machines_$command" "$@"
|
||||||
else
|
else
|
||||||
machines_help
|
machines_help "$@"
|
||||||
fi
|
fi
|
||||||
|
|
9
scripts/pw
Executable file
9
scripts/pw
Executable file
|
@ -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
|
65
scripts/ter
Executable file
65
scripts/ter
Executable file
|
@ -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} €")
|
21
scripts/totask
Executable file
21
scripts/totask
Executable file
|
@ -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}")
|
2
scripts/tracefiles
Executable file
2
scripts/tracefiles
Executable file
|
@ -0,0 +1,2 @@
|
||||||
|
#!/usr/bin/env sh
|
||||||
|
strace -f -t -e trace=file
|
|
@ -6,7 +6,19 @@ import subprocess
|
||||||
for root, dirs, files in os.walk("."):
|
for root, dirs, files in os.walk("."):
|
||||||
for name in files:
|
for name in files:
|
||||||
base, ext = os.path.splitext(name)
|
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
|
continue
|
||||||
|
|
||||||
filepath = os.path.join(root, name)
|
filepath = os.path.join(root, name)
|
||||||
|
@ -15,7 +27,7 @@ for root, dirs, files in os.walk("."):
|
||||||
|
|
||||||
os.mkdir(dirpath)
|
os.mkdir(dirpath)
|
||||||
|
|
||||||
cmd = ["unzip", os.path.realpath(filepath)]
|
cmd.append(os.path.realpath(filepath))
|
||||||
r = subprocess.run(cmd, cwd=dirpath)
|
r = subprocess.run(cmd, cwd=dirpath)
|
||||||
r.check_returncode()
|
r.check_returncode()
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ SOURCE_FOLDER = os.path.join(os.path.expanduser("~"), "Musiques")
|
||||||
OUTPUT_FOLDER = os.path.join(os.path.expanduser("~"), ".musicCompressed")
|
OUTPUT_FOLDER = os.path.join(os.path.expanduser("~"), ".musicCompressed")
|
||||||
CONVERSIONS = {"flac": "opus"}
|
CONVERSIONS = {"flac": "opus"}
|
||||||
FORBIDDEN_EXTENSIONS = ["jpg", "pdf", "ffs_db"]
|
FORBIDDEN_EXTENSIONS = ["jpg", "pdf", "ffs_db"]
|
||||||
FORGIVEN_FILENAMES = ["cover.jpg"]
|
FORGIVEN_FILENAMES = ["cover.jpg", "front.jpg"]
|
||||||
IGNORED_EMPTY_FOLDER = [".stfolder"]
|
IGNORED_EMPTY_FOLDER = [".stfolder"]
|
||||||
|
|
||||||
# TODO FEAT Make the directory structure the same as the base one and
|
# TODO FEAT Make the directory structure the same as the base one and
|
||||||
|
|
11
tmux.conf
Normal file
11
tmux.conf
Normal file
|
@ -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'
|
54
vimrc
54
vimrc
|
@ -31,11 +31,10 @@ Plug 'vim-airline/vim-airline'
|
||||||
Plug 'vim-airline/vim-airline-themes'
|
Plug 'vim-airline/vim-airline-themes'
|
||||||
Plug 'airblade/vim-gitgutter'
|
Plug 'airblade/vim-gitgutter'
|
||||||
Plug 'mbbill/undotree'
|
Plug 'mbbill/undotree'
|
||||||
Plug 'xolox/vim-misc' " Required for 'xolox/vim-easytags'
|
Plug 'ludovicchabant/vim-gutentags'
|
||||||
Plug 'xolox/vim-easytags'
|
|
||||||
Plug 'majutsushi/tagbar'
|
Plug 'majutsushi/tagbar'
|
||||||
Plug 'wellle/targets.vim'
|
Plug 'wellle/targets.vim'
|
||||||
Plug 'Chiel92/vim-autoformat'
|
" Plug 'Chiel92/vim-autoformat'
|
||||||
Plug 'tomtom/tcomment_vim'
|
Plug 'tomtom/tcomment_vim'
|
||||||
" Plug 'Shougo/denite.nvim'
|
" Plug 'Shougo/denite.nvim'
|
||||||
" Plug 'tomlion/vim-solidity'
|
" Plug 'tomlion/vim-solidity'
|
||||||
|
@ -43,16 +42,16 @@ Plug 'tomtom/tcomment_vim'
|
||||||
" Plug 'jrozner/vim-antlr'
|
" Plug 'jrozner/vim-antlr'
|
||||||
"
|
"
|
||||||
" Plug 'maralla/completor.vim'
|
" Plug 'maralla/completor.vim'
|
||||||
if has('nvim')
|
" if has('nvim')
|
||||||
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
|
" Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
|
||||||
else
|
" else
|
||||||
Plug 'Shougo/deoplete.nvim'
|
" Plug 'Shougo/deoplete.nvim'
|
||||||
Plug 'roxma/nvim-yarp'
|
" Plug 'roxma/nvim-yarp'
|
||||||
Plug 'roxma/vim-hug-neovim-rpc'
|
" Plug 'roxma/vim-hug-neovim-rpc'
|
||||||
endif
|
" endif
|
||||||
Plug 'zchee/deoplete-jedi'
|
" 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', {'do': './install --bin'}
|
||||||
Plug 'junegunn/fzf.vim'
|
Plug 'junegunn/fzf.vim'
|
||||||
Plug 'ervandew/supertab'
|
Plug 'ervandew/supertab'
|
||||||
|
@ -60,12 +59,19 @@ Plug 'dpelle/vim-LanguageTool'
|
||||||
Plug 'terryma/vim-smooth-scroll'
|
Plug 'terryma/vim-smooth-scroll'
|
||||||
Plug 'vim-pandoc/vim-pandoc'
|
Plug 'vim-pandoc/vim-pandoc'
|
||||||
Plug 'vim-pandoc/vim-pandoc-syntax'
|
Plug 'vim-pandoc/vim-pandoc-syntax'
|
||||||
|
Plug 'idanarye/vim-vebugger'
|
||||||
|
Plug 'w0rp/ale'
|
||||||
|
|
||||||
call plug#end()
|
call plug#end()
|
||||||
|
|
||||||
""" COMPLETOR """
|
""" ALE """
|
||||||
|
|
||||||
let g:deoplete#enable_at_startup = 1
|
nmap <F3> :ALEFix<CR>
|
||||||
|
|
||||||
|
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 """
|
""" 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_b = airline#section#create(['branch', 'hunks'])
|
||||||
" let g:airline_section_z = airline#section#create(['%B', '@', '%l', ':', '%c'])
|
" let g:airline_section_z = airline#section#create(['%B', '@', '%l', ':', '%c'])
|
||||||
let g:airline_theme = 'base16_monokai'
|
let g:airline_theme = 'base16_monokai'
|
||||||
|
let g:airline#extensions#ale#enabled = 1
|
||||||
""" AUTOFORMAT """
|
|
||||||
nmap <F3> :Autoformat<CR>
|
|
||||||
|
|
||||||
""" 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
|
|
||||||
|
|
||||||
""" FZF """
|
""" FZF """
|
||||||
|
|
||||||
let g:fzf_layout = { 'down': '~100%' }
|
let g:fzf_layout = { 'down': '~40%' }
|
||||||
let g:fzf_colors =
|
let g:fzf_colors =
|
||||||
\ { 'fg': ['fg', 'Normal'],
|
\ { 'fg': ['fg', 'Normal'],
|
||||||
\ 'bg': ['bg', 'Normal'],
|
\ 'bg': ['bg', 'Normal'],
|
||||||
|
|
Loading…
Reference in a new issue