moving some aliases into dedicated scripts
This commit is contained in:
parent
00b0b76637
commit
f38cccf8f2
4 changed files with 34 additions and 30 deletions
3
home/bin/executable_now
Normal file
3
home/bin/executable_now
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
date +"%Y-%m-%dT%H:%M:%S%z"
|
||||||
28
home/bin/executable_reldate
Normal file
28
home/bin/executable_reldate
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
if [[ -z "$1" ]]; then
|
||||||
|
cat << EOF
|
||||||
|
reldate - Format or adjust dates
|
||||||
|
|
||||||
|
Usage: reldate <date|adjustment>
|
||||||
|
|
||||||
|
Examples:
|
||||||
|
reldate "2025-12-12" # Output: 2025-12-12
|
||||||
|
reldate "+1d" # Output: tomorrow's date
|
||||||
|
reldate "-1w" # Output: date 1 week ago
|
||||||
|
reldate "+2m" # Output: date 2 months from now
|
||||||
|
reldate "-1y" # Output: date 1 year ago
|
||||||
|
|
||||||
|
Adjustments:
|
||||||
|
d = days, w = weeks, m = months, y = years
|
||||||
|
Use + for future, - for past
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$1" =~ ^[0-9]{4}-[0-9]{2}-[0-9]{2}$ ]]; then
|
||||||
|
date -j -f "%Y-%m-%d" "$1" "+%Y-%m-%d" 2>/dev/null || echo "Invalid date: $1"
|
||||||
|
else
|
||||||
|
date -v "$1" "+%Y-%m-%d"
|
||||||
|
fi
|
||||||
3
home/bin/executable_today
Normal file
3
home/bin/executable_today
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
date +"%Y-%m-%d"
|
||||||
|
|
@ -1,23 +1,10 @@
|
||||||
# Remove older command from the history if a duplicate is to be added.
|
|
||||||
setopt HIST_IGNORE_ALL_DUPS
|
setopt HIST_IGNORE_ALL_DUPS
|
||||||
|
|
||||||
# Set editor default keymap to emacs (`-e`) or vi (`-v`)
|
|
||||||
bindkey -v
|
bindkey -v
|
||||||
|
|
||||||
# Remove path separator from WORDCHARS.
|
|
||||||
WORDCHARS=${WORDCHARS//[\/]}
|
WORDCHARS=${WORDCHARS//[\/]}
|
||||||
|
|
||||||
# Disable automatic widget re-binding on each precmd. This can be set when
|
|
||||||
# zsh-users/zsh-autosuggestions is the last module in your ~/.zimrc.
|
|
||||||
ZSH_AUTOSUGGEST_MANUAL_REBIND=1
|
ZSH_AUTOSUGGEST_MANUAL_REBIND=1
|
||||||
|
|
||||||
# Set what highlighters will be used.
|
|
||||||
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
|
|
||||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
|
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
|
||||||
|
|
||||||
ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
||||||
|
|
||||||
# Download zimfw plugin manager if missing.
|
|
||||||
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
|
if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
|
||||||
if (( ${+commands[curl]} )); then
|
if (( ${+commands[curl]} )); then
|
||||||
curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \
|
curl -fsSL --create-dirs -o ${ZIM_HOME}/zimfw.zsh \
|
||||||
|
|
@ -28,15 +15,12 @@ if [[ ! -e ${ZIM_HOME}/zimfw.zsh ]]; then
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install missing modules, and update ${ZIM_HOME}/init.zsh if missing or outdated.
|
|
||||||
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
|
if [[ ! ${ZIM_HOME}/init.zsh -nt ${ZDOTDIR:-${HOME}}/.zimrc ]]; then
|
||||||
source ${ZIM_HOME}/zimfw.zsh init -q
|
source ${ZIM_HOME}/zimfw.zsh init -q
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Initialize modules.
|
|
||||||
source ${ZIM_HOME}/init.zsh
|
source ${ZIM_HOME}/init.zsh
|
||||||
|
|
||||||
# zsh-history-substring-search
|
|
||||||
zmodload -F zsh/terminfo +p:terminfo
|
zmodload -F zsh/terminfo +p:terminfo
|
||||||
|
|
||||||
# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
|
# Bind ^[[A/^[[B manually so up/down works both before and after zle-line-init
|
||||||
|
|
@ -69,22 +53,8 @@ export NVM_DIR="$HOME/.nvm"
|
||||||
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
|
[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"
|
||||||
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
|
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"
|
||||||
|
|
||||||
function reldate() {
|
|
||||||
date -v "${1}" "+%Y-%m-%d"
|
|
||||||
}
|
|
||||||
|
|
||||||
function now() {
|
|
||||||
date +"%Y-%m-%dT%H:%M:%S%z"
|
|
||||||
}
|
|
||||||
|
|
||||||
function today {
|
|
||||||
date +"%Y-%m-%d"
|
|
||||||
}
|
|
||||||
|
|
||||||
[ "$TERM" = "xterm-kitty" ] && alias ssh="TERM=xterm ssh"
|
[ "$TERM" = "xterm-kitty" ] && alias ssh="TERM=xterm ssh"
|
||||||
|
|
||||||
alias strip_jira="sed 's/\[\{0,1\}[a-zA-Z]*-[0-9]*\]\{0,1\}//g'"
|
|
||||||
|
|
||||||
export FZF_DEFAULT_COMMAND="rg --files --hidden"
|
export FZF_DEFAULT_COMMAND="rg --files --hidden"
|
||||||
export FZF_DEFAULT_OPTS=" \
|
export FZF_DEFAULT_OPTS=" \
|
||||||
--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \
|
--color=bg+:#313244,bg:#1e1e2e,spinner:#f5e0dc,hl:#f38ba8 \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue