From f311c01a1b2672ab2c724674de8022e83988545e Mon Sep 17 00:00:00 2001 From: "Simen A. W. Olsen" Date: Fri, 27 Dec 2024 14:37:58 +0100 Subject: reorganize --- zsh/.zshrc | 23 +++++++++++++++++++++++ zsh/aliases.zsh | 31 +++++++++++++++++++++++++++++++ zsh/extras.zsh | 28 ++++++++++++++++++++++++++++ zsh/path.zsh | 13 +++++++++++++ 4 files changed, 95 insertions(+) create mode 100644 zsh/.zshrc create mode 100644 zsh/aliases.zsh create mode 100755 zsh/extras.zsh create mode 100644 zsh/path.zsh (limited to 'zsh') diff --git a/zsh/.zshrc b/zsh/.zshrc new file mode 100644 index 0000000..bdc70cc --- /dev/null +++ b/zsh/.zshrc @@ -0,0 +1,23 @@ + +# Download Znap, if it's not there yet. +[[ -r ~/.zsh_repos/znap/znap.zsh ]] || + git clone --depth 1 -- \ + https://github.com/marlonrichert/zsh-snap.git ~/.zsh_repos/znap +source ~/.zsh_repos/znap/znap.zsh # Start Znap + +export GOPATH=~/go +export REPOS=~/ghq + +znap eval starship 'starship init zsh --print-full-init' +znap prompt + +znap source marlonrichert/zsh-autocomplete +znap source zsh-users/zsh-autosuggestions + +for file in ~/.{aliases.zsh,path.zsh,extras.zsh}; do + if [[ -r "$file" ]] && [[ -f "$file" ]]; then + # shellcheck source=/dev/null + source "$file" + fi +done + diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh new file mode 100644 index 0000000..ebda55c --- /dev/null +++ b/zsh/aliases.zsh @@ -0,0 +1,31 @@ +# Git aliases +alias git-unpushed='git log --branches --not --remotes --no-walk --decorate --oneline' +alias gb='git checkout -b' +alias gfr='git fetch upstream && git rebase upstream/main' +alias git-undo='git reset --soft HEAD~1' +alias git-clean-branches="git for-each-ref --format '%(refname:short)' refs/heads | grep -v 'master\|main' | xargs git branch -D" +alias :q='exit' +alias ls='ls --color' + +# Generic / Random / Utility +alias rg="rg --hidden --glob '!.git' --glob '!node_modules'" +alias r='cd $REPOS/github.com/' +alias c='clear' +alias afk='pmset displaysleepnow' +alias dl="cd ~/Downloads" +alias l='ls -l' +alias todo='nt' +alias tasks="open 'obsidian://open?file=-%20Oppgaver'" +alias todos="mt ~/ghq/github.com/simenandre/notes/" +# alias docker-compose=podman-compose +alias today="open 'obsidian://advanced-uri?daily=true'" +alias tre="tree -I '.git|node_modules'" +alias timeliste="open 'https://tripletex.no/execute/updateHourlist?contextId=11208568'" +alias t="open 'https://tripletex.no/execute/updateHourlist?contextId=11208568'" +alias fork-cleaner="fork-cleaner --token $(cat ~/.secrets/github-token)" +alias vi="nvim" +alias vim="nvim" +alias v="nvim" + +alias dump-issues="getBjerkIssues > ~/Downloads/issues-$(date -I).json" + diff --git a/zsh/extras.zsh b/zsh/extras.zsh new file mode 100755 index 0000000..0647ca0 --- /dev/null +++ b/zsh/extras.zsh @@ -0,0 +1,28 @@ +NOTES_DIR=$HOME/ghq/github.com/simenandre/notes/ +function note() { + if [ $1 ]; then + FILE=$NOTES_DIR/$(date +%Y-%m-%d).md + + if [ $2 ]; then + FILE=$2 + fi + + echo $1 >> $FILE + fi +} + +function nt() { + if [ $1 ]; then + CONTENT="- [ ] $1" + note $CONTENT $2 + fi +} + +function getBjerkIssues() { + gh issue list --repo bjerkio/internal \ + --search "-label:backlog -label:kind/system" \ + --json title,body,url,createdAt,assignees,number,labels,comments \ + --jq 'map({url, createdAt, title, labels: [.labels[].name], assignees: [.assignees[].login], body, number: "#\(.number)", comments: .comments | map({ body: .body, createdAt: .createdAt })})' +} + + diff --git a/zsh/path.zsh b/zsh/path.zsh new file mode 100644 index 0000000..ef41549 --- /dev/null +++ b/zsh/path.zsh @@ -0,0 +1,13 @@ +#!/bin/bash + +# Add directories to the PATH and prevent to add the same directory multiple times upon shell reload. +add_to_path() { + if [[ -d "$1" ]] && [[ ":$PATH:" != *":$1:"* ]]; then + export PATH="$1:$PATH" + fi +} + +# Add ghq to PATH +add_to_path "$GOPATH/bin" +add_to_path "/Library/Frameworks/Firebird.framework/Resources/bin" + -- cgit v1.2.3