diff options
| author | Paul Buetow <paul@buetow.org> | 2025-06-14 23:39:45 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-06-14 23:39:45 +0300 |
| commit | 1795d0e31ac897a4e652f62b6d3e3b5a03b325e3 (patch) | |
| tree | 99ab086c4921087cffc3c2ad5cd5e6c7b0a35313 | |
| parent | 55e3295ea9337aa36c34b0dffb70e979d7d38c0e (diff) | |
remove zsh
32 files changed, 3 insertions, 1805 deletions
diff --git a/dotfiles/Rexfile b/dotfiles/Rexfile index 39ee3f6..72fd9b7 100644 --- a/dotfiles/Rexfile +++ b/dotfiles/Rexfile @@ -53,7 +53,6 @@ task 'pkg_termux', sub { ruby starship tig - zsh /; for my $pkg (@pkgs) { @@ -79,7 +78,6 @@ task 'pkg_freebsd', sub { starship tig tmux - zsh /; for my $pkg (@pkgs) { @@ -122,7 +120,6 @@ task 'pkg_fedora', sub { vit tig tmux - zsh dialect chromium strawberry @@ -157,12 +154,6 @@ task 'home_vit', sub { ensure "$DOT/vit/config.ini" => "$HOME/.vit/config.ini", '0600'; }; -desc 'Install ZSH configuration'; -task 'home_zsh', sub { - ensure "$DOT/zsh/zshrc" => "$HOME/.zshrc"; - ensure "$DOT/zsh/zshrc_d/*" => "$HOME/.zshrc_d/"; -}; - desc 'Install BASH configuration'; task 'home_bash', sub { ensure "$DOT/bash/bash_profile" => "$HOME/.bash_profile"; diff --git a/dotfiles/helix/config.toml b/dotfiles/helix/config.toml index 82d62bf..7f8de78 100644 --- a/dotfiles/helix/config.toml +++ b/dotfiles/helix/config.toml @@ -1,4 +1,4 @@ -theme = "catppuccin_frappe" +theme = "default" [editor] bufferline = "always" diff --git a/dotfiles/helix/languages.toml b/dotfiles/helix/languages.toml index e4a7110..c5c6e8a 100644 --- a/dotfiles/helix/languages.toml +++ b/dotfiles/helix/languages.toml @@ -41,7 +41,8 @@ command = "golangci-lint-langserver" # golangci-lint-langserver depepds/calls golangci-lint # go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest [language-server.golangci-lint-lsp.config] -command = ["golangci-lint", "run", "--out-format", "json", "--issues-exit-code=1"] +command = ["golangci-lint", "run", "--issues-exit-code=1"] +# command = ["golangci-lint", "run", "--out-format", "json", "--issues-exit-code=1"] [[language]] name = "c" diff --git a/dotfiles/zsh/zshrc b/dotfiles/zsh/zshrc deleted file mode 100644 index c4925c6..0000000 --- a/dotfiles/zsh/zshrc +++ /dev/null @@ -1,196 +0,0 @@ - # Use fish if it's installed and it's an interactive session -if [[ ! -z "$PS1" && ! -f $HOME/.nofish ]]; then - if [ -e /opt/homebrew/bin/fish ]; then - exec /opt/homebrew/bin/fish - elif [ -e /bin/fish ]; then - exec /bin/fish - elif [ -e /usr/bin/fish ]; then - exec /usr/bin/fish - elif [ -e /data/data/com.termux/files/usr/bin/fish ]; then - exec /data/data/com.termux/files/usr/bin/fish - fi - - echo 'I might want to install fish on this host' -fi - -if [[ ! -n "$TMUX" && ! -f ~/.tmux.disable ]]; then - source ~/.zshrc_d/tmux.source.zsh - tmux::new -fi - -export HISTSIZE=999999 -export SAVEHIST=999999 -export HISTFILE=~/.zsh_history -export UNAME=$(uname) -export UNAME_R=$(uname -r) - -addpath_recursive () { - readonly bin=$1 - - if [ -e $bin ]; then - find $bin -maxdepth 2 -type d | while read dir; do - grep -q '\.' <<< "$dir" || export PATH=$PATH:$dir - done - fi -} - -addpath_if () { - readonly addif=$1 - - if [ -d $addif ]; then - export PATH=$PATH:$addif - fi -} - -addpath_if_front () { - readonly addif=$1 - - if [ -d $addif ]; then - export PATH=$addif:$PATH - fi -} - -addpath_if $GOPATH/bin -addpath_if $HOME/bin -addpath_if $HOME/scripts -addpath_if $HOME/.local/bin -addpath_if $HOME/.npm/node_modules/.bin -addpath_if $HOME/.cargo/bin -addpath_if $HOME/pkg/bin -addpath_if /usr/games -addpath_if /usr/local/go/bin -addpath_if /usr/local/scripts -addpath_recursive /opt/bin/ -addpath_recursive /opt/snonux/bin/ -addpath_recursive /opt/snonux/local/bin/ -addpath_if_front /opt/local/bin/ -addpath_if_front $HOME/go/bin -addpath_if . - -export PATH=$PATH:/sbin:/usr/sbin:/usr/local/sbin -export CDPATH=$CDPATH:$HOME - -for dir in \ - ~/svn ~/svn/modules \ - ~/git ~/git/java ~/git/foo.zone-content/gemtext \ - ~/src \ - ~/Notes ~/Data ~/data; do - test -d $dir && export CDPATH=$CDPATH:$dir -done - -setopt histignorealldups sharehistory -setopt nobeep # never ever beep -setopt autocd # running /etc actually does a cd /etc -setopt cdablevars # avoid the need for an explicit $ in cd -setopt listtypes # show types in completion -setopt extendedglob # weird & wacky pattern matching - yay zsh! -setopt correct # spelling correction -setopt histverify # when using ! cmds, confirm first -setopt printexitvalue # alert me if something's failed - -bindkey -v -bindkey "^R" history-incremental-search-backward - -autoload -Uz compinit -compinit - -autoload edit-command-line; zle -N edit-command-line -bindkey -M vicmd v edit-command-line - -zstyle ':completion:*' auto-description 'specify: %d' -zstyle ':completion:*' completer _expand _complete _correct _approximate -zstyle ':completion:*' format 'Completing %d' -zstyle ':completion:*' group-name '' -zstyle ':completion:*' menu select=2 -zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} -zstyle ':completion:*' list-colors '' -zstyle ':completion:*' list-prompt %SAt %p: Hit TAB for more, or the character to insert%s -zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' -zstyle ':completion:*' menu select=long -zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s -zstyle ':completion:*' use-compctl false -zstyle ':completion:*' verbose true -zstyle ':completion:*:kill:*' menu yes select -zstyle ':completion:*:kill:*' force-list always -zstyle ':completion:*:processes' command 'ps x -o pid,pcpu,tt,args' - -alias ll='ls -trl' -alias la='ls -fA' -alias l='ls -CF' -alias ..='cd ..' -alias ...='cd ../..' -alias ....='cd ../../..' -alias s=sudo -alias d=doas -alias tomorrow='date +%Y%m%d --date tomorrow' -alias ttomorrow='date +%Y%m%d --date "2 days"' -alias tttomorrow='date +%Y%m%d --date "3 days"' -alias today='date +%Y%m%d' -alias today2='date +%Y-%m-%d' -alias yesterday='date +%Y%m%d --date yesterday' -alias yyesterday='date +%Y%m%d --date "2 days ago"' -alias yyyesterday='date +%Y%m%d --date "3 days ago"' -alias rsync_nostrict='rsync -e "ssh -o StrictHostKeyChecking=no"' -alias g='grep -E -i' -alias not='grep -E -i -v' -alias ro='fgrep " ro," /proc/mounts' -alias pl='pgrep -lf' -alias pf='pgrep -f' -alias first='awk "{ print \$1 }"' -alias fst=first -alias second='awk "{ print \$2 }"' -alias snd=second -alias third='awk "{ print \$3 }"' -alias thrd=third -alias lst='awk "{ print \$(NF) }"' -alias llst='awk "{ print \$(NF-1) }"' -alias lllst='awk "{ print \$(NF-2) }"' -alias se='cut -d"|" -f2' - -rcloader::prepare () { - local -r all_rcs="$1"; shift - - touch "$all_rcs.tmp" && chmod 600 "$all_rcs.tmp" - - for rcdir in $HOME/.zshrc_d/ \ - $HOME/.zshrc_{local,private,private_local,work,work_local}_d/; do - if [ ! -e "$rcdir" ]; then - continue - fi - - find "$rcdir" -name \*.source.zsh -type f -empty delete - find "$rcdir" -name \*.source.zsh -type f | sort | - while read -r rcfile; do - echo "Preparing $rcfile" >&2 - cat "$rcfile" - echo - done - [ -f ~/.zshrc_local ] && cat ~/.zshrc_local - - done > "$all_rcs".tmp - mv "$all_rcs".tmp "$all_rcs" -} - -rcloader::load () { - # Speeding up loading ZSH on the mac (Security scanners) - local -r all_rcs=~/.zshrc_d_all.source - - if [ ! -f "$all_rcs" ]; then - rcloader::prepare "$all_rcs" - fi - - source "$all_rcs" -} -alias loadzsh='rm ~/.zshrc_d_all.source; source ~/.zshrc' - -rcloader::load - -test "$UNAME" = FreeBSD && zpool list - -if [ -f ~/motd ]; then - echo - echo "Local message of the day:" - cat ~/motd -fi - -supersync::is_it_time_to_sync diff --git a/dotfiles/zsh/zshrc_d/addons.source.zsh b/dotfiles/zsh/zshrc_d/addons.source.zsh deleted file mode 100644 index b77bfbf..0000000 --- a/dotfiles/zsh/zshrc_d/addons.source.zsh +++ /dev/null @@ -1,32 +0,0 @@ -addon::zsh::autosuggestions::init () { - zsh_autosuggestions_path=/usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh - if [ Darwin = $UNAME ]; then - zsh_autosuggestions_path=$(brew --prefix)/share/zsh-autosuggestions/zsh-autosuggestions.zsh - fi - if [ -f $zsh_autosuggestions_path ]; then - source "$zsh_autosuggestions_path" - else - echo 'zsh-autosuggestions not found' - fi -} - -# Make up and down arrow take what’s typed on the commandline in to account. -# E.g. if you type ls and press up it will only find history entries that start with ls: -addon::history () { - autoload -Uz up-line-or-beginning-search down-line-or-beginning-search - - zle -N up-line-or-beginning-search - zle -N down-line-or-beginning-search - - bindkey '^[[A' up-line-or-beginning-search # Arrow up - bindkey '^[OA' up-line-or-beginning-search - bindkey '^[[B' down-line-or-beginning-search # Arrow down - bindkey '^[OB' down-line-or-beginning-search -} - -addon::init () { - addon::zsh::autosuggestions::init - addon::history -} - -addon::init diff --git a/dotfiles/zsh/zshrc_d/ai.source.zsh b/dotfiles/zsh/zshrc_d/ai.source.zsh deleted file mode 100644 index dfddff2..0000000 --- a/dotfiles/zsh/zshrc_d/ai.source.zsh +++ /dev/null @@ -1,20 +0,0 @@ -# AI tools in here need API keys to be configured. That's -# not done automatically through Rex yet. - -ai::chatgpt () { - chatgpt "$@" | less -} - -alias gpt=ai::chatgpt -alias gpti='chatgpt --interactive' - -copilot::suggest () { - gh copilot suggest "$@" -} - -copilot::explain () { - gh copilot explain "$@" -} - -alias suggest=copilot::suggest -alias explain=copilot::explain diff --git a/dotfiles/zsh/zshrc_d/aliases.source.zsh b/dotfiles/zsh/zshrc_d/aliases.source.zsh deleted file mode 100644 index 8b13789..0000000 --- a/dotfiles/zsh/zshrc_d/aliases.source.zsh +++ /dev/null @@ -1 +0,0 @@ - diff --git a/dotfiles/zsh/zshrc_d/alternatives.source.zsh b/dotfiles/zsh/zshrc_d/alternatives.source.zsh deleted file mode 100644 index 55e7487..0000000 --- a/dotfiles/zsh/zshrc_d/alternatives.source.zsh +++ /dev/null @@ -1,25 +0,0 @@ -alternatives::aliases () { - grep alias ~/.zshrc_d/alternatives.source.zsh -} - -alternatives::init () { - if command -v bat; then - alias Cat=/usr/bin/cat - alias cat=bat - fi - - if command -v bit; then - alias Git=/usr/bin/git - alias git=bit - fi - - if command -v procs; then - alias p='procs' - fi - - if command -v zoxide; then - source <(zoxide init zsh) - fi -} - -alternatives::init diff --git a/dotfiles/zsh/zshrc_d/bashforwindows.source.zsh b/dotfiles/zsh/zshrc_d/bashforwindows.source.zsh deleted file mode 100644 index b532f2c..0000000 --- a/dotfiles/zsh/zshrc_d/bashforwindows.source.zsh +++ /dev/null @@ -1,6 +0,0 @@ -if [[ $UNAME_R =~ Microsoft ]]; then - winopen () { - local -r file=$(readlink -f "$1" | sed 's/\//\\/g') - cmd.exe /c start "%localappdata%\\lxss\\$file" - } -fi diff --git a/dotfiles/zsh/zshrc_d/dotfiles.source.zsh b/dotfiles/zsh/zshrc_d/dotfiles.source.zsh deleted file mode 100644 index 423fa87..0000000 --- a/dotfiles/zsh/zshrc_d/dotfiles.source.zsh +++ /dev/null @@ -1,57 +0,0 @@ -export DOTFILES_DIR=~/git/rexfiles/dotfiles - -dotfiles::update () { - local -r prev_pwd="$(pwd)" - cd $DOTFILES_DIR - rex home - cd "$prev_pwd" -} -alias .u=dotfiles::update - -dotfiles::update::git () { - local -r prev_pwd="$(pwd)" - cd $DOTFILES_DIR - git pull - git commit -a - git push - rex home - loadzsh - cd "$prev_pwd" -} -alias .ug=dotfiles::update::git - -dotfiles::fuzzy::edit () { - local -r prev_pwd="$(pwd)" - cd $DOTFILES_DIR - local -r dotfile="$(find . -type f -not -path '*/.git/*' | fzf)" - $EDITOR "$dotfile" - if grep -F -q source.zsh <<< "$dotfile"; then - echo "Sourcing $dotfile" - source "$dotfile" - fi - cd "$prev_pwd" -} -alias .e=dotfiles::fuzzy::edit - -dotfiles::visual () { - local -r prev_pwd="$(pwd)" - cd $DOTFILES_DIR - $VISUAL - cd "$prev_pwd" -} -alias .v=dotfiles::visual - -dotfiles::rexify () { - local -r prev_pwd="$(pwd)" - cd ~/git/rexfiles/dotfiles/ - rex home - cd "$prev_pwd" -} -alias .rex=dotfiles::rexify - -dotfiles::random::edit () { - cd $DOTFILES_DIR - $EDITOR $(find . -type f | sort -R | head -n 1) - cd - -} -alias .re=dotfiles::random::edit diff --git a/dotfiles/zsh/zshrc_d/editor.source.zsh b/dotfiles/zsh/zshrc_d/editor.source.zsh deleted file mode 100644 index 818ee0d..0000000 --- a/dotfiles/zsh/zshrc_d/editor.source.zsh +++ /dev/null @@ -1,72 +0,0 @@ -export EDITOR=hx -export VISUAL=$EDITOR -export GIT_EDITOR=$EDITOR -export HELIX_CONFIG_DIR=$HOME/.config/helix - -# For https://github.com/leona/helix-gpt/blob/master/src/config.ts -# export OPENAI_MODEL=gpt-4o -# export OPENAI_MAX_TOKENS=14000 -export COPILOT_MODEL=gpt-4o -export HANDLER=copilot - -editor::helix::theme::get_random () { - for dir in $(hx --health \ - | awk '/^Runtime directories/ { print $3 }' | tr ';' ' '); do - if [ -d $dir/themes ]; then - ls $dir/themes - fi - done | grep -F .toml | sort -R | head -n 1 | cut -d. -f1 -} - -editor::helix::theme::set () { - local -r theme="$1"; shift - - local -r config_file=$HELIX_CONFIG_DIR/config.toml - - sed "/^theme =/ { s/.*/theme = \"$theme\"/; }" \ - $config_file > $config_file.tmp && - mv $config_file.tmp $config_file -} - -editor::helix::open_with_lock () { - local -r file="$1"; shift - local -r lock="$file.lock" - - if [ -f "$lock" ]; then - if pgrep -f hx; then - echo "File lock $lock exists! Another instance is editing it?" - return 2 - fi - fi - - touch $lock - hx $file $@ - rm $lock -} -alias hxl=editor::helix::open_with_lock - -editor::helix::edit::remote () { - local -r local_path="$1"; shift - local -r remote_uri="$1"; shift - - scp $local_path $remote_uri || return 1 - - cat <<END >~/.hx.remote.source -LOCAL_PATH=$local_path -REMOTE_URI=$remote_uri -END - hx $local_path -} -alias rhx=editor::helix::edit::remote - -if [ -f $HELIX_CONFIG_DIR/config.toml ]; then - editor::helix::theme::set $(editor::helix::theme::get_random) -fi - -alias -s txt=$EDITOR -alias -s pp=$EDITOR -alias -s json=$EDITOR -alias -s xml=$EDITOR -alias -s erb=$EDITOR -alias -s c=$EDITOR -alias -s rb=$EDITOR diff --git a/dotfiles/zsh/zshrc_d/games.source.zsh b/dotfiles/zsh/zshrc_d/games.source.zsh deleted file mode 100644 index 62f7b74..0000000 --- a/dotfiles/zsh/zshrc_d/games.source.zsh +++ /dev/null @@ -1,21 +0,0 @@ -games::funky () { - while :; do - printf "\e[%d;%dH\e[48;5;%dm \e[0m" $(($RANDOM%$LINES)) $(($RANDOM%$COLUMNS)) $(($RANDOM%216 )) - done -} - -games::colorscript () { - if [ -e ~/git/shell-color-scripts ]; then - cd ~/git/shell-color-scripts - DEV=1 ./colorscript.sh --random - cd - - else - # https://gitlab.com/dwt1/shell-color-scripts - echo 'No colorscripts installed. Go to:' - echo ' https://gitlab.com/dwt1/shell-color-scripts' - fi -} - -if [ ! -f ~/.colorscript.disable ]; then - games::colorscript -fi diff --git a/dotfiles/zsh/zshrc_d/gemtexter.source.zsh b/dotfiles/zsh/zshrc_d/gemtexter.source.zsh deleted file mode 100644 index d1bcdf3..0000000 --- a/dotfiles/zsh/zshrc_d/gemtexter.source.zsh +++ /dev/null @@ -1,44 +0,0 @@ -export GEMTEXTER_DIR=$HOME/git/gemtexter - -if [ -d $GEMTEXTER_DIR ]; then - export GEMTEXTER_FOO_DIR=$HOME/git/foo.zone-content/gemtext - - gemtexter::edit () { - local -r dir="$1"; shift - - cd $dir - $VISUAL "$(find . -type f -not -path '*/.git/*' | fzf)" - git::quickpush - cd - - } - - gemtexter::publish () { - local -r config_file="$1"; shift - - cd "$GEMTEXTER_DIR" - CONFIG_FILE_PATH="$config_file" ./gemtexter --publish - cd - - } - - gemtexter::publish::file () { - local -r file="$1"; shift - - cd "$GEMTEXTER_DIR" - ./gemtexter --generate "$file" - ./gemtexter --git - ./post_publish_hook.sh - cd - - } - - gemtexter::foo::edit () { - gemtexter::edit "$GEMTEXTER_FOO_DIR" - } - alias .gfe=gemtexter::foo::edit - alias .gfp=gemtexter::publish "$GEMTEXTER_DIR/gemtexter.conf" - alias .gff=gemtexter::publish::file - - gemtexter::random::note () { - amfora $(find ~/git/foo.zone-content/gemtext/notes -name \*.gmi | sort -R | head -n 1 | sed 's|.*foo.zone-content/gemtext|gemini://foo.zone/|') - } - alias .grn=gemtexter::random::note -fi diff --git a/dotfiles/zsh/zshrc_d/git.source.zsh b/dotfiles/zsh/zshrc_d/git.source.zsh deleted file mode 100644 index 0a24b1a..0000000 --- a/dotfiles/zsh/zshrc_d/git.source.zsh +++ /dev/null @@ -1,20 +0,0 @@ -git::log () { - git log --graph --decorate --all -} - -git::log::oneline () { - git log --pretty=oneline --graph --decorate --all -} -alias gl=git::log::oneline - -# Delete local branches which were merged into master. -git::prune () { - git branch --merged master | grep -F -v master | xargs -n 1 git branch -d -} - -git::quickpush () { - git commit -a - git pull - git push -} -alias gp=git::quickpush diff --git a/dotfiles/zsh/zshrc_d/gos.source.zsh b/dotfiles/zsh/zshrc_d/gos.source.zsh deleted file mode 100644 index d36f4e4..0000000 --- a/dotfiles/zsh/zshrc_d/gos.source.zsh +++ /dev/null @@ -1,6 +0,0 @@ -export GOS_BIN=~/go/bin/gos -export GOS_DIR=~/.gosdir - -if [ -f $GOS_BIN ]; then - alias cdgos="cd $GOS_DIR" -fi diff --git a/dotfiles/zsh/zshrc_d/lsof.source.zsh b/dotfiles/zsh/zshrc_d/lsof.source.zsh deleted file mode 100644 index 36bdb0d..0000000 --- a/dotfiles/zsh/zshrc_d/lsof.source.zsh +++ /dev/null @@ -1,4 +0,0 @@ -lsof::listening () { - local pid=$1 - sudo lsof -p $pid -a -i -sTCP:LISTEN -P -} diff --git a/dotfiles/zsh/zshrc_d/media.source.zsh b/dotfiles/zsh/zshrc_d/media.source.zsh deleted file mode 100644 index 2b376c4..0000000 --- a/dotfiles/zsh/zshrc_d/media.source.zsh +++ /dev/null @@ -1,3 +0,0 @@ -media::aaxtom4b () { - bash ~/git/AAXtoM4B/AAXtoMP3 -e:m4b --authcode $AC $@ -} diff --git a/dotfiles/zsh/zshrc_d/news.source.zsh b/dotfiles/zsh/zshrc_d/news.source.zsh deleted file mode 100644 index e69de29..0000000 --- a/dotfiles/zsh/zshrc_d/news.source.zsh +++ /dev/null diff --git a/dotfiles/zsh/zshrc_d/notes.source.zsh b/dotfiles/zsh/zshrc_d/notes.source.zsh deleted file mode 100644 index 3778d0c..0000000 --- a/dotfiles/zsh/zshrc_d/notes.source.zsh +++ /dev/null @@ -1,37 +0,0 @@ -declare NOTES_DIR=~/Notes - -if [ -e $NOTES_DIR ]; then - notes::edit () { - cd ~/Notes - $VISUAL "$(find . -type f | fzf)" - cd - - } - - alias ,ne=notes::edit - alias cdnodes="cd $NOTES_DIR" - - notes::quick () { - local -r name="$1"; shift - local -r file="$NOTES_DIR/$name.md" - if [ ! -f "$file" ]; then - echo "# $name" >> "$file" - fi - $EDITOR "$file" - } - alias ,nq=notes::quick - - notes::quick::find () { - local -r name="$1"; shift - local -r note="$(find $NOTES_DIR/ -iname "*$name*.md" | head -n 1)" - - if [ ! -f "$note" ]; then - echo "Could not find any note in $NOTES_DIR" - return - fi - - $EDITOR $note - } - - alias ,nf=notes::quick::find - alias ,nr="ranger $NOTES_DIR" -fi diff --git a/dotfiles/zsh/zshrc_d/pass.source.zsh b/dotfiles/zsh/zshrc_d/pass.source.zsh deleted file mode 100644 index b740e61..0000000 --- a/dotfiles/zsh/zshrc_d/pass.source.zsh +++ /dev/null @@ -1,40 +0,0 @@ -pass::commit () { - cd ~/.password-store || return 3 - git add -A . - git commit -a -m "@$" - cd - &>/dev/null -} - -pass::push () { - cd ~/.password-store || return 3 - git push $@ - cd - &>/dev/null -} - -pass::pw () { - if [ $1 = commit ]; then - shift - pass::commit $@ - elif [ $1 = push ]; then - shift - pass::push $@ - elif [ $1 = new ]; then - shift - pass::commit $@ - pass::push origin master - elif [ $1 = s ]; then - shift - pass search $@ - else - pass $@ - fi -} - -if [ -f ~/git/geheim/geheim.rb ]; then - alias geheim='ruby ~/git/geheim/geheim.rb' - geheim::setpin () { - read PIN - export PIN - } -fi - diff --git a/dotfiles/zsh/zshrc_d/prompt.source.zsh b/dotfiles/zsh/zshrc_d/prompt.source.zsh deleted file mode 100644 index 0c557ca..0000000 --- a/dotfiles/zsh/zshrc_d/prompt.source.zsh +++ /dev/null @@ -1,6 +0,0 @@ -where starship &>/dev/null -if [ $? -eq 0 ]; then - eval "$(starship init zsh)" -else - echo 'starship not installed' -fi diff --git a/dotfiles/zsh/zshrc_d/quicknotes.source.zsh b/dotfiles/zsh/zshrc_d/quicknotes.source.zsh deleted file mode 100644 index e69de29..0000000 --- a/dotfiles/zsh/zshrc_d/quicknotes.source.zsh +++ /dev/null diff --git a/dotfiles/zsh/zshrc_d/rakuandperl.source.zsh b/dotfiles/zsh/zshrc_d/rakuandperl.source.zsh deleted file mode 100644 index bdbc0f0..0000000 --- a/dotfiles/zsh/zshrc_d/rakuandperl.source.zsh +++ /dev/null @@ -1,4 +0,0 @@ -if [ -d $HOME/.rakubrew ]; then - export PATH=$HOME/.rakubrew/bin:$PATH - export PATH=$HOME/.rakubrew/shims:$PATH -fi diff --git a/dotfiles/zsh/zshrc_d/ssh.source.zsh b/dotfiles/zsh/zshrc_d/ssh.source.zsh deleted file mode 100644 index e69de29..0000000 --- a/dotfiles/zsh/zshrc_d/ssh.source.zsh +++ /dev/null diff --git a/dotfiles/zsh/zshrc_d/sshauth.source.zsh b/dotfiles/zsh/zshrc_d/sshauth.source.zsh deleted file mode 100644 index 5c4431a..0000000 --- a/dotfiles/zsh/zshrc_d/sshauth.source.zsh +++ /dev/null @@ -1,4 +0,0 @@ -if [[ -S "$SSH_AUTH_SOCK" && ! -h "$SSH_AUTH_SOCK" ]]; then - ln -sf "$SSH_AUTH_SOCK" ~/.ssh/ssh_auth_sock; -fi -export SSH_AUTH_SOCK=~/.ssh/ssh_auth_sock; diff --git a/dotfiles/zsh/zshrc_d/supersync.source.zsh b/dotfiles/zsh/zshrc_d/supersync.source.zsh deleted file mode 100644 index 06a9fbc..0000000 --- a/dotfiles/zsh/zshrc_d/supersync.source.zsh +++ /dev/null @@ -1,26 +0,0 @@ -export SUPERSYNC_STAMP_FILE=~/.supersync.last - -supersync::is_it_time_to_sync () { - local max_age=86400 - local now=$(date +%s) - if [[ -f $SUPERSYNC_STAMP_FILE ]]; then - local diff=$(( now - $(cat $SUPERSYNC_STAMP_FILE) )) - if [[ $diff -lt $max_age ]]; then - return 0 - fi - fi - echo 'It is time to run supersync!!!' -} - -supersync::sync () { - worktime::sync - uprecords::sync - task::sync - if [[ -f $GOS_BIN ]]; then - gos - fi - date +%s > $SUPERSYNC_STAMP_FILE.tmp - mv $SUPERSYNC_STAMP_FILE.tmp $SUPERSYNC_STAMP_FILE -} - -alias supersync='supersync::sync' diff --git a/dotfiles/zsh/zshrc_d/task.source.zsh b/dotfiles/zsh/zshrc_d/task.source.zsh deleted file mode 100644 index 1eedc9d..0000000 --- a/dotfiles/zsh/zshrc_d/task.source.zsh +++ /dev/null @@ -1,278 +0,0 @@ -if [[ -f ~/.taskrc && -f ~/.task.enable ]]; then - alias t='task' - - export DATE=$(command -v gdate || echo date) - if ! $DATE --version | grep -q -v GNU; then - echo 'GNU Date not installed' - fi - - _task::config () { - local -r message="$1"; shift - if [ "$TASK_AUTO_CONFIRM" = yes ]; then - echo "Auto confirming" - return 0 - fi - # bash: - # read -p "$message? (y/n)" answer - # zsh: - read "answer?$message? (y/n)" - if [ "$answer" = y ]; then - return 0 - else - return 1 - fi - } - - alias tdue='vit status:pending due.before:now' - alias thome='vit +home' - alias tasks='vit -track' - - task::due::count () { - local -i due_count=$(task status:pending due.before:now count) - if [ $due_count -gt 0 ]; then - echo "There are $due_count tasks due!" - fi - } - task::due::count - - task::done () { - task::select "$1" - task $TASK_ID - if _task::config "Mark task $TASK_ID as done"; then - task $TASK_ID done - task::due - fi - } - alias tdone=task::done - - task::edit () { - task::select "$1" - task $TASK_ID edit - } - alias tedit=task::edit - - task::url::open () { - task::select "$1" - local -r desc=$(task +track status:pending export | jq -r '.[].description') - local -r url=$(extractUrlFromString "$desc") - open -a "Google Chrome" "$url" - } - - extractUrlFromString () { - local -r str="$1" - local -r regex="(https?://[a-zA-Z0-9.-]+(/[a-zA-Z0-9._%+-/?&=]*))" - if [[ $str =~ $regex ]]; then - echo "${BASH_REMATCH[1]}" - else - echo "No URL found" - fi - } - - task::del () { - task::select "$1" - task $TASK_ID delete - } - alias tdel=task::del - - task::start () { - task::select "$1" - task $TASK_ID start - } - alias tstart=task::start - - task::stop () { - task::select "$1" - task $TASK_ID stop - } - alias tstop=task::stop - - task::annotate () { - task::select "$1"; shift - task $TASK_ID annotate "$@" - } - alias tanon=task::annotate - - task::random::due_date () { - local -i seed="$1" - local -i due_days=$(( ($RANDOM + $seed) % 30)) - $DATE +%Y-%m-%d --date "$due_days days" - } - - task::randomize () { - task::select "$1" - local -i seed="$2" - - echo 'Tasks without due date:' - task due: - - echo "Setting random due date for task $TASK_ID" - task $TASK_ID modify due:$(task::random::due_date $seed) - } - alias trand=task::randomize - - task::add () { - task add priority:L "$@" - } - alias a=task::add - - task::add::log () { - task add priority:L +log "$@" - } - alias log=task::add::log - - task::add::track () { - if [ "$#" -gt 0 ]; then - task add priority:L +personal +track "$@" due:eow - else - vit +track - fi - } - alias track=task::add::track - alias T=task::add::track - - task::summarize::track () { - task +track status:pending export | jq -r '.[].description' | awk ' - { - num=$1 - $1="" - keys[$0] += num - } - - END { - for (key in keys) - printf "%s %d\n", key, keys[key] - } - ' - } - alias Tsummarize=task::summarize::track - - task::add::standup() { - if [ "$#" -gt 0 ]; then - task add priority:L +work +standup +sre +nosched "$@" - task add priority:L +work +standup +storage +nosched "$@" - else - vit +standup - fi - } - - task::add::standup::editor () { - local -r tmpfile=$(mktemp /tmp/standup.XXXXXX.txt) && \ - $EDITOR $tmpfile && \ - task::add::standup "$(cat $tmpfile)" - } - - alias standup=task::add::standup - # Virtual standup - alias V=task::add::standup - alias Vstorage='vit +standup +storage' - alias Vsre='vit +standup +sre' - alias Ved=task::add::standup::editor - - task::dice () { - local -r filter=$1 - TASK_ID=$(task $filter ready | sort -R | sed -n '/^[0-9]/ { p; q; }' | cut -d' ' -f1) - task $TASK_ID - } - alias tdice=task::dice - - task::dice::next () { - if [ -z "$TASK_ID" ]; then - echo "No diced task ID!" - return 1 - fi - task done $TASK_ID - task::dice - } - alias tnext=task::dice::next - - task::fuzzy::_select () { - sed -n '/^[0-9]/p' | sort -rn | fzf | cut -d' ' -f1 - } - - task::fuzzy::find () { - TASK_ID=$(task ready | task::fuzzy::_select) - } - alias tfind=task::fuzzy::find - - task::select () { - local -r task_id="$1" - if [ ! -z "$task_id" ]; then - TASK_ID="$task_id" - fi - if [[ "$TASK_ID" = '-' || -z "$TASK_ID" ]]; then - task::fuzzy::find - fi - } - alias tsel=task::select - - task::fuzzy::due () { - local -r flag="$1" - - TASK_ID=$(task limit:0 due.before:$($DATE +%Y-%m-%d --date '7 days') | - sed -E '/^$/d; /^[[:digit:]]+ tasks/d' | - task::fuzzy::_select) - - if [ "$flag" != silent ]; then - task $TASK_ID - fi - } - alias fdue=task::fuzzy::due - alias fdone='task::fuzzy::due && task::done' - - _task::set_import_export_tags () { - if [ $(uname) = Darwin ]; then - export TASK_IMPORT_TAG=work - export TASK_EXPORT_TAG=personal - else - export TASK_IMPORT_TAG=personal - export TASK_EXPORT_TAG=work - fi - } - - task::export () { - _task::set_import_export_tags - - local -i count=$(task +$TASK_EXPORT_TAG status:pending count) - if [ $count -eq 0 ]; then - return - fi - - echo "Exporting $count tasks to $TASK_EXPORT_TAG" - task +$TASK_EXPORT_TAG status:pending export > \ - "$WORKTIME_DIR/tw-$TASK_EXPORT_TAG-export-$($DATE +%s).json" - yes | task +$TASK_EXPORT_TAG status:pending delete - } - - task::import () { - _task::set_import_export_tags - find $WORKTIME_DIR -name "tw-$TASK_IMPORT_TAG-export-*.json" \ - | while read -r import; do - task import $import - rm $import - done - find $WORKTIME_DIR -name "tw-$(hostname)-export-*.json" \ - | while read -r import; do - task import $import - rm $import - done - } - - task::sync () { - if [ -f ~/scripts/taskwarriorfeeder.rb ]; then - ruby ~/scripts/taskwarriorfeeder.rb - fi - task::export - - if [ -d $WORKTIME_DIR ]; then - cd $WORKTIME_DIR - git pull - git add *.txt *.json - git commit -a -m 'do stuff' - git push - cd - - fi - - task::import - } - alias tsync=task::sync -fi diff --git a/dotfiles/zsh/zshrc_d/tmputils.source.zsh b/dotfiles/zsh/zshrc_d/tmputils.source.zsh deleted file mode 100644 index 9d7f26f..0000000 --- a/dotfiles/zsh/zshrc_d/tmputils.source.zsh +++ /dev/null @@ -1,66 +0,0 @@ -TMPUTILS_DIR=~/data/tmp -TMPUTILS_TMPFILE=~/.tmpfile - -tmpls () { - if [ ! -d $TMPUTILS_DIR ]; then - return - fi - - ls $TMPUTILS_DIR -} -alias Ls=tmpls - -alias cdtmp="cd $TMPUTILS_DIR" - -tmptee () { - local name=$1 - - if [ -z $name ]; then - name=$(date +%Y%m%d-%H:%M:%S) - else - shift - fi - local -r file=$TMPUTILS_DIR/$name - - if [ ! -d $TMPUTILS_DIR ]; then - mkdir -p $TMPUTILS_DIR - fi - - tee $@ $file - echo $file > $TMPUTILS_TMPFILE -} -alias Tee=tmptee - -tmpcat () { - local -r name=$1 - - if [ -z $name ]; then - cat $(tmpfile) - return - fi - - cat $TMPUTILS_DIR/$name -} -alias Cat=tmpcat - -tmpedit () { - local -r name=$1 - - if [ -z $name ]; then - $EDITOR $(tmpfile) - return - fi - - $EDITOR $TMPUTILS_DIR/$name -} -alias Edit=tmpedit - -tmpgrep () { - local -r name=$1 ; shift - tmcpat $name | grep "$@" -} -alias Grep=tmpgrep - -tmpfile () { - cat $TMPUTILS_TMPFILE -} diff --git a/dotfiles/zsh/zshrc_d/tmux.source.zsh b/dotfiles/zsh/zshrc_d/tmux.source.zsh deleted file mode 100644 index 73af656..0000000 --- a/dotfiles/zsh/zshrc_d/tmux.source.zsh +++ /dev/null @@ -1,110 +0,0 @@ -_tmux::cleanup_default () { - local s - tmux list-sessions | grep '^T.*: ' | grep -F -v attached | - cut -d: -f1 | while read -r s; do - echo "Killing $s" - tmux kill-session -t "$s" - done -} - -_tmux::connect_command () { - local -r server_or_pod="$1"; shift - - if [ -z "$TMUX_KEXEC" ]; then - echo "ssh -t $server_or_pod" - else - echo "kubectl exec -it $server_or_pod -- /bin/bash" - fi -} - - -# Create new session and if alread exists attach to it -tmux::new () { - readonly session=$1 - - _tmux::cleanup_default - if [ -z "$session" ]; then - tmux::new T$(date +%s) - else - tmux new-session -d -s $session - tmux -2 attach-session -t $session || tmux -2 switch-client -t $session - fi -} -alias tn=tmux::new - -tmux::attach () { - readonly session=$1 - - if [ -z "$session" ]; then - tmux attach-session || tmux::new - else - tmux attach-session -t $session || tmux::new $session - fi -} -alias ta=tmux::attach - -# Create new session andthe given server or container -tmux::remote () { - readonly server=$1 - tmux new -s $server "ssh -t $server 'tmux attach-session || tmux'" || tmux attach-session -d -t $server -} -alias tx=tmux::remote - -# Fuzzy search tmux session and attach or switch to it. -tmux::search () { - local -r session=$(tmux list-sessions | fzf | cut -d: -f1) - if [ -z "$TMUX" ]; then - tmux attach-session -t $session - else - tmux switch -t $session - fi -} -alias ts=tmux::search - -# Connect to multiple servers or containers, one tmux pane per target. -tmux::cluster_ssh () { - if [ -f "$1" ]; then - tmux::tssh_from_file $1 - return - fi - - tmux::tssh_from_argument $@ -} -alias tssh=tmux::cluster_ssh - -# Create a new tmux session with many servers in it -tmux::tssh_from_argument () { - local -r session=$1; shift - local first_server_or_container=$1; shift - - if [ -z "$first_server_or_container" ]; then - first_server_or_container=$session - fi - - tmux new-session -d -s $session "$(_tmux::connect_command "$first_server_or_container")" - if ! tmux list-session | grep "^$session:"; then - echo "Could not create session $session" - return 2 - fi - - for server_or_container in "${@[@]}"; do - tmux split-window -t $session "tmux select-layout tiled; $(_tmux::connect_command "$server_or_container")" - done - - tmux setw -t $session synchronize-panes on - tmux -2 attach-session -t $session | tmux -2 switch-client -t $session -} - -# Same as tssh, but based on a server list from a file -tmux::tssh_from_file () { - local -r serverlist=$1; shift - local -r session=$(basename $serverlist | cut -d. -f1) - - tmux::tssh_from_argument $session $(awk '{ print $1 }' $serverlist | sed 's/.lan./.lan/g') -} - -alias tm=tmux -alias tl='tmux list-sessions' -alias foo='tmux::new foo' -alias bar='tmux::new bar' -alias baz='tmux::new baz' diff --git a/dotfiles/zsh/zshrc_d/uprecords.source.zsh b/dotfiles/zsh/zshrc_d/uprecords.source.zsh deleted file mode 100644 index 683f210..0000000 --- a/dotfiles/zsh/zshrc_d/uprecords.source.zsh +++ /dev/null @@ -1,74 +0,0 @@ -export UPRECORDS_DIR=~/git/uprecords -export UPRECORDS_REPO=git@codeberg.org:snonux/uprecords.git - -uprecords::os () { - if [ $(uname) = FreeBSD ]; then - echo -n 'FreeBSD ' - freebsd-version - elif [ $(uname) = OpenBSD ]; then - echo -n 'OpenBSD ' - uname -r - elif [ $(uname) = Darwin ]; then - echo -n 'Darwin ' - uname -r - elif [ -f /etc/debian_version ]; then - cat /etc/debian_version - else - cat $(ls -d /etc/*release* | head -n 1) - fi -} - -uprecords::collect () { - readonly hostname=$(hostname | cut -d. -f1 | sed 's/..-lon-mb/mega/; s/MBDVXJ4XKH9C/mega-m3-pro/;') - - if [ $(whoami) = root ]; then - return 1 - fi - - if [ ! -d $UPRECORDS_DIR ]; then - git clone $UPRECORDS_REPO $UPRECORDS_DIR - cd $UPRECORDS_DIR - else - cd $UPRECORDS_DIR - git pull - fi - - if [ -f /var/spool/uptimed/records ]; then - # Debian, Ubuntu and FreeBSD - records_path=/var/spool/uptimed/records - elif [ -f /var/db/uptimed/records ]; then - # OpenBSD - records_path=/var/db/uptimed/records - else - # Homebrew (MacOS) - records_path=/opt/homebrew/var/uptimed/records - fi - - cp $records_path ./stats/$hostname.records - uprecords -a -m 100 > ./stats/$hostname.txt - uprecords -a | grep '^->' > ./stats/$hostname.cur.txt - which guprecords &>/dev/null && make - - local -r os=$(uprecords::os) - touch ./stats/$hostname.os.txt - grep -q "$os" ./stats/$hostname.os.txt - if [ $? -ne 0 ]; then - echo "$os" >> ./stats/$hostname.os.txt - fi - if [ -e /proc/cpuinfo ]; then - cat /proc/cpuinfo > ./stats/$hostname.cpuinfo.txt - elif [ $(uname) = Darwin ]; then - sysctl -a | grep machdep.cpu >./stats/$hostname.cpuinfo.txt - fi - - git add ./stats/$hostname.* - git add ./*.txt - git commit -m "New uprecords for host $hostname" - git push - - cd - -} - -uprecords::sync () { - grep -q running ~/.config/snonux/etc/uptimed_ensure && uprecords::collect -} diff --git a/dotfiles/zsh/zshrc_d/utils.source.zsh b/dotfiles/zsh/zshrc_d/utils.source.zsh deleted file mode 100644 index 263c1fa..0000000 --- a/dotfiles/zsh/zshrc_d/utils.source.zsh +++ /dev/null @@ -1,467 +0,0 @@ -# Learn a new command -learn () { - man $(ls /bin /sbin /usr/bin /usr/sbin 2>/dev/null | shuf -n 1)| sed -n "/^NAME/ { n;p;q }" -} - -fullest_h () { - df -h | sort -n -k 5 -} - -fullest_i () { - df -i | sort -n -k 5 -} - -usortn () { - sort | uniq -c | sort -n -} - -asum () { - awk '{ sum += $1 } END { print sum }' -} - -hral () { - # Human readable audit logs - awk '{ time=gensub(/.*audit.(.*)\..*/, "\\1", "g", $2); $2 = ""; printf "%s -> %s\n", strftime("%m%d-%H%M%S", time), $0; }' -} - -pof () { - local -r pattern=$1 - sudo lsof -p $(pgrep -f $pattern) -} - -if [ $UNAME = Linux ]; then - plimits () { - local -r pattern=$1 - sudo cat /proc/$(pgrep -f $pattern)/limits - } - - ptop () { - local -r pattern=$1 - sudo top -p $(sudo pgrep -f $pattern) - } - - swappy () { - local count=$1 - s dd if=/dev/zero of=/swapfile$count bs=1024 count=$((1024 * 1024 * 4)) - s mkswap /swapfile$count - s swapon /swapfile$count - echo You have to add this to fstab: - echo /swapfile$count swap swap defaults 0 0 - } - - extfs_ratio () { - readonly device=$1 - - if [ -z $device ]; then - df | sed /Filesystem/d | cut -d' ' -f1 | - while read dev; do - ext_ratio $dev - done - else - echo -n "$device: " - sudo tune2fs -l $device | - awk -F: ' \ - /^Block count:/ { blocks = $2 } \ - /^Inode count:/ { inodes = $2 } \ - /^Block size:/ { block_size = $2 } \ - END { blocks_per_inode = blocks/inodes; \ - print " blocks per inode:", blocks_per_inode, \ - " bytes per inode:", blocks_per_inode * block_size }' - fi - } - - 2dos () { - sed 's/$'"/`echo \\\r`/" $@ - } - - 2dos_i () { - sed -i 's/$'"/`echo \\\r`/" $@ - } -fi # If Linux - -2unix () { - perl -pe 's/\r\n|\n|\r/\n/g' -} - -maint_banner () { - cat <<END - -██████╗ ██████╗ ██╗ ██╗███████╗████████╗ ██████╗ ██╗ ██╗ -██╔══██╗██╔══██╗██║ ██║██╔════╝╚══██╔══╝██╔═══██╗██║ ██║ -██████╔╝██████╔╝██║ ██║█████╗ ██║ ██║ ██║██║ █╗ ██║ -██╔═══╝ ██╔══██╗██║ ██║██╔══╝ ██║ ██║ ██║██║███╗██║ -██║ ██████╔╝╚██████╔╝███████╗ ██║ ╚██████╔╝╚███╔███╔╝ -╚═╝ ╚═════╝ ╚═════╝ ╚══════╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ - -██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗██╗███╗ ██╗ ██████╗ -██║ ██║██╔═══██╗██╔══██╗██║ ██╔╝██║████╗ ██║██╔════╝ -██║ █╗ ██║██║ ██║██████╔╝█████╔╝ ██║██╔██╗ ██║██║ ███╗ -██║███╗██║██║ ██║██╔══██╗██╔═██╗ ██║██║╚██╗██║██║ ██║ -╚███╔███╔╝╚██████╔╝██║ ██║██║ ██╗██║██║ ╚████║╚██████╔╝ - ╚══╝╚══╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝ ╚═════╝ - -██╗ ██╗███████╗██████╗ ███████╗ -██║ ██║██╔════╝██╔══██╗██╔════╝ -███████║█████╗ ██████╔╝█████╗ -██╔══██║██╔══╝ ██╔══██╗██╔══╝ -██║ ██║███████╗██║ ██║███████╗██╗██╗██╗ -╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝╚══════╝╚═╝╚═╝╚═╝ - -END -} - -maint () { - readonly arg=$1 - all="$@" - readonly maintfile=/root/.maint - echo "Checking whether Puppet is running" - pgrep -lf puppet 2>/dev/null - if [ $? -eq 0 ]; then - echo "Puppet is still running, terminating it" - sudo pkill -f puppet - sleep 1 - fi - - if [ -z $arg ]; then - echo -n 'Maintenance mode is currently ' - sudo test -f $maintfile && echo on || echo off - sudo test -f $maintfile && echo -n /root/.maint: && sudo cat /root/.maint - echo -n '/etc/motd:'; tail -n 1 /etc/motd - - elif [ $arg = off ]; then - echo Toggling maintenance mode to off - sudo rm $maintfile 2>/dev/null - - else - local message="$(date +%Y%m%d) $USER: $all" - - echo Toggling maintenance mode to on - maint_banner | sudo tee -a /etc/motd >/dev/null - sudo tee -a /etc/motd <<< "$message" - sudo tee -a $maintfile <<< "$message" 2>/dev/null - fi -} - -maint_until () { - local -r at=$1 ; shift - maint $@ " (Leaving maintenance mode at $at via atd)" - unmaint_at $at -} - -m11 () { - maint $@ - unmaint_at 11pm -} - -unmaint () { - maint off -} - -unmaint_at () { - readonly at=$1 - readonly maintfile=/root/.maint - - sudo at $at <<< "/bin/rm $maintfile" -} - -### LOG TAIL HELPERS ### - -lt () { - readonly today=$(date +'%Y%m%d') - local cmd=$1 - local params - - if [ -z $cmd ]; then - cmd=tail - params=-f - else - shift - params=$@ - fi - - # Run the F command inside of less to autotail - if [ -f $today.log ]; then - $cmd $params $today.log - - elif [ -f $today ]; then - $cmd $params $today - - elif [ -f log/$today.log ]; then - $cmd $params log/$today.log - - elif [ -f log/$today ]; then - $cmd $params log/$today - - else - echo 'No logfile to tail' - return -1 - fi -} - -### SERVICE HELPERS ### - -stop () { - readonly service=$1 ; shift - sudo service $service stop $@ -} - -start () { - readonly service=$1 ; shift - sudo service $service start $@ -} - -restart () { - readonly service=$1 ; shift - sudo service $service restart $@ -} - -status () { - readonly service=$1 ; shift - sudo service $service status $@ -} - -### CD HELPERS - -# cd into newest directory -cdn () { - readonly pattern="${1}" ; shift - readonly dir=$(ls -tF | grep "$pattern.*/\$" | head -n 1) - - if [ -d "$dir" ]; then - cd "$dir" - else - echo "No such dir $dir" - fi -} - -# cd into parallel directory -cdpal () { - readonly from="${1}" ; shift - readonly to="${1}" ; shift - readonly pwd=$(pwd) - - cd ${pwd/$from/$to} -} - -# Loop a command with interval (other than gnu-watch) -loop () { - local -i sleep=10 - - if [ "$SLEEP" != '' ]; then - sleep=$SLEEP - fi - - echo sleep is $sleep 1>&2 - - while : ; do - $@ - sleep $sleep - done -} - -lsiowait () { - ps ax | awk '$3 ~ /D/ { print $0 }' -} - -# Find helper -f () { - find . -iname "*$@*" -} - -scpf () { - readonly src=$1 - readonly file=$2 - - sudo scp -r $USER@$src:$(pwd)/$file $file -} - -cpf () { - readonly src=$1 - readonly file=$2 - - scp -r $USER@$src:$(pwd)/$file $file -} - -commit_message () { - if [ -z "$1" ]; then - which fortune && message="$(fortune)" || message='Quick commit' - else - message="$@" - fi - - echo "$message" -} - -mmaps () { - readonly pid=$1 - sudo cat /proc/$pid/maps | awk '/\// {print $6}' | sort | uniq -} - -# Time helpers -random () { - local -i upto=$1 - local -i random=$[$RANDOM % $upto] - echo "Sleeping $random seconds" - sleep $random -} - -dedup () { - local -r file=$1 - - if [ -z $file ]; then - awk '{ if (line[$0] != 42) { print $0 }; line[$0] = 42; }' - - else - awk '{ if (line[$0] != 42) { print $0 }; line[$0] = 42; }' $file | sudo tee $file.dedup > /dev/null || return 3 - if [ ! -f $file.dedupbak ] - then - sudo mv $file $file.dedupbak - fi - sudo mv $file.dedup $file - wc -l $file $file.dedupbak - sudo gzip --best $file.dedupbak & - fi -} - -dedup_no_bak () { - local -r file=$1 - - if [ -z $file ]; then - awk '{ if (line[$0] != 42) { print $0 }; line[$0] = 42; }' - - else - awk '{ if (line[$0] != 42) { print $0 }; line[$0] = 42; }' $file | sudo tee $file.dedup > /dev/null || return 3 - if [ ! -f $file.dedupbak ] - then - sudo mv $file $file.dedupbak - fi - sudo mv $file.dedup $file - wc -l $file $file.dedupbak - sudo rm -v $file.dedupbak & - fi -} - -json () { - ruby -r json -e 'puts JSON.pretty_generate(JSON.parse(STDIN.read))' -} - -drop_caches () { - echo 3 | sudo tee /proc/sys/vm/drop_caches -} - -ssl_connect () { - local -r address=$1 - openssl s_client -connect $address -} - -ssl_dates () { - ssl_connect $@ | openssl x509 -noout -dates -} - -asum () { - awk '{ sum += $1 } END { print sum }' -} - -lastu () { - last | grep -E -v '(root|cron|nagios)' -} - -lastl () { - lastu | less -} - -duckduckgo () { - lynx "https://lite.duckduckgo.com/lite?q=$*" -} - -stopwatch () { - local -i start_time=$(date +%s) - while : - do - local -i now_time=$(date +%s) - local -i diff_time=$(( now_time - start_time )) - local -i minutes=$(printf "%d" $((diff_time / 60))) - clear - figlet <<< "$minutes min." - sleep 60 - done -} - -# Curl commands -weather () { - curl http://wttr.in/ -} -alias wetter=weather - -cheat () { - curl cheat.sh/$1 -} - -functions () { - grep -h -E '^[a-z]+::[a-z]+ ()' ~/.zsh*/* | cut -d: -f1 | sort -u -} - -alias tf=terraform -alias search=ddgr - -# Touch type commands - -touchtype () { - tt --noskip --noreport --showwpm --bold --theme $(tt -list themes | sort -R | head -n1) $@ -} - -touchtype::notes () { - while : ; do - ruby ~/scripts/randomnote.rb | touchtype - sleep 0.2 - done -} - -touchtype::quote () { - while : ; do - touchtype -quotes en - sleep 0.2 - done -} -alias typing=touchtype::quote - -sway_config_view () { - less /etc/sway/config -} - -# FZF fuzzy finder -if [ -f ~/.fzf.zsh ]; then - # brew/macOS - source ~/.fzf.zsh -elif [ -f /usr/share/fzf/shell/key-bindings.zsh ]; then - # Fedora Linux - source /usr/share/fzf/shell/key-bindings.zsh -fi - -# tv (television) fuzzy finder -tv::git () { - cd $(tv git-repos) - zle accept-line -} -zle -N tv::git -bindkey -M viins '^G' tv::git - -tv::files() { - BUFFER="$BUFFER $(tv files)" - zle end-of-line - zle accept-line -} -zle -N tv::files -bindkey -M viins '^t' tv::files - -tv::text () { - $EDITOR $(tv text) - zle accept-line -} -zle -N tv::text -bindkey -M viins '^x' tv::text - -ssh::force () { - local -r server="$1"; shift - ssh-keygen -R $server && ssh -A $server -} diff --git a/dotfiles/zsh/zshrc_d/worktime.source.zsh b/dotfiles/zsh/zshrc_d/worktime.source.zsh deleted file mode 100644 index aa473e4..0000000 --- a/dotfiles/zsh/zshrc_d/worktime.source.zsh +++ /dev/null @@ -1,175 +0,0 @@ -export WORKTIME_DIR=~/git/worktime - -if [ -d $WORKTIME_DIR ]; then - alias cdworktime="cd $WORKTIME_DIR" - - if [[ $(uname) = Darwin && ! -f ~/.wtloggedin ]]; then - echo "Warn: Not logged in, run wtlogin" - fi - - worktime () { - ruby $WORKTIME_DIR/worktime.rb $@ - } - alias wt=worktime - alias wtedit='worktime --edit' - - worktime::wisdom_reminder () { - if [ $WORKTIME_DIR/work-wisdoms.md ]; then - sed -n '/^\* / { s/\* //; p; }' $WORKTIME_DIR/work-wisdoms.md | sort -R | head -n 1 - fi - } - - worktime::report () { - if [ -f ~/.wtloggedin ]; then - if [ -f ~/.wtmaster ]; then - # Avoiding merge conflicts - worktime --report | tee $WORKTIME_DIR/report.txt - else - worktime --report - fi - worktime::wisdom_reminder - fi - } - alias wtreport=worktime::report - # wtreport force - alias wtf='worktime --report' - - worktime::sync () { - cd $WORKTIME_DIR - if [ -d ~/Notes/HabitsAndQuotes ]; then - echo > work-wisdoms.md.tmp - for notes in ~/Notes/HabitsAndQuotes/{Productivity,Mentoring}.md; do - grep '^\* ' $notes >> work-wisdoms.md.tmp - done - sort -u work-wisdoms.md.tmp > work-wisdoms.md - rm work-wisdoms.md.tmp - git add work-wisdoms.md - - grep '^\* ' ~/Notes/HabitsAndQuotes/Exercise.md > exercises.md - git add exercises.md - fi - - find . -name \*.txt -exec git add {} \; - git add db.*.json - git commit -a -m sync - git pull origin master - git push origin master - cd - - } - alias wtsync=worktime::sync - alias random_exercise="sort -R $WORKTIME_DIR/exercises.md | head -n 1" - alias random_exercises="sort -R $WORKTIME_DIR/exercises.md | head -n 10" - - worktime::add () { - local -r seconds=$1 - local what=$2 - local -r descr="$3" - local -r epoch=$(date +%s) - - if [ -z "$what" ]; then - what=work - fi - - if [ -z "$descr" ]; then - worktime --add $seconds --epoch $epoch --what $what - else - worktime --add $seconds --epoch $epoch --what $what --descr "$descr" - fi - worktime::report - } - alias wtadd=worktime::add - - worktime::log () { - local -r seconds=$1 - local what=$2 - local -r epoch=$(date +%s) - - if [ -z "$what" ]; then - what=work - fi - - worktime --log --epoch $epoch --what $what - worktime::report - } - alias wtlog=worktime::log - - worktime::login () { - local what=$1 - if [ -z "$what" ]; then - what=work - fi - - touch ~/.wtloggedin - worktime --login --what $what - worktime::wisdom_reminder - } - alias wtlogin=worktime::login - - worktime::logout () { - local what=$1 - local sync=$2 - - if [ -z "$what" ]; then - what=work - fi - - if [ -f ~/.wtloggedin ] ; then - rm ~/.wtloggedin - fi - - worktime --logout --what $what - worktime::report - if [ ! -z "$sync" ]; then - worktime::sync - worktime::report - fi - } - alias wtlogout=worktime::logout - - worktime::status () { - worktime::report - - if [ -f ~/.wtloggedin ]; then - echo "You are logged in" - local -i num_worklog=$(ls $WORKTIME_DIR | grep wl- | wc -l) - if [ $num_worklog -gt 0 ]; then - echo "$num_worklog entries in the worklog" - fi - else - echo "You are not logged in" - fi - } - alias wtstatus=worktime::status - - worktime::log::personal::quick () { - cd $WORKTIME_DIR - echo "$@" > "pl-$(date +%s).txt" - git add pl-*.txt - git commit -m "Add personal log" pl-*.txt - cd - - } - alias ql=worktime::log::personal::quick - alias pl=worktime::log::personal::quick - - worktime::log::work () { - cd $WORKTIME_DIR - - if [ -z "$@" ]; then - grep . wl-*.txt 2>/dev/null - cd - - return - elif [ "$@" = clear ]; then - git rm wl-*.txt 2>/dev/null - git commit -m 'Cleaning up work log' - cd - - return - fi - - cd $WORKTIME_DIR - echo "$@" > "wl-$(date +%s).txt" - git add wl-*.txt - git commit -m "Add work log" wl-*.txt - cd - - } - alias wl=worktime::log::work -fi |
