summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.bash-powerline.sh97
-rw-r--r--.bashrc106
-rw-r--r--.profile5
-rw-r--r--etc/doas.d/doas.conf1
4 files changed, 208 insertions, 1 deletions
diff --git a/.bash-powerline.sh b/.bash-powerline.sh
new file mode 100644
index 0000000..6d2ee2d
--- /dev/null
+++ b/.bash-powerline.sh
@@ -0,0 +1,97 @@
+#!/usr/bin/env bash
+
+## Uncomment to disable git info
+#POWERLINE_GIT=0
+
+__powerline() {
+ # Colorscheme
+ readonly RESET='\[\033[m\]'
+ readonly COLOR_CWD='\[\033[0;34m\]' # blue
+ readonly COLOR_GIT='\[\033[0;36m\]' # cyan
+ #readonly COLOR_SUCCESS='\[\033[0;32m\]' # green
+ readonly COLOR_SUCCESS='\[\033[0;1;34m\]' # blue, bold
+ readonly COLOR_FAILURE='\[\033[0;1;31m\]' # red, bold
+
+ #readonly SYMBOL_GIT_BRANCH='⑂'
+ readonly SYMBOL_GIT_BRANCH='→'
+ readonly SYMBOL_GIT_MODIFIED='¤'
+ readonly SYMBOL_GIT_PUSH='↑'
+ readonly SYMBOL_GIT_PULL='↓'
+
+ if test -f '../usr/etc/hostname'; then
+ host=$(<../usr/etc/hostname)
+ elif test -f '/etc/hostname'; then
+ host=$(</etc/hostname)
+ else
+ host=$(hostname -s)
+ fi
+
+ [ "$PS_SYMBOL" ] || PS_SYMBOL=';'
+
+ __git_info() {
+ [[ $POWERLINE_GIT = 0 ]] && return # disabled
+ hash git 2>/dev/null || return # git not found
+ local git_eng="env LANG=C git" # force git output in English to make our work easier
+
+ # get current branch name
+ local ref=$($git_eng symbolic-ref --short HEAD 2>/dev/null)
+
+ if [[ -n "$ref" ]]; then
+ # prepend branch symbol
+ ref=$SYMBOL_GIT_BRANCH$ref
+ else
+ # get tag name or short unique hash
+ ref=$($git_eng describe --tags --always 2>/dev/null)
+ fi
+
+ [[ -n "$ref" ]] || return # not a git repo
+
+ local marks
+
+ # scan first two lines of output from `git status`
+ while IFS= read -r line; do
+ if [[ $line =~ ^## ]]; then # header line
+ [[ $line =~ ahead\ ([0-9]+) ]] && marks+="$SYMBOL_GIT_PUSH${BASH_REMATCH[1]}"
+ [[ $line =~ behind\ ([0-9]+) ]] && marks+="$SYMBOL_GIT_PULL${BASH_REMATCH[1]}"
+ else # branch is modified if output contains more lines after the header line
+ marks="$SYMBOL_GIT_MODIFIED$marks"
+ break
+ fi
+ done < <($git_eng status --porcelain --branch 2>/dev/null) # note the space between the two <
+
+ # print the git branch segment without a trailing newline
+ printf "$ref$marks"
+ }
+
+ ps1() {
+ # Check the exit code of the previous command and display different
+ # colors in the prompt accordingly.
+ if [ $? -eq 0 ]; then
+ local symbol="$COLOR_SUCCESS$PS_SYMBOL $RESET"
+ else
+ local symbol="$COLOR_FAILURE$PS_SYMBOL $RESET"
+ fi
+
+ local cwd="$COLOR_CWD\w$RESET"
+ # Bash by default expands the content of PS1 unless promptvars is disabled.
+ # We must use another layer of reference to prevent expanding any user
+ # provided strings, which would cause security issues.
+ # POC: https://github.com/njhartwell/pw3nage
+ # Related fix in git-bash: https://github.com/git/git/blob/9d77b0405ce6b471cb5ce3a904368fc25e55643d/contrib/completion/git-prompt.sh#L324
+ if shopt -q promptvars; then
+ __powerline_git_info="$(__git_info)"
+ local git="$COLOR_GIT\${__powerline_git_info}$RESET"
+ else
+ # promptvars is disabled. Avoid creating unnecessary env var.
+ local git="$COLOR_GIT$(__git_info)$RESET"
+ fi
+
+ [ "$SSH_TTY" ] && PS1=": $host:$cwd$git$symbol" || PS1=": $cwd$git$symbol"
+ }
+
+ PROMPT_DIRTRIM=1
+ PROMPT_COMMAND="ps1${PROMPT_COMMAND:+; $PROMPT_COMMAND}"
+}
+
+__powerline
+unset __powerline
diff --git a/.bashrc b/.bashrc
new file mode 100644
index 0000000..2ebb2e9
--- /dev/null
+++ b/.bashrc
@@ -0,0 +1,106 @@
+# ~/.bashrc
+
+# If not running interactively, don't do anything
+[[ $- != *i* ]] && return
+
+export PAGER=less
+export EDITOR=vim
+export HISTIGNORE='sudo id:uname:date:exit:df:ll:ls:ps:pwd:top:history'
+export HISTCONTROL=ignoreboth:erasedups # no start space and duplicate entries
+export HISTSIZE=100000 # big big history
+export HISTFILESIZE=100000 # big big history
+shopt -s histappend # append to history, don't overwrite it
+stty -ixon # disable Ctrl-S
+
+p() { [ -f "$1" -a ! -x "$1" ] && less -XF $1 || "$@" 2>&1 | less -XF ; }
+export -f p
+
+fixab() { printf "\x1f\x8b\x08\x00\x00\x00\x00\x00" ; tail -c +25 "$1"; }
+
+#export BACKUP=bip:/home/backup/marc@$(hostname -s)
+export LESS=XFRx4
+
+# gnuplot display in terminal
+export GNUTERM='sixelgd enhanced truecolor font "arial,9"'
+
+# Stopwatch
+alias timer='echo "Timer started. Stop with Ctrl-D." && date && time cat && date'
+
+alias ls='ls --color=auto -v'
+alias ll='ls -AlFhv'
+alias more='less'
+alias vi='vim'
+alias view='vim -R'
+alias op='xdg-open'
+alias gob='go build'
+alias goh='p go help'
+alias god='p go doc'
+alias gol='GO111MODULE=off go'
+alias gtr='go test -v -run'
+alias gtb='go test -v -cpuprofile cpu.out -memprofile mem.out -benchmem -bench'
+alias kd='sudo cat /sys/kernel/debug/tracing/trace_pipe'
+
+alias sudo=doas
+alias rvi='sudo vim'
+alias rxt='sudo xt'
+alias rxvi='sudo xvi'
+alias ww='vi ~/Wiki/home_page.md'
+alias s='vi ~/Wiki/scratch.md'
+alias dotfiles='git --git-dir=$HOME/dotfiles --work-tree=$HOME'
+
+# Some admin command
+alias dmesg='doas dmesg'
+alias mount='doas mount'
+alias umount='doas umount'
+alias apk='doas apk'
+#alias cryptsetup='sudo cryptsetup'
+
+alias by='go build ./cmd/yaegi'
+alias cy='cd ~/go/src/github.com/traefik/yaegi'
+#alias ty='go test -v -short ./interp'
+alias y='rlwrap -pblue yaegi'
+alias dy='YAEGI_AST_DOT=1 YAEGI_CFG_DOT=1 ./yaegi'
+alias wai='~/go/src/github.co/traefik/whoami/whoami'
+
+# yaegi debug
+export YAEGI_DOT_CMD='dotty -'
+export YAEGI_UNSAFE=1
+export YAEGI_UNRESTRICTED=1
+export YAEGI_SYSCALL=1
+
+ssht() { ssh -t "$@" -- tmux new -A; }
+export -f ssht
+
+sshs() { ssh -t "$@" -- screen -d -R; }
+
+mpvx() { mpv --vo=sixel --profile=sw-fast --really-quiet "$@"; }
+export -f mpvx
+
+ws() (cd ~/Wiki && git status --short)
+export -f ws
+
+wsd() (cd ~/Wiki && git add . && git diff --cached)
+export -f wsd
+
+meteo() {
+ local request="wttr.in/${1-Toulouse}?F&T"
+ [ "$(tput cols)" -lt 125 ] && request+='&n'
+ curl -H "Accept-Language: fr" --compressed "$request"
+}
+
+#PS1='[\u@\h \W]\$ '
+
+# fzf
+[ -f "/usr/share/fzf/completion.bash" ] && . "/usr/share/fzf/completion.bash"
+[ -f "/usr/share/fzf/key-bindings.bash" ] && . "/usr/share/fzf/key-bindings.bash"
+
+# Display git status in prompt
+. ~/.bash-powerline.sh
+
+# eval "$(direnv hook bash)"
+#export GITHUB_TOKEN=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
+
+#set -o vi
+#bind -m vi-command ".":insert-last-argument
+#bind -m vi-command 'Control-l: clear-screen'
+#bind -m vi-insert 'Control-l: clear-screen'
diff --git a/.profile b/.profile
index 64f7ed6..e1b8a7c 100644
--- a/.profile
+++ b/.profile
@@ -1,6 +1,9 @@
export PATH=~/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:~/go/bin
export XDG_RUNTIME_DIR=/run/user/1000
-[ "$SHELL" = /bin/ash ] && export ENV=~/.shrc
+case "$SHELL" in
+*/ash) export ENV=~/.shrc ;;
+*/bash) . ~/.bashrc ;;
+esac
[ "$(tty)" = /dev/tty1 ] && exec dbus-run-session -- sway
diff --git a/etc/doas.d/doas.conf b/etc/doas.d/doas.conf
new file mode 100644
index 0000000..d2423e7
--- /dev/null
+++ b/etc/doas.d/doas.conf
@@ -0,0 +1 @@
+permit nopass :wheel