1
0
mirror of https://github.com/robbyrussell/oh-my-zsh.git synced 2026-02-12 04:10:58 +01:00

6 Commits

Author SHA1 Message Date
0xHouss
736632228a feat(copyfile): add error handling (#13248) 2025-08-16 21:31:40 +02:00
Jérémy
7504f22a0c feat(battery): add wattage for macOS (#13258) 2025-08-16 21:28:32 +02:00
Carlo Sala
92a03105ac docs(key-bindings): clarify comment
Closes #13265
2025-08-16 21:26:22 +02:00
Patrick W. Healy
5d37f723f6 fix(asdf): avoid prepending path entry multiple times (#13268) 2025-08-16 21:17:14 +02:00
olwooz
51760e1d4a feat(installer): add confirmation before overwriting existing .zshrc (#13086) 2025-08-16 18:29:43 +02:00
Carlo Sala
8bd49fb047 fix(virtualenv): take into account $VIRTUAL_ENV_PROMPT
Closes #13262
2025-08-16 18:27:53 +02:00
7 changed files with 51 additions and 6 deletions

View File

@@ -117,7 +117,7 @@ bindkey '^r' history-incremental-search-backward # [Ctrl-r] - Search backwa
bindkey ' ' magic-space # [Space] - don't do history expansion
# Edit the current command line in $EDITOR
# Edit the current command line in $VISUAL (or $EDITOR / `vi` if not set)
autoload -U edit-command-line
zle -N edit-command-line
bindkey '\C-x\C-e' edit-command-line

View File

@@ -1,7 +1,9 @@
(( ! $+commands[asdf] )) && return
export ASDF_DATA_DIR="${ASDF_DATA_DIR:-$HOME/.asdf}"
path=("$ASDF_DATA_DIR/shims" $path)
# Add shims to the front of the path, removing if already present.
path=("$ASDF_DATA_DIR/shims" ${path:#$ASDF_DATA_DIR/shims})
# If the completion file doesn't exist yet, we need to autoload it and
# bind it to `asdf`. Otherwise, compinit will have already done that.

View File

@@ -19,6 +19,12 @@ For example:
BATTERY_CHARGING="⚡️"
```
You can see the power of your charger using the following setting (MacOS only)
```zsh
BATTERY_SHOW_WATTS=true
```
## Requirements
- On Linux, you must have the `acpi` or `acpitool` commands installed on your operating system.

View File

@@ -17,8 +17,13 @@
# Modified to add support for OpenBSD #
###########################################
: ${BATTERY_SHOW_WATTS:=false}
if [[ "$OSTYPE" = darwin* ]]; then
function get_charger_power() {
echo "$(ioreg -rc AppleSmartBattery | grep -o '"Watts"=[0-9]\+' | head -1 | grep -o '[0-9]\+')W "
}
function battery_is_charging() {
ioreg -rc AppleSmartBattery | command grep -q '^.*"ExternalConnected"\ =\ Yes'
}
@@ -58,7 +63,10 @@ if [[ "$OSTYPE" = darwin* ]]; then
fi
echo "%{$fg[$color]%}[${battery_pct}%%]%{$reset_color%}"
else
echo "${BATTERY_CHARGING-⚡️}"
if [[ "${BATTERY_SHOW_WATTS}" = "true" ]] ; then
watts=$(get_charger_power)
fi
echo "${watts}${BATTERY_CHARGING-⚡️}"
fi
}

View File

@@ -1,7 +1,19 @@
# Copies the contents of a given file to the system or X Windows clipboard
#
# copyfile <file>
# Usage: copyfile <file>
function copyfile {
emulate -L zsh
if [[ -z "$1" ]]; then
echo "Usage: copyfile <file>"
return 1
fi
if [[ ! -f "$1" ]]; then
echo "Error: '$1' is not a valid file."
return 1
fi
clipcopy $1
echo ${(%):-"%B$1%b copied to clipboard."}
}

View File

@@ -1,6 +1,6 @@
function virtualenv_prompt_info(){
[[ -n ${VIRTUAL_ENV} ]] || return
echo "${ZSH_THEME_VIRTUALENV_PREFIX=[}${VIRTUAL_ENV:t:gs/%/%%}${ZSH_THEME_VIRTUALENV_SUFFIX=]}"
echo "${ZSH_THEME_VIRTUALENV_PREFIX=[}${VIRTUAL_ENV_PROMPT:-${VIRTUAL_ENV:t:gs/%/%%}}${ZSH_THEME_VIRTUALENV_SUFFIX=]}"
}
# disables prompt mangling in virtual_env/bin/activate

View File

@@ -341,6 +341,23 @@ setup_zshrc() {
echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Keeping...${FMT_RESET}"
return
fi
# Ask user for confirmation before backing up and overwriting
echo "${FMT_YELLOW}Found ${zdot}/.zshrc."
echo "The existing .zshrc will be backed up to .zshrc.pre-oh-my-zsh if overwritten."
echo "Make sure your .zshrc contains the following minimal configuration if you choose not to overwrite it:${FMT_RESET}"
echo "----------------------------------------"
cat "$ZSH/templates/minimal.zshrc"
echo "----------------------------------------"
printf '%sDo you want to overwrite it with the Oh My Zsh template? [Y/n]%s ' \
"$FMT_YELLOW" "$FMT_RESET"
read -r opt
case $opt in
[Yy]*|"") ;;
[Nn]*) echo "Overwrite skipped. Existing .zshrc will be kept."; return ;;
*) echo "Invalid choice. Overwrite skipped. Existing .zshrc will be kept."; return ;;
esac
if [ -e "$OLD_ZSHRC" ]; then
OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)"
if [ -e "$OLD_OLD_ZSHRC" ]; then
@@ -353,7 +370,7 @@ setup_zshrc() {
echo "${FMT_YELLOW}Found old .zshrc.pre-oh-my-zsh." \
"${FMT_GREEN}Backing up to ${OLD_OLD_ZSHRC}${FMT_RESET}"
fi
echo "${FMT_YELLOW}Found ${zdot}/.zshrc.${FMT_RESET} ${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}"
echo "${FMT_GREEN}Backing up to ${OLD_ZSHRC}${FMT_RESET}"
mv "$zdot/.zshrc" "$OLD_ZSHRC"
fi