ohmyzsh / ohmyzsh

🙃 A delightful community-driven (with 2,300+ contributors) framework for managing your zsh configuration. Includes 300+ optional plugins (rails, git, macOS, hub, docker, homebrew, node, php, python, etc), 140+ themes to spice up your morning, and an auto-update tool so that makes it easy to keep up with the latest updates from the community.

Home Page:https://ohmyz.sh

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Alias Arguments Not Being Recognized

ChaseKolozsy opened this issue · comments

Describe the bug

The following is in my .zshrc file:

alias tn="(){tmux new -s $1}"
alias gc="(){git commit -m $1}"

NOTE: all the other aliases that do not have parameters work
NOTE: source .zshrc has been executed in terminal

Outputs for alias commands in terminal:

chasekolozsy@Chases-MacBook-Pro ~ % tn Test
command new-session: -s expects an argument
chasekolozsy@Chases-MacBook-Pro ~ % gc "test commit"
error: switch `m' requires a value
chasekolozsy@Chases-MacBook-Pro ~ %

Steps to reproduce

install ohmyzsh using the curl command
brew install tmux
install git

add the following aliases to the .zshrc file:

alias tn="(){tmux new -s $1}"
alias gc="(){git commit -m $1}"

execute in terminal:
source .zshrc

execute in terminal:

tn Test

gc "test commit"

Expected behavior

tmux should run a new session called Test for tn Test
git should create a commit with commit message "test commit"

Screenshots and recordings

No response

OS / Linux distribution

MacOS 14

Zsh version

5.9

Oh My Zsh version

master (529f77a)

Terminal emulator

iTerm2

If using WSL on Windows, which version of WSL

None

Additional context

It has this issue right out of the box and after installing plugins autocomplete and syntax highlighting.

Hi! I recommend you define those aliases as alias tn="tmux new -s" and alias gc="git commit -m". You can pass arguments to regular aliases as if they were commands!

Note: both aliases already exist in the tmux and git plugins, respectively. tn alias will directly work if you enable tmux plugin and gcmsg do exactly what you want!

Thanks!