ksh93 config #904
tungstengmd
started this conversation in
Show and tell
Replies: 1 comment 3 replies
-
|
Looks nice! Someday I'll release all the scripting-specific scaffolding I load on startup, but besides all that, the only thing I have in my function my_prompt {
integer lastrc=$?
# Save .sh.match so we can reference it later in the shell
typeset oldshmatch=${.sh.match}
# Add red return code if it's not 0
if (( lastrc > 0 ))
then
printf "\033[01;31m$lastrc\033[00m:"
fi
# If at $HOME, replace with '~'
if [[ $PWD == $HOME ]]
then
printf "\033[01;32m~\033[00m\$ "
else
printf "\033[01;32m${PWD##*/}\033[00m\$ "
fi
# Restore old .sh.match
[[ $oldshmatch == * ]]
}
export PS1="\$(my_prompt)"
alias class='typeset -T'
alias static='typeset -S'
alias short='typeset -si'
alias put='print -rn --'
alias puts='print -r --'
alias pute='print -n --'
alias puterr='print -u2 -rn --'
alias putserr='print -u2 -r --'
alias puteerr='print -u2 -n --'
function DATE.get {
.sh.value=$(printf "%(%Y-%m-%d)T")
}
function TIME.get {
.sh.value=$(printf "%(%H:%M:%S:%z)T")
}
function DATEANDTIME.get {
.sh.value=$(printf "%(%Y-%m-%d %H:%M:%S%z)T")
}
function RAND.get {
.sh.value=$(($RANDOM / 32767.0))
}
function UNIXTIME.get {
.sh.value=$(printf "%(%s)T")
} |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
since i haven't seen any discussions here, i'd like to start by sending my config !
https://git.gay/harlow/dotfiles/src/branch/main/.kshrc.d
https://git.gay/harlow/dotfiles/src/branch/main/.kshrc
lmk if there's any room for improvement :3
Beta Was this translation helpful? Give feedback.
All reactions