Compare commits

...

20 Commits

Author SHA1 Message Date
9d5f34011f Explicitly create user 2024-04-14 02:42:30 +02:00
05b41da541 Move gtk2 config into ~/.config 2024-04-14 02:25:53 +02:00
9e5f1c95fe Remove screen 2024-04-14 02:24:11 +02:00
45060743ce Move wget HSTS file into XDG_STATE_HOME 2024-04-14 02:16:55 +02:00
3fdd991cef Log into XDG_RUNTIME_DIR 2024-04-14 02:14:12 +02:00
d0b067e3d4 Remove ~/.var/lib 2024-04-14 02:11:58 +02:00
b23363ec55 Remove ~/.usr/lib 2024-04-14 02:09:44 +02:00
09ed854251 Use XDG_RUNTIME_DIR instead of ~/.var/run 2024-04-14 02:09:29 +02:00
7287ff76a5 Disable certain user services 2024-04-14 02:02:58 +02:00
97409130ab Get rid of xdg-user-dirs 2024-04-14 01:54:23 +02:00
ff70e29117 Move i3 config into ~/.config 2024-04-14 01:37:57 +02:00
5ed1650b02 Use PASSWORD_STORE_DIR 2024-04-14 01:33:43 +02:00
ba066166fe Use GNUPGHOME 2024-04-14 01:31:55 +02:00
9278e8c065 Move tmux.conf into ~/.config 2024-04-14 01:27:53 +02:00
c6405280de Remove ~/.vimrc 2024-04-14 01:27:48 +02:00
03a6e6b737 Move gitconfig into ~/.config 2024-04-14 01:27:16 +02:00
4c5bb331d4 Add list of dotfiles to remove 2024-04-14 01:27:16 +02:00
580bfd9e52 Set XDG_ env variables 2024-04-14 01:06:55 +02:00
2937aa8b9b Streamline zsh config 2024-04-14 01:06:48 +02:00
cce054a742 Fix package inconsistencies 2024-04-14 00:52:09 +02:00
25 changed files with 558 additions and 800 deletions

View File

@@ -5,7 +5,6 @@ i3bar_icon_padding: ""
users: users:
- name: hannes-work - name: hannes-work
group: hannes-work
vt: 1 vt: 1
firefox_profiles: firefox_profiles:
default: default:
@@ -31,7 +30,6 @@ users:
repositories: [] repositories: []
- name: hannes-private - name: hannes-private
group: hannes-private
vt: 2 vt: 2
firefox_profiles: firefox_profiles:
default: default:

View File

@@ -1,10 +1,11 @@
[Unit] [Unit]
BindsTo=autostart.target BindsTo=autostart.target
After=windowmanager.target After=windowmanager.target
ConditionPathExists=%h/.var/run/features/gpg_agent ConditionPathExists=%t/features/gpg_agent
[Service] [Service]
Type=forking Type=forking
ExecStart=/usr/bin/env gpg-agent --homedir %h/.gnupg --no-detach --daemon ExecStart=/usr/bin/env gpg-agent --no-detach --daemon
PassEnvironment=DISPLAY PassEnvironment=DISPLAY GNUPGHOME
Restart=always Restart=always

View File

@@ -1,6 +1,6 @@
[Service] [Service]
Type=simple Type=simple
ExecStart=/usr/bin/env i3 --config %h/.i3/config ExecStart=/usr/bin/env i3 --config %h/.config/i3/config
PassEnvironment=DISPLAY PassEnvironment=DISPLAY
Restart=no Restart=no

View File

@@ -1,7 +1,7 @@
[Unit] [Unit]
BindsTo=autostart.target BindsTo=autostart.target
After=windowmanager.target After=windowmanager.target
ConditionPathExists=%h/.var/run/features/keepassx ConditionPathExists=%t/features/keepassx
[Service] [Service]
ExecStart=/usr/bin/env keepassx --keyfile %h/.secret/main.key %h/.secret/main.kdbx ExecStart=/usr/bin/env keepassx --keyfile %h/.secret/main.key %h/.secret/main.kdbx

View File

@@ -1,7 +1,7 @@
[Unit] [Unit]
BindsTo=autostart.target BindsTo=autostart.target
After=windowmanager.target After=windowmanager.target
ConditionPathExists=%h/.var/run/features/machine_is_laptop ConditionPathExists=%t/features/machine_is_laptop
[Service] [Service]
Type=oneshot Type=oneshot

View File

@@ -3,7 +3,7 @@ BindsTo=autostart.target
After=windowmanager.target After=windowmanager.target
After=gnome-keyring.service After=gnome-keyring.service
ConditionPathExists=%h/.var/run/features/nextcloud ConditionPathExists=%t/features/nextcloud
[Service] [Service]
ExecStart=/usr/bin/env nextcloud --background ExecStart=/usr/bin/env nextcloud --background

View File

@@ -1,5 +1,5 @@
[Unit] [Unit]
ConditionPathExists=%h/.var/run/features/restic_backup ConditionPathExists=%t/features/restic_backup
[Service] [Service]
Type=oneshot Type=oneshot

View File

@@ -3,7 +3,7 @@ BindsTo=autostart.target
After=windowmanager.target After=windowmanager.target
After=i3.service After=i3.service
ConditionPathExists=%h/.var/run/features/steam ConditionPathExists=%t/features/steam
[Service] [Service]
ExecStart=/usr/bin/env steam ExecStart=/usr/bin/env steam

View File

@@ -1,7 +1,7 @@
[Unit] [Unit]
BindsTo=autostart.target BindsTo=autostart.target
After=windowmanager.target After=windowmanager.target
ConditionPathExists=%h/.var/run/features/machine_is_laptop ConditionPathExists=%t/features/machine_is_laptop
[Service] [Service]
Type=oneshot Type=oneshot

View File

@@ -2,7 +2,7 @@
set -o nounset set -o nounset
_logfile="$LOGDIR/dunstctl.log" _logfile="$XDG_RUNTIME_DIR/dunstctl.log"
log() { log() {
printf '[%s] %s\n' "$(date -uIseconds)" "$*" >> "$_logfile" printf '[%s] %s\n' "$(date -uIseconds)" "$*" >> "$_logfile"

View File

@@ -3,10 +3,10 @@
set -o nounset set -o nounset
set -o errexit set -o errexit
if [[ ! -e ~/.password-store ]] ; then if [[ ! -e "${PASSWORD_STORE_DIR}" ]] ; then
printf '%s\n' 'This is the first time running pass, initializting repository ...' printf '%s\n' 'This is the first time running pass, initializting repository ...'
git clone ssh://git@code.hkoerber.de:2222/hannes/passwordstore.git ~/.password-store git clone ssh://git@code.hkoerber.de:2222/hannes/passwordstore.git "${PASSWORD_STORE_DIR}"
printf '%s\n' 'Done' printf '%s\n' 'Done'
fi fi

View File

@@ -1,5 +1,4 @@
empty_directories: empty_directories:
- name: .i3
- name: .gnupg - name: .gnupg
mode: '0700' mode: '0700'
- name: .config/nvim - name: .config/nvim
@@ -13,9 +12,12 @@ empty_directories:
- name: .config/i3status-rust/icons - name: .config/i3status-rust/icons
- name: .config/i3status-rust/themes - name: .config/i3status-rust/themes
- name: .config/helix - name: .config/helix
- name: .config/git
- name: .config/tmux
- name: .config/i3
dotfiles: dotfiles:
- from: git/gitconfig - from: git/gitconfig
to: .gitconfig to: .config/git/config
template: true template: true
- from: gnupg/dirmngr.conf - from: gnupg/dirmngr.conf
to: .gnupg/dirmngr.conf to: .gnupg/dirmngr.conf
@@ -26,7 +28,7 @@ dotfiles:
to: .gnupg/gpg.conf to: .gnupg/gpg.conf
template: true template: true
- from: i3/config - from: i3/config
to: .i3/config to: .config/i3/config
template: true template: true
- from: i3/i3status-rust/config.toml - from: i3/i3status-rust/config.toml
to: .config/i3status-rust/config.toml to: .config/i3status-rust/config.toml
@@ -36,13 +38,11 @@ dotfiles:
- from: i3/i3status-rust/icons/awesome.toml - from: i3/i3status-rust/icons/awesome.toml
to: .config/i3status-rust/icons/awesome.toml to: .config/i3status-rust/icons/awesome.toml
- from: i3/scripts - from: i3/scripts
to: .i3/scripts to: .config/i3/scripts
- from: tmux/tmux.conf - from: tmux/tmux.conf
to: .tmux.conf to: .config/tmux/tmux.conf
- from: vim/vimrc - from: vim/vimrc
to: .config/nvim/init.vim to: .config/nvim/init.vim
- from: vim/vimrc
to: .vimrc
- from: x/Xresources - from: x/Xresources
to: .Xresources to: .Xresources
template: true template: true
@@ -79,7 +79,7 @@ dotfiles:
to: .config/gtk-3.0-overrides/bigger-font/gtk-3.0/settings.ini to: .config/gtk-3.0-overrides/bigger-font/gtk-3.0/settings.ini
template: true template: true
- from: gtk/gtkrc-2.0 - from: gtk/gtkrc-2.0
to: .gtkrc-2.0 to: .config/gtkrc-2.0
template: true template: true
- from: qt/qt5ct.conf - from: qt/qt5ct.conf
to: .config/qt5ct/qt5ct.conf to: .config/qt5ct/qt5ct.conf
@@ -89,3 +89,9 @@ dotfiles:
to: scripts to: scripts
- from: helix/config.toml - from: helix/config.toml
to: .config/helix/config.toml to: .config/helix/config.toml
dotfiles_remove:
- .gitconfig
- .vimrc
- .tmux.conf
- .i3
- .gtkrc-2.0

View File

@@ -20,7 +20,7 @@
set $terminal "alacritty --config-file ~/.config/alacritty.toml" set $terminal "alacritty --config-file ~/.config/alacritty.toml"
set $calc "alacritty --config-file ~/.config/alacritty.toml -e $SHELL -i -c calc" set $calc "alacritty --config-file ~/.config/alacritty.toml -e $SHELL -i -c calc"
set $scriptdir ~/.i3/scripts set $scriptdir ~/.config/i3/scripts
# Keys for the exit mode # Keys for the exit mode
set $key_lock l set $key_lock l
@@ -206,27 +206,27 @@ assign [class="^Wine$"] $workspace10
### START APPLICATIONS ##################################################### ### START APPLICATIONS #####################################################
bindsym $mod+d exec --no-startup-id ~/.i3/scripts/appmenu bindsym $mod+d exec --no-startup-id $scriptdir/appmenu
bindsym $mod+Return exec $terminal bindsym $mod+Return exec $terminal
bindsym $mod+Shift+Return exec $calc bindsym $mod+Shift+Return exec $calc
bindsym F1 exec --no-startup-id ~/.i3/scripts/shutdown-menu bindsym F1 exec --no-startup-id $scriptdir/shutdown-menu
bindsym F2 exec --no-startup-id ~/.i3/scripts/screenmenu bindsym F2 exec --no-startup-id $scriptdir/screenmenu
bindsym $mod+F1 exec --no-startup-id ~/.i3/scripts/i3exit lock bindsym $mod+F1 exec --no-startup-id $scriptdir/i3exit lock
bindsym $mod+F2 exec --no-startup-id screencfg ~/.screencfg/{{ ansible_hostname }}/default.yml ; exec systemctl --user restart keyboard.service bindsym $mod+F2 exec --no-startup-id screencfg ~/.screencfg/{{ ansible_hostname }}/default.yml ; exec systemctl --user restart keyboard.service
{% for screencfg in machine.screencfgs -%} {% for screencfg in machine.screencfgs -%}
bindsym $mod+{{ screencfg.key }} exec --no-startup-id screencfg ~/.screencfg/{{ ansible_hostname }}/{{ screencfg.name }}.yml ; exec systemctl --user restart keyboard.service bindsym $mod+{{ screencfg.key }} exec --no-startup-id screencfg ~/.screencfg/{{ ansible_hostname }}/{{ screencfg.name }}.yml ; exec systemctl --user restart keyboard.service
{% endfor -%} {% endfor -%}
bindsym $mod+F4 exec --no-startup-id ~/.i3/scripts/i3exit suspend bindsym $mod+F4 exec --no-startup-id $scriptdir/i3exit suspend
bindsym $mod+Home exec --no-startup-id ~/.i3/scripts/shutdown-menu bindsym $mod+Home exec --no-startup-id $scriptdir/shutdown-menu
bindsym $mod+$screenshot exec --no-startup-id sh -c 'maim | xclip -selection clipboard -t image/png' bindsym $mod+$screenshot exec --no-startup-id sh -c 'maim | xclip -selection clipboard -t image/png'
bindsym $mod+Shift+$screenshot exec --no-startup-id sh -c 'maim --select | xclip -selection clipboard -t image/png' bindsym $mod+Shift+$screenshot exec --no-startup-id sh -c 'maim --select | xclip -selection clipboard -t image/png'
bindsym $mod+Shift+v exec --no-startup-id redshift-toggle bindsym $mod+Shift+v exec --no-startup-id redshift-toggle
bindsym $mod+$pim_toggle exec --no-startup-id ~/.i3/scripts/swap-from-workspace $workspace10 bindsym $mod+$pim_toggle exec --no-startup-id $scriptdir/swap-from-workspace $workspace10
################################################################################ ################################################################################
### MODES ###################################################################### ### MODES ######################################################################

View File

@@ -2,10 +2,7 @@
### From http://www.archlinux.org/index.php/i3 ### From http://www.archlinux.org/index.php/i3
_logfile="$LOGDIR/i3/i3exit.log" _logfile="$XDG_RUNTIME_DIR/i3exit.log"
LOCKSCREEN="$LIBDIR/lockscreen"
_fallback_color="000000"
touch "$_logfile" touch "$_logfile"
@@ -20,16 +17,8 @@ lock()
set -x set -x
playerctl -p spotify pause playerctl -p spotify pause
if [[ -f "$LOCKSCREEN" ]] ; then i3lock --nofork --show-failed-attempts --ignore-empty-password \
resized_lockscreen=$(mktemp) --color "000000"
convert "${LOCKSCREEN}" -resize "${MACHINE_RESOLUTION_X}x${MACHINE_RESOLUTION_Y}" "${resized_lockscreen}"
i3lock --nofork --show-failed-attempts --ignore-empty-password \
--image "${resized_lockscreen}"
rm "${resized_lockscreen}"
else
i3lock --nofork --show-failed-attempts --ignore-empty-password \
--color "$_fallback_color"
fi
} }
screen_off() { screen_off() {

View File

@@ -88,8 +88,6 @@ packages:
archlinux: ["alacritty"] archlinux: ["alacritty"]
tmux: tmux:
archlinux: ["tmux"] archlinux: ["tmux"]
screen:
archlinux: ["screen"]
zsh: zsh:
archlinux: ["zsh", "zsh-syntax-highlighting", "zsh-autosuggestions", "zsh-completions"] archlinux: ["zsh", "zsh-syntax-highlighting", "zsh-autosuggestions", "zsh-completions"]
zathura: zathura:
@@ -190,8 +188,6 @@ packages:
archlinux: ["nodejs", "npm"] archlinux: ["nodejs", "npm"]
xdg: xdg:
archlinux: ["xdg-utils"] archlinux: ["xdg-utils"]
compton:
archlinux: []
dunst: dunst:
archlinux: ["dunst"] archlinux: ["dunst"]
cloc: cloc:
@@ -215,7 +211,7 @@ packages:
rclone: rclone:
archlinux: ["rclone"] archlinux: ["rclone"]
dnf: dnf:
archlinux: [] archlinux: ["dnf"]
rustup: rustup:
archlinux: ["rustup"] archlinux: ["rustup"]
musescore: musescore:
@@ -360,3 +356,5 @@ packages:
archlinux: ["gvim"] archlinux: ["gvim"]
rust: rust:
archlinux: ["rust"] archlinux: ["rust"]
screen:
archlinux: ["screen"]

View File

@@ -1,18 +1,3 @@
- name: configure sudoers
lineinfile:
path: /etc/sudoers
line: "{{ user.name }} ALL=(ALL) NOPASSWD:ALL"
regexp: "^{{ user.name }}\\s+"
become: true
become_user: root
- name: set shell
user:
name: "{{ user.name }}"
shell: /usr/bin/zsh
become: true
become_user: root
- set_fact: - set_fact:
user_groups: user_groups:
- libvirt - libvirt
@@ -25,21 +10,30 @@
- kvm - kvm
tags: [always] tags: [always]
- set_fact:
user_group_name: "{{ user.group|default(user.name) }}"
tags: [always]
- name: create user group - name: create user group
group: group:
name: "{{ user_group_name }}" name: "{{ user.name }}"
state: present state: present
become: true become: true
become_user: root become_user: root
- name: set groups - name: create user
user: user:
name: "{{ user.name }}" name: "{{ user.name }}"
groups: "{{ [user_group_name, 'dotfiles'] + user_groups }}" state: present
home: "/home/{{ user.name }}"
create_home: true
groups: "{{ [user.name, 'dotfiles'] + user_groups }}"
shell: /usr/bin/zsh
become: true
become_user: root
- name: configure sudoers
lineinfile:
path: /etc/sudoers
line: "{{ user.name }} ALL=(ALL) NOPASSWD:ALL"
regexp: "^{{ user.name }}\\s+"
become: true become: true
become_user: root become_user: root
@@ -48,12 +42,28 @@
state: directory state: directory
path: "{{ item }}" path: "{{ item }}"
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
loop: loop:
- "/home/{{ user.name }}/.config/" - "/home/{{ user.name }}/.config/"
- "/home/{{ user.name }}/.config/systemd/" - "/home/{{ user.name }}/.config/systemd/"
- "/home/{{ user.name }}/.config/systemd/user/" - "/home/{{ user.name }}/.config/systemd/user/"
- set_fact:
undesired_user_services:
- gpg-agent.socket
- gpg-agent-browser.socket
- gpg-agent-ssh.socket
- gpg-agent-extra.socket
- xdg-user-dirs-update.service
- gnome-keyring-daemon.service
- name: stop undesired service
systemd_service:
name: "{{ item }}"
scope: user
state: stopped
loop: "{{ undesired_user_services }}"
# No way to use the `systemd` module here, as it needs a logind # No way to use the `systemd` module here, as it needs a logind
# session. So we have to handle the symlinks for masking ourselves. # session. So we have to handle the symlinks for masking ourselves.
- name: disable and mask systemd user units - name: disable and mask systemd user units
@@ -61,11 +71,7 @@
state: link state: link
dest: "/home/{{ user.name }}/.config/systemd/user/{{ item }}" dest: "/home/{{ user.name }}/.config/systemd/user/{{ item }}"
src: "/dev/null" src: "/dev/null"
with_items: loop: "{{ undesired_user_services }}"
- gpg-agent.socket
- gpg-agent-browser.socket
- gpg-agent-ssh.socket
- gpg-agent-extra.socket
- name: create directory for getty autologin - name: create directory for getty autologin
file: file:
@@ -128,7 +134,7 @@
force: true force: true
follow: false follow: false
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
path: "/home/{{ user.name }}/.dotfiles" path: "/home/{{ user.name }}/.dotfiles"
src: "{{ playbook_dir }}" src: "{{ playbook_dir }}"
become: true become: true
@@ -161,7 +167,7 @@
state: directory state: directory
path: "{{ (['/home', user.name, item.to]|join('/')) | dirname }}" path: "{{ (['/home', user.name, item.to]|join('/')) | dirname }}"
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
with_items: "{{ dotfiles }}" with_items: "{{ dotfiles }}"
become: true become: true
become_user: root become_user: root
@@ -176,7 +182,7 @@
path: "/home/{{ user.name }}/{{ item.to }}" path: "/home/{{ user.name }}/{{ item.to }}"
src: /var/lib/dotfiles/{{ item.from }} src: /var/lib/dotfiles/{{ item.from }}
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
when: not item.template|default(false) when: not item.template|default(false)
with_items: "{{ dotfiles }}" with_items: "{{ dotfiles }}"
become: true become: true
@@ -211,7 +217,7 @@
src: /var/lib/dotfiles/{{ item.from }}.j2 src: /var/lib/dotfiles/{{ item.from }}.j2
dest: "/home/{{ user.name }}/{{ item.to }}" dest: "/home/{{ user.name }}/{{ item.to }}"
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
force: true force: true
become: true become: true
become_user: root become_user: root
@@ -220,16 +226,18 @@
loop_control: loop_control:
label: "{{ item.to }}" label: "{{ item.to }}"
- name: remove dotfiles
file:
state: absent
path: "/home/{{ user.name }}/{{ item }}"
loop: "{{ dotfiles_remove }}"
- name: create directories - name: create directories
file: file:
state: directory state: directory
path: "{{ item }}" path: "{{ item }}"
with_items: with_items:
- ~/tmp - ~/tmp
- ~/.var/lib
- ~/.var/log
- ~/.var/run
- ~/.usr/lib
- name: stat ~/bin - name: stat ~/bin
stat: stat:
@@ -253,7 +261,7 @@
path: "/home/{{ user.name }}/bin" path: "/home/{{ user.name }}/bin"
src: /var/lib/dotfiles/bin src: /var/lib/dotfiles/bin
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
tags: tags:
- dotfiles - dotfiles
@@ -274,7 +282,7 @@
src: contrib/vim-plug/plug.vim src: contrib/vim-plug/plug.vim
dest: ~/.local/share/nvim/site/autoload/plug.vim dest: ~/.local/share/nvim/site/autoload/plug.vim
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
mode: "0644" mode: "0644"
- name: install vim plugins - name: install vim plugins
@@ -401,7 +409,7 @@
path: "/home/{{ user.name }}/.config/systemd/user/{{ item | basename }}" path: "/home/{{ user.name }}/.config/systemd/user/{{ item | basename }}"
src: "{{ item }}" src: "{{ item }}"
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
with_fileglob: /var/lib/dotfiles/autostart/services/* with_fileglob: /var/lib/dotfiles/autostart/services/*
- name: get state of autostart.target - name: get state of autostart.target
@@ -422,7 +430,7 @@
src: ./autostart/autostart.target.j2 src: ./autostart/autostart.target.j2
dest: "/home/{{ user.name }}/.config/systemd/user/autostart.target" dest: "/home/{{ user.name }}/.config/systemd/user/autostart.target"
owner: "{{ user.name }}" owner: "{{ user.name }}"
group: "{{ user_group_name }}" group: "{{ user.name }}"
force: true force: true
follow: false follow: false

View File

@@ -1,8 +1,6 @@
#!/bin/bash #!/bin/bash
export LOGFILE="$LOGDIR/xinitrc.log" export LOGFILE="$XDG_RUNTIME_DIR/xinitrc.log"
mkdir -p "${LOGDIR}/i3"
log() { log() {
echo "[$(date +%FT%T)] $*" >> "$LOGFILE" echo "[$(date +%FT%T)] $*" >> "$LOGFILE"
@@ -25,7 +23,6 @@ start_wm() {
sleep 1 sleep 1
systemctl --user start autostart.target systemctl --user start autostart.target
sleep inf sleep inf
# exec systemd-run --user --unit i3_user --pty --setenv=DISPLAY=${DISPLAY} i3 -c "$HOME/.i3/config" >> "$LOGDIR/i3/i3.log"
} }
autostart() { autostart() {

View File

@@ -19,9 +19,6 @@ export LESS="FRX"
export WINEPATH="$HOME/games/wine" export WINEPATH="$HOME/games/wine"
export LOGDIR="$HOME/.var/log"
export RUNDIR="$HOME/.var/run"
export LIBDIR="$HOME/.var/lib"
export BINDIR="$HOME/bin" export BINDIR="$HOME/bin"
export LANG=en_US.UTF-8 export LANG=en_US.UTF-8
@@ -37,6 +34,17 @@ export ACPI_LID_NAME=LID
export QT_QPA_PLATFORMTHEME=qt5ct export QT_QPA_PLATFORMTHEME=qt5ct
export XDG_CONFIG_HOME="$HOME/.config"
export XDG_CACHE_HOME="$HOME/.cache"
export XDG_DATA_HOME="$HOME/.local/share"
export XDG_STATE_HOME="$HOME/.local/state"
export GNUPGHOME="$HOME/.gnupg"
export PASSWORD_STORE_DIR="$HOME/.password-store"
export GTK2_RC_FILES=${XDG_CONFIG_HOME}/gtkrc-2.0
umask 0022 umask 0022
{% set env = machine.environment | combine(user.environment) %} {% set env = machine.environment | combine(user.environment) %}
@@ -44,7 +52,7 @@ umask 0022
export {{ k }}="{{ v }}" export {{ k }}="{{ v }}"
{% endfor %} {% endfor %}
export FEATURE_DIR="${RUNDIR}/features/" export FEATURE_DIR="${XDG_RUNTIME_DIR}/features/"
rm -rf "${FEATURE_DIR}"/ rm -rf "${FEATURE_DIR}"/
mkdir -p "${FEATURE_DIR}" mkdir -p "${FEATURE_DIR}"

View File

@@ -1,45 +0,0 @@
setopt EXTENDED_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt AUTO_CD
setopt APPEND_HISTORY
setopt HIST_IGNORE_DUPS
setopt NOHIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt CORRECT
setopt RM_STAR_SILENT
setopt BG_NICE
setopt CHECK_JOBS
setopt HUP
setopt LONG_LIST_JOBS
setopt share_history
bindkey -e
autoload -U promptinit
promptinit
autoload -U colors
colors
autoload -U compinit
compinit
zstyle ':completion:*' menu select
setopt completealiases
autoload -U edit-command-line
zle -N edit-command-line
bindkey '^xe' edit-command-line
bindkey '^x^e' edit-command-line
HISTSIZE=10000
SAVEHIST=10000
HISTFILE="$HOME/.zsh_history"
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git hg
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:git*' formats "%{${fg[cyan]}%}[%{${fg[green]}%}%s%{${fg[cyan]}%}][%{${fg[blue]}%}%r/%S%%{${fg[cyan]}%}][%{${fg[blue]}%}%b%{${fg[yellow]}%}%m%u%c%{${fg[cyan]}%}]%{$reset_color%}"

View File

@@ -1,312 +0,0 @@
alias vim="nvim"
### BETTER COMMANDS
alias ls="exa --oneline --icons --group-directories-first"
alias ll='ls --all --long --classify --group --modified --time-style=long-iso --git'
alias la='ls --all'
alias spm="sudo pacman"
alias tml="tmux list-sessions"
alias tma="tmux ls 2>/dev/null && tmux attach-session || tmux"
alias tmn="tmux new-session -A -s"
alias clipc="xclip -selection primary"
alias clipo="xclip -out -selection clipboard"
alias rgrep="grep -r"
alias vimrc="vim -c ':e \$MYVIMRC'"
alias zshrc="vim -c ':e ~/.zshrc' ; source ~/.zshrc"
alias calc='python3 -ic "from math import *; import cmath"'
alias le_haxxor_1='clear && dmesg | pv -qL 20'
alias le_haxxor_2='clear && hexdump -C /dev/urandom | pv -qlL 2'
alias root='sudo -sE'
### USEFUL DEFAULT OPTIONS
alias tmux="tmux -2"
alias chmod="chmod -c"
alias chown="chown -c"
alias diff="diff --color=auto"
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias rg='rg --hidden --glob "!.git/**"'
alias rm='rm -v'
alias cp='cp -vi'
alias mv='mv -vi'
alias ln='ln -v'
alias du='du -h'
alias df='df -h'
### SHORTENING COMMAND NAMES
alias cs="cryptsetup"
alias v="vim"
alias g="git"
alias c="cd"
alias l="ls"
alias s="sudo"
alias cl="clear"
alias nocolor="sed -r \"s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g\""
alias ip="ip -color"
alias vimtask="vim -c :TW"
alias tw="task"
alias twl="task list"
alias twa="task add"
alias twd="task done"
alias inbox="task add +inbox"
alias yaml2json="python3 -c 'import sys, yaml, json; json.dump([d for d in yaml.safe_load_all(sys.stdin)][-1], sys.stdout, indent=4)'"
alias json2yaml="python3 -c 'import sys, yaml, json; yaml.safe_dump(json.loads(sys.stdin.read()), stream=sys.stdout)'"
alias currentbranch='git rev-parse --abbrev-ref HEAD'
alias issh="ssh -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null"
alias gfix='git commit --amend --no-edit'
alias gfixa='git commit --amend --no-edit --all '
alias gfixp='git commit --amend --no-edit --patch'
alias issh="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
alias newpw="pwgen --secure 25 1"
alias sys="systemctl"
alias sysu="systemctl --user"
alias gpg=gpg2
alias alacritty="alacritty --config-file $HOME/.config/alacritty.toml"
alias d=docker
alias dc=docker-compose
alias hx=helix
alias h=helix
gitmaster() {
git stash push -m gitmaster-$(date -uIseconds) -u || return 1
_branch=$(git rev-parse --abbrev-ref HEAD)
git fe || return 1
git checkout master || return 1
git merge origin/master || return 1
git checkout $_branch
git stash pop
}
_remote() {
[[ -n "$SSH_CONNECTION" ]]
}
cd() {
builtin cd "$@" && ls
}
mount() {
if [[ $# == 0 ]] ; then
command mount | column -t
else
command mount "$@"
fi
}
extr()
{
if [[ -f "$1" ]] ; then
case "$1" in
*.tar.bz2 ) tar xvjf "$1" ;;
*.tar.gz ) tar xvzf "$1" ;;
*.tar.xz ) tar xvJf "$1" ;;
*.bz2 ) bunzip2 "$1" ;;
*.rar ) unrar x "$1" ;;
*.gz ) gunzip "$1" ;;
*.tar ) tar xvf "$1" ;;
*.tbz2 ) tar xvjf "$1" ;;
*.tgz ) tar xvzf "$1" ;;
*.zip ) unzip "$1" ;;
*.Z ) uncompress "$1" ;;
*.7z ) 7z x "$1" ;;
*)
echo "$1 cannot be extracted via $0"
;;
esac
else
echo "$1 is not a valid file"
fi
}
ruler() {
for s in '....^....|' '1234567890'; do
w=${#s}
str=$(for (( i=1; $i<=$(( ($COLUMNS + $w) / $w )) ; i=$i+1 )); do echo -n $s; done )
str=$(echo $str | cut -c -$COLUMNS)
echo $str
done
}
addext() {
[[ -z "$1" ]] || [[ -z "$2" ]] && { echo "Usage: $0 <file> <extension>" ; return }
mv "$1" "$1$2"
}
rmext() {
[[ -e "$1" ]] && mv -i "$1" "${1%.*}"
}
ckwww() {
ping -c 3 www.google.com
}
httpcode() {
curl http://httpcode.info/$1
}
bak() {
if ! [[ "$1" ]] ; then
printf '%s\n' "usage: $0 FILE"
return 1
fi
if ! [[ -e "$1" ]] ; then
printf '%s\n' "\"$1\" not found"
return 1
fi
name="$1.$(date +%Y%m%d%H%M%S.bak)"
if [[ -e "${name}" ]] ; then
printf '%s\n' "Backup file \"$name\" already exists"
return 1
fi
cp --archive --verbose --no-clobber "$1" "${name}"
}
fstab() {
# yeah
expand /etc/fstab | grep -v '^#' | grep -P '^.+$' | tr -s ' ' | tr ' ' '|' | cat <(grep -P '<.+>' /etc/fstab | cut -f 2- -d ' ' | sed 's/>[^<]*</>|</g') - | column -ts '|'
}
serve() {
python3 -m http.server 8800
}
manpdf() {
[[ -z "$1" ]] && { printf '%s' >&2 "$(man)" ; return ; }
man -t "$1" | ps2pdf - - | zathura -
}
myip4() {
curl "http://ipv4.icanhazip.com"
}
myip6() {
curl "http://ipv6.icanhazip.com" 2>/dev/null || echo "no ip6"
}
diffdir() {
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
diff <(cd "$1" && find -type f -exec md5sum {} \;) <(cd "$2" && find -type f -exec md5sum {} \;)
}
diffdir2() {
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
comm -13 <(cd "$1" && find -type f | sort -g) <(cd "$2" && find -type f | sort -g)
}
bm() {
case "$1" in
dev)
cd "$HOME/development/projects"
;;
dot)
cd "$HOME/dotfiles"
;;
*)
echo "unknown target"
;;
esac
}
man() {
env LESS_TERMCAP_mb=$'\E[01;31m' \
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
LESS_TERMCAP_me=$'\E[0m' \
LESS_TERMCAP_se=$'\E[0m' \
LESS_TERMCAP_so=$'\E[38;5;246m' \
LESS_TERMCAP_ue=$'\E[0m' \
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
man "$@"
}
resolvecd() {
cd "$(readlink -f $(pwd))"
}
ssht () {
ssh -t $@ "tmux a || tmux";
}
t() {
if [[ "$1" ]] ; then
tmux new-session -A -s "$1"
else
tmux attach-session
fi
}
b() {
bookmarks=${DOTFILES}/bookmarks
bookmark="$1"
if ! [[ "${bookmark}" ]] ; then
printf 'Need a bookmark' >&2
return 1
fi
if ! [[ -r "${bookmark}" ]] ; then
printf 'Invalid bookmark %s' "${bookmark}" >&2
return 1
fi
target="$(head -1 ${bookmark})"
if ! [[ -e "${target}" ]] ; then
printf 'Traget not found: %s' "${target}" >&2
fi
cd "$(eval ${target})"
}
sb() {
echo $(( $1 * $(cat /sys/class/backlight/intel_backlight/max_brightness) / 100)) | sudo tee /sys/class/backlight/intel_backlight/brightness
}
clip() {
tee >(xclip -selection clipboard) | tee >(xclip -selection primary)
}
gb() {
_superproject="$(git rev-parse --show-superproject-working-tree)"
_root="$(git rev-parse --show-toplevel)"
if [[ -n "${_superproject}" ]] ; then
if [[ "$(pwd)" == "${_root}" ]] ; then
builtin cd "${_superproject}"
else
builtin cd "${_root}"
fi
else
builtin cd "${_root}"
fi
}
meetingnotes() {
[[ "${1}" ]] || return 1
file="$(date +%Y-%m-%d)-${1}.md"
cp ~/snippets/meetingnotes.md "${file}"
$EDITOR "${file}"
}

View File

@@ -1,246 +0,0 @@
_remote() {
[[ -n "$SSH_CONNECTION" ]]
}
cd() {
builtin cd "$@" && ls
}
mount() {
if [[ $# == 0 ]] ; then
command mount | column -t
else
command mount "$@"
fi
}
extr()
{
if [[ -f "$1" ]] ; then
case "$1" in
*.tar.bz2 ) tar xvjf "$1" ;;
*.tar.gz ) tar xvzf "$1" ;;
*.tar.xz ) tar xvJf "$1" ;;
*.bz2 ) bunzip2 "$1" ;;
*.rar ) unrar x "$1" ;;
*.gz ) gunzip "$1" ;;
*.tar ) tar xvf "$1" ;;
*.tbz2 ) tar xvjf "$1" ;;
*.tgz ) tar xvzf "$1" ;;
*.zip ) unzip "$1" ;;
*.Z ) uncompress "$1" ;;
*.7z ) 7z x "$1" ;;
*)
echo "$1 cannot be extracted via $0"
;;
esac
else
echo "$1 is not a valid file"
fi
}
ruler() {
for s in '....^....|' '1234567890'; do
w=${#s}
str=$(for (( i=1; $i<=$(( ($COLUMNS + $w) / $w )) ; i=$i+1 )); do echo -n $s; done )
str=$(echo $str | cut -c -$COLUMNS)
echo $str
done
}
addext() {
[[ -z "$1" ]] || [[ -z "$2" ]] && { echo "Usage: $0 <file> <extension>" ; return }
mv "$1" "$1$2"
}
rmext() {
[[ -e "$1" ]] && mv -i "$1" "${1%.*}"
}
ckwww() {
ping -c 3 www.google.com
}
httpcode() {
curl http://httpcode.info/$1
}
bak() {
if ! [[ "$1" ]] ; then
printf '%s\n' "usage: $0 FILE"
return 1
fi
if ! [[ -e "$1" ]] ; then
printf '%s\n' "\"$1\" not found"
return 1
fi
name="$1.$(date +%Y%m%d%H%M%S.bak)"
if [[ -e "${name}" ]] ; then
printf '%s\n' "Backup file \"$name\" already exists"
return 1
fi
cp --archive --verbose --no-clobber "$1" "${name}"
}
fstab() {
# yeah
expand /etc/fstab | grep -v '^#' | grep -P '^.+$' | tr -s ' ' | tr ' ' '|' | cat <(grep -P '<.+>' /etc/fstab | cut -f 2- -d ' ' | sed 's/>[^<]*</>|</g') - | column -ts '|'
}
serve() {
python3 -m http.server 8800
}
manpdf() {
[[ -z "$1" ]] && { printf '%s' >&2 "$(man)" ; return ; }
man -t "$1" | ps2pdf - - | zathura -
}
myip4() {
curl "http://ipv4.icanhazip.com"
}
myip6() {
curl "http://ipv6.icanhazip.com" 2>/dev/null || echo "no ip6"
}
diffdir() {
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
diff <(cd "$1" && find -type f -exec md5sum {} \;) <(cd "$2" && find -type f -exec md5sum {} \;)
}
diffdir2() {
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
comm -13 <(cd "$1" && find -type f | sort -g) <(cd "$2" && find -type f | sort -g)
}
bm() {
case "$1" in
dev)
cd "$HOME/development/projects"
;;
dot)
cd "$HOME/dotfiles"
;;
*)
echo "unknown target"
;;
esac
}
man() {
env LESS_TERMCAP_mb=$'\E[01;31m' \
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
LESS_TERMCAP_me=$'\E[0m' \
LESS_TERMCAP_se=$'\E[0m' \
LESS_TERMCAP_so=$'\E[38;5;246m' \
LESS_TERMCAP_ue=$'\E[0m' \
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
man "$@"
}
embiggen() {
enscript --no-header --media=A4 --landscape --font="DejaVuSansMono30" -o - 2>/dev/null | ps2pdf - | zathura -
}
resolvecd() {
cd "$(readlink -f $(pwd))"
}
ssht () {
ssh -t $@ "tmux a || tmux";
}
t() {
if [[ "$1" ]] ; then
tmux new-session -A -s "$1"
else
tmux attach-session
fi
}
b() {
bookmarks=${DOTFILES}/bookmarks
bookmark="$1"
if ! [[ "${bookmark}" ]] ; then
printf 'Need a bookmark' >&2
return 1
fi
if ! [[ -r "${bookmark}" ]] ; then
printf 'Invalid bookmark %s' "${bookmark}" >&2
return 1
fi
target="$(head -1 ${bookmark})"
if ! [[ -e "${target}" ]] ; then
printf 'Traget not found: %s' "${target}" >&2
fi
cd "$(eval ${target})"
}
sb() {
echo $(( $1 * $(cat /sys/class/backlight/intel_backlight/max_brightness) / 100)) | sudo tee /sys/class/backlight/intel_backlight/brightness
}
journal() {
journaldir=~/sync/journal/
file="$journaldir/$(date +%Y-%m-%d).md"
if [[ ! -e $file ]] ; then
cp $journaldir/template.md $file || return
fi
$EDITOR $file
}
syncfolder() {
folder=$1
mv $folder ~/sync
ln -s ~/sync/$folder ~/$folder
}
prefix() {
prefix=$2
file=$1
mv $file ${prefix}${file}
}
tmp() {
cd "$(mktemp -d)"
}
kubectl_pod() {
kubectl-env mycloud get -n "${1}" pods --field-selector=status.phase=Running --selector=${2} -o jsonpath='{.items[*].metadata.name}'
}
kubectl_deployment() {
kubectl-env mycloud get -n "${1}" deployment --selector=${2} -o jsonpath='{.items[*].metadata.name}'
}
# The semver_ checks are inspired by
# https://stackoverflow.com/questions/4023830/how-to-compare-two-strings-in-dot-separated-version-format-in-bash
semver_lte() {
v1="${1}"
v2="${2}"
printf '%s\n%s' "${v1}" "${v2}" | sort --version-sort --check=silent
}
semver_lt() {
v1="${1}"
v2="${2}"
semver_lte "${v1}" "${v2}" && [[ ! "${v1}" == "${v2}" ]]
}
semver_gte() {
v1="${1}"
v2="${2}"
! semver_lt "${v1}" "${v2}"
}
semver_gt() {
v1="${1}"
v2="${2}"
! semver_lte "${v1}" "${v2}"
}

View File

@@ -1,62 +0,0 @@
autoload -Uz vcs_info
_vcsbase="%{$fg[red]%}[%r] %{$fg[blue]%}[%{%B%}%b%{$fg[red]%}%m%{$fg[blue]%}] %{$fg[red]%}%{%B%}%c%u"
zstyle ':vcs_info:*' stagedstr 'I'
zstyle ':vcs_info:*' unstagedstr 'M'
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:git*' formats "$_vcsbase"
zstyle ':vcs_info:git*' actionformats "%{$fg[red]%}(%a) $_vcsbase"
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st git-remotebranch
+vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
[[ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') == 1 ]] ; then
hook_com[unstaged]+='?%f'
fi
}
+vi-git-st() {
local ahead behind
local -a gitstatus
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "+${ahead}" )
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "-${behind}" )
hook_com[misc]+=${(j:/:)gitstatus}
}
+vi-git-remotebranch() {
local remote
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
hook_com[branch]="${hook_com[branch]} %b%{$fg[magenta]%}<${remote}>"
fi
}
precmd() {
vcs_info
}
_topstr='%{$fg[green]%}%n@%m%{$fg[white]%} ─ %{%B$fg[yellow]%}%~%{%b%} ${vcs_info_msg_0_}%{$fg[white]%} '
botstr='%B${PINFO}%#%b '
if _remote ; then
_topstr="%{$fg[red]%}[remote]%{$fg[white]%} ${_topstr}"
fi
setopt prompt_subst
PROMPT='%{$fg[white]%}┌─ '"${_topstr}"'
└─ '"${botstr}"
RPROMPT="%{$fg[cyan]%}%*%{$fg[white]%} ─ [%?]"

View File

@@ -1,29 +0,0 @@
autoload zkbd
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
bindkey "\e[5~" beginning-of-history
bindkey "\e[6~" end-of-history
bindkey "\e[3~" delete-char
bindkey "\e[2~" quoted-insert
bindkey "\e[5C" forward-word
bindkey "\eOc" emacs-forward-word
bindkey "\e[5D" backward-word
bindkey "\eOd" emacs-backward-word
bindkey "\ee[C" forward-word
bindkey "\ee[D" backward-word
bindkey "^H" backward-delete-word
# for rxvt
bindkey "\e[8~" end-of-line
bindkey "\e[7~" beginning-of-line
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
# for freebsd console
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line
# completion in the middle of a line
bindkey '^i' expand-or-complete-prefix
export FZF_DEFAULT_OPTS='--height 50% --border'
eval "$(fzf --zsh)"

View File

@@ -1,18 +1,10 @@
[[ -z "$PS1" ]] && return [[ -z "$PS1" ]] && return
_zshdir="$HOME/.zshrc.d"
{% if user.gpg_agent %} {% if user.gpg_agent %}
export GPG_TTY=$(tty) export GPG_TTY=$(tty)
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket) export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
{% endif %} {% endif %}
for file in "${_zshdir}"/* ; do
if [[ -e "$file" ]] ; then
source "$file"
fi
done
if [[ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] ; then if [[ -f /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] ; then
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
elif [[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] ; then elif [[ -f /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ]] ; then
@@ -27,3 +19,458 @@ if [[ ! "$SSH_AUTH_SOCK" ]]; then
source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null source "$XDG_RUNTIME_DIR/ssh-agent.env" >/dev/null
fi fi
{% endif %} {% endif %}
{% raw %}
setopt EXTENDED_HISTORY
setopt HIST_EXPIRE_DUPS_FIRST
setopt HIST_VERIFY
setopt INC_APPEND_HISTORY
setopt SHARE_HISTORY
setopt AUTO_CD
setopt APPEND_HISTORY
setopt HIST_IGNORE_DUPS
setopt NOHIST_IGNORE_ALL_DUPS
setopt HIST_IGNORE_SPACE
setopt CORRECT
setopt RM_STAR_SILENT
setopt BG_NICE
setopt CHECK_JOBS
setopt HUP
setopt LONG_LIST_JOBS
setopt share_history
bindkey -e
autoload -U promptinit
promptinit
autoload -U colors
colors
autoload -U compinit
compinit
zstyle ':completion:*' menu select
setopt completealiases
autoload -U edit-command-line
zle -N edit-command-line
bindkey '^xe' edit-command-line
bindkey '^x^e' edit-command-line
HISTSIZE=100000
SAVEHIST=100000
HISTFILE="$HOME/.zsh_history"
alias vim="nvim"
### BETTER COMMANDS
alias ls="exa --oneline --icons --group-directories-first"
alias ll='ls --all --long --classify --group --modified --time-style=long-iso --git'
alias la='ls --all'
alias spm="sudo pacman"
alias tml="tmux list-sessions"
alias tma="tmux ls 2>/dev/null && tmux attach-session || tmux"
alias tmn="tmux new-session -A -s"
alias clipc="xclip -selection primary"
alias clipo="xclip -out -selection clipboard"
alias rgrep="grep -r"
alias calc='python3 -ic "from math import *; import cmath"'
alias le_haxxor_1='clear && dmesg | pv -qL 20'
alias le_haxxor_2='clear && hexdump -C /dev/urandom | pv -qlL 2'
alias root='sudo -sE'
### USEFUL DEFAULT OPTIONS
alias tmux="tmux -2"
alias chmod="chmod -c"
alias chown="chown -c"
alias diff="diff --color=auto"
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
alias rg='rg --hidden --glob "!.git/**"'
alias rm='rm -v'
alias cp='cp -vi'
alias mv='mv -vi'
alias ln='ln -v'
alias du='du -h'
alias df='df -h'
### SHORTENING COMMAND NAMES
alias cs="cryptsetup"
alias v="vim"
alias g="git"
alias c="cd"
alias l="ls"
alias s="sudo"
alias cl="clear"
alias nocolor="sed -r \"s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[mGK]//g\""
alias ip="ip -color"
alias vimtask="vim -c :TW"
alias tw="task"
alias twl="task list"
alias twa="task add"
alias twd="task done"
alias inbox="task add +inbox"
alias yaml2json="python3 -c 'import sys, yaml, json; json.dump([d for d in yaml.safe_load_all(sys.stdin)][-1], sys.stdout, indent=4)'"
alias json2yaml="python3 -c 'import sys, yaml, json; yaml.safe_dump(json.loads(sys.stdin.read()), stream=sys.stdout)'"
alias currentbranch='git rev-parse --abbrev-ref HEAD'
alias issh="ssh -o StrictHostKeyChecking=false -o UserKnownHostsFile=/dev/null"
alias gfix='git commit --amend --no-edit'
alias gfixa='git commit --amend --no-edit --all '
alias gfixp='git commit --amend --no-edit --patch'
alias issh="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"
alias newpw="pwgen --secure 25 1"
alias sys="systemctl"
alias sysu="systemctl --user"
alias gpg=gpg2
alias alacritty="alacritty --config-file $HOME/.config/alacritty.toml"
alias d=docker
alias dc=docker-compose
alias hx=helix
alias h=helix
alias wget="wget --hsts-file ${XDG_STATE_HOME}/wget-hsts"
gitmaster() {
git stash push -m gitmaster-$(date -uIseconds) -u || return 1
_branch=$(git rev-parse --abbrev-ref HEAD)
git fe || return 1
git checkout master || return 1
git merge origin/master || return 1
git checkout $_branch
git stash pop
}
_remote() {
[[ -n "$SSH_CONNECTION" ]]
}
cd() {
builtin cd "$@" && ls
}
mount() {
if [[ $# == 0 ]] ; then
command mount | column -t
else
command mount "$@"
fi
}
extr()
{
if [[ -f "$1" ]] ; then
case "$1" in
*.tar.bz2 ) tar xvjf "$1" ;;
*.tar.gz ) tar xvzf "$1" ;;
*.tar.xz ) tar xvJf "$1" ;;
*.bz2 ) bunzip2 "$1" ;;
*.rar ) unrar x "$1" ;;
*.gz ) gunzip "$1" ;;
*.tar ) tar xvf "$1" ;;
*.tbz2 ) tar xvjf "$1" ;;
*.tgz ) tar xvzf "$1" ;;
*.zip ) unzip "$1" ;;
*.Z ) uncompress "$1" ;;
*.7z ) 7z x "$1" ;;
*)
echo "$1 cannot be extracted via $0"
;;
esac
else
echo "$1 is not a valid file"
fi
}
ruler() {
for s in '....^....|' '1234567890'; do
w=${#s}
str=$(for (( i=1; $i<=$(( ($COLUMNS + $w) / $w )) ; i=$i+1 )); do echo -n $s; done )
str=$(echo $str | cut -c -$COLUMNS)
echo $str
done
}
addext() {
[[ -z "$1" ]] || [[ -z "$2" ]] && { echo "Usage: $0 <file> <extension>" ; return }
mv "$1" "$1$2"
}
rmext() {
[[ -e "$1" ]] && mv -i "$1" "${1%.*}"
}
ckwww() {
ping -c 3 www.google.com
}
httpcode() {
curl http://httpcode.info/$1
}
bak() {
if ! [[ "$1" ]] ; then
printf '%s\n' "usage: $0 FILE"
return 1
fi
if ! [[ -e "$1" ]] ; then
printf '%s\n' "\"$1\" not found"
return 1
fi
name="$1.$(date +%Y%m%d%H%M%S.bak)"
if [[ -e "${name}" ]] ; then
printf '%s\n' "Backup file \"$name\" already exists"
return 1
fi
cp --archive --verbose --no-clobber "$1" "${name}"
}
fstab() {
# yeah
expand /etc/fstab | grep -v '^#' | grep -P '^.+$' | tr -s ' ' | tr ' ' '|' | cat <(grep -P '<.+>' /etc/fstab | cut -f 2- -d ' ' | sed 's/>[^<]*</>|</g') - | column -ts '|'
}
serve() {
python3 -m http.server 8800
}
manpdf() {
[[ -z "$1" ]] && { printf '%s' >&2 "$(man)" ; return ; }
man -t "$1" | ps2pdf - - | zathura -
}
myip4() {
curl "http://ipv4.icanhazip.com"
}
myip6() {
curl "http://ipv6.icanhazip.com" 2>/dev/null || echo "no ip6"
}
diffdir() {
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
diff <(cd "$1" && find -type f -exec md5sum {} \;) <(cd "$2" && find -type f -exec md5sum {} \;)
}
diffdir2() {
[[ "$1" ]] && [[ "$2" ]] || { echo "$0 <dir1> <dir2>" ; return 1 ; }
comm -13 <(cd "$1" && find -type f | sort -g) <(cd "$2" && find -type f | sort -g)
}
man() {
env LESS_TERMCAP_mb=$'\E[01;31m' \
LESS_TERMCAP_md=$'\E[01;38;5;74m' \
LESS_TERMCAP_me=$'\E[0m' \
LESS_TERMCAP_se=$'\E[0m' \
LESS_TERMCAP_so=$'\E[38;5;246m' \
LESS_TERMCAP_ue=$'\E[0m' \
LESS_TERMCAP_us=$'\E[04;38;5;146m' \
man "$@"
}
resolvecd() {
cd "$(readlink -f $(pwd))"
}
ssht () {
ssh -t $@ "tmux a || tmux";
}
t() {
if [[ "$1" ]] ; then
tmux new-session -A -s "$1"
else
tmux attach-session
fi
}
sb() {
echo $(( $1 * $(cat /sys/class/backlight/intel_backlight/max_brightness) / 100)) | sudo tee /sys/class/backlight/intel_backlight/brightness
}
clip() {
tee >(xclip -selection clipboard) | tee >(xclip -selection primary)
}
gb() {
_superproject="$(git rev-parse --show-superproject-working-tree)"
_root="$(git rev-parse --show-toplevel)"
if [[ -n "${_superproject}" ]] ; then
if [[ "$(pwd)" == "${_root}" ]] ; then
builtin cd "${_superproject}"
else
builtin cd "${_root}"
fi
else
builtin cd "${_root}"
fi
}
bm() {
case "$1" in
dev)
cd "$HOME/development/projects"
;;
dot)
cd "$HOME/dotfiles"
;;
*)
echo "unknown target"
;;
esac
}
embiggen() {
enscript --no-header --media=A4 --landscape --font="DejaVuSansMono30" -o - 2>/dev/null | ps2pdf - | zathura -
}
journal() {
journaldir=~/sync/journal/
file="$journaldir/$(date +%Y-%m-%d).md"
if [[ ! -e $file ]] ; then
cp $journaldir/template.md $file || return
fi
$EDITOR $file
}
prefix() {
prefix=$2
file=$1
mv $file ${prefix}${file}
}
tmp() {
cd "$(mktemp -d)"
}
autoload -Uz vcs_info
_vcsbase="%{$fg[red]%}[%r] %{$fg[blue]%}[%{%B%}%b%{$fg[red]%}%m%{$fg[blue]%}] %{$fg[red]%}%{%B%}%c%u"
zstyle ':vcs_info:*' stagedstr 'I'
zstyle ':vcs_info:*' unstagedstr 'M'
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:git*' formats "$_vcsbase"
zstyle ':vcs_info:git*' actionformats "%{$fg[red]%}(%a) $_vcsbase"
zstyle ':vcs_info:git*+set-message:*' hooks git-untracked git-st git-remotebranch
+vi-git-untracked() {
if [[ $(git rev-parse --is-inside-work-tree 2> /dev/null) == 'true' ]] && \
[[ $(git ls-files --other --directory --exclude-standard | sed q | wc -l | tr -d ' ') == 1 ]] ; then
hook_com[unstaged]+='?%f'
fi
}
+vi-git-st() {
local ahead behind
local -a gitstatus
ahead=$(git rev-list ${hook_com[branch]}@{upstream}..HEAD 2>/dev/null | wc -l)
(( $ahead )) && gitstatus+=( "+${ahead}" )
behind=$(git rev-list HEAD..${hook_com[branch]}@{upstream} 2>/dev/null | wc -l)
(( $behind )) && gitstatus+=( "-${behind}" )
hook_com[misc]+=${(j:/:)gitstatus}
}
+vi-git-remotebranch() {
local remote
remote=${$(git rev-parse --verify ${hook_com[branch]}@{upstream} \
--symbolic-full-name 2>/dev/null)/refs\/remotes\/}
if [[ -n ${remote} ]] ; then
hook_com[branch]="${hook_com[branch]} %b%{$fg[magenta]%}<${remote}>"
fi
}
precmd() {
vcs_info
}
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git hg
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:git*' formats "%{${fg[cyan]}%}[%{${fg[green]}%}%s%{${fg[cyan]}%}][%{${fg[blue]}%}%r/%S%%{${fg[cyan]}%}][%{${fg[blue]}%}%b%{${fg[yellow]}%}%m%u%c%{${fg[cyan]}%}]%{$reset_color%}"
_topstr='%{$fg[green]%}%n@%m%{$fg[white]%} ─ %{%B$fg[yellow]%}%~%{%b%} ${vcs_info_msg_0_}%{$fg[white]%} '
botstr='%B${PINFO}%#%b '
if _remote ; then
_topstr="%{$fg[red]%}[remote]%{$fg[white]%} ${_topstr}"
fi
setopt prompt_subst
PROMPT='%{$fg[white]%}┌─ '"${_topstr}"'
└─ '"${botstr}"
RPROMPT="%{$fg[cyan]%}%*%{$fg[white]%} ─ [%?]"
autoload zkbd
bindkey "\e[1~" beginning-of-line
bindkey "\e[4~" end-of-line
bindkey "\e[5~" beginning-of-history
bindkey "\e[6~" end-of-history
bindkey "\e[3~" delete-char
bindkey "\e[2~" quoted-insert
bindkey "\e[5C" forward-word
bindkey "\eOc" emacs-forward-word
bindkey "\e[5D" backward-word
bindkey "\eOd" emacs-backward-word
bindkey "\ee[C" forward-word
bindkey "\ee[D" backward-word
bindkey "^H" backward-delete-word
# for rxvt
bindkey "\e[8~" end-of-line
bindkey "\e[7~" beginning-of-line
# for non RH/Debian xterm, can't hurt for RH/DEbian xterm
bindkey "\eOH" beginning-of-line
bindkey "\eOF" end-of-line
# for freebsd console
bindkey "\e[H" beginning-of-line
bindkey "\e[F" end-of-line
# completion in the middle of a line
bindkey '^i' expand-or-complete-prefix
export FZF_DEFAULT_OPTS='--height 50% --border'
eval "$(fzf --zsh)"
{% endraw %}