Skip to content

Instantly share code, notes, and snippets.

@underground0930
Last active June 5, 2022 05:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save underground0930/de0eb0cc509de16984df19eccd98d490 to your computer and use it in GitHub Desktop.
Save underground0930/de0eb0cc509de16984df19eccd98d490 to your computer and use it in GitHub Desktop.
#!/bin/sh
########################################
# 現在のカレントディレクトリに移動するためのaliasをセットする
# 例)
# 現在地 /Users/hogehoge/project_a/develop
# ターミナルで右のコマンドを実行 ⇨ set_alias hogehoge
# 以下のスクリプトが、指定したファイルの末尾に追加される
# alias hogehoge='cd /Users/hogehoge/project_a/develop'
# hogehoge とターミナルで実行すると、そのディレクトリに移動している
########################################
# エイリアスに指定したい名前(他と被らないようにする)
name=$1
# 保存先は、bashや、zshで読み込めればどこでも良いです
save_file=~/.zsh.d/alias.zsh
if [ -z "$name" ]; then
echo "please input alias name!"
exit;
fi
echo "alias $1='cd $(pwd)'" >> $save_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment