mirror of
https://github.com/robbyrussell/oh-my-zsh.git
synced 2026-02-12 04:10:58 +01:00
Compare commits
6 Commits
2423b7a12d
...
736632228a
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
736632228a | ||
|
|
7504f22a0c | ||
|
|
92a03105ac | ||
|
|
5d37f723f6 | ||
|
|
51760e1d4a | ||
|
|
8bd49fb047 |
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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."}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user