Skip to content

Instantly share code, notes, and snippets.

@elsayed85
Last active August 27, 2023 12:12
Show Gist options
  • Save elsayed85/c144ccf466e727f97c9f1187c887b9e2 to your computer and use it in GitHub Desktop.
Save elsayed85/c144ccf466e727f97c9f1187c887b9e2 to your computer and use it in GitHub Desktop.
function phpv() {
version="$1"
php_bin="/usr/bin/php${version}"
if [ -f "$php_bin" ]; then
sudo update-alternatives --set php "$php_bin"
echo "Switched to PHP ${version}"
else
echo "Invalid version number or PHP ${version} not installed."
fi
}
alias pa='php artisan'
alias pas='php artisan serve'
alias pam='php artisan migrate'
alias pamr='php artisan make:request'
alias pamf='php artisan migrate:fresh'
alias pamm='php artisan make:migration'
alias pamc='php artisan make:controller'
alias pams='php artisan make:seeder'
alias pame='php artisan make:event'
alias pamn='php artisan make:notification'
alias model='php artisan make:model'
alias m='php artisan make:model'
alias rayi='composer require spatie/laravel-ray'
alias rayd='composer require spatie/laravel-ray --dev'
alias ray='electron /home/sayed/Desktop/ray/source/dist/main.js'
alias r='php artisan route:list'
alias res='php artisan make:resource'
alias wire='php artisan make:livewire'
alias work='php artisan queue:work'
alias ws='php artisan websockets:serve'
alias policy='php artisan make:policy'
alias middleware='php artisan make:middleware'
alias mid='php artisan make:middleware'
alias mtest='php artisan pest:test'
alias seed='php artisan db:seed'
alias ccache='php artisan cache:clear'
alias cview='php artisan view:clear'
alias croute='php artisan route:clear'
alias cconfig='php artisan config:clear'
alias wip='git add . && git commit -m “wip” && git push origin master'
alias gst='git status'
alias commit='git add . & git commit -m'
alias npmi='npm install'
alias npmw='npm run watch'
alias npmd='npm run dev'
alias npmp='npm run prod'
alias cls="clear"
alias clr="http --print=h POST http://laravel.test/api/clear-events > /dev/null"
alias crq='composer require '
alias crr='composer remove '
alias crd='composer dumpautoload'
alias t='gnome-terminal --working-directory=$(pwd)'
alias psr="phpstorm "
alias ?="php /home/sayed/Desktop/projects/packages/sites/laravel/artisan copilot:chat"
PATH="$PATH:$HOME/.config/composer/vendor/bin"
copilot_what-the-shell () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if /home/sayed/.nvm/versions/node/v16.18.1/bin/github-copilot-cli what-the-shell "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
history -s $(history 1 | cut -d' ' -f4-); history -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias '??'='copilot_what-the-shell';
copilot_git-assist () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if /home/sayed/.nvm/versions/node/v16.18.1/bin/github-copilot-cli git-assist "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
history -s $(history 1 | cut -d' ' -f4-); history -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias 'git?'='copilot_git-assist';
copilot_gh-assist () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if /home/sayed/.nvm/versions/node/v16.18.1/bin/github-copilot-cli gh-assist "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
history -s $(history 1 | cut -d' ' -f4-); history -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias 'gh?'='copilot_gh-assist';
alias 'wts'='copilot_what-the-shell';
# To the extent possible under law, the author(s) have dedicated all
# copyright and related and neighboring rights to this software to the
# public domain worldwide. This software is distributed without any warranty.
# You should have received a copy of the CC0 Public Domain Dedication along
# with this software.
# If not, see <https://creativecommons.org/publicdomain/zero/1.0/>.
# /etc/bash.bashrc: executed by bash(1) for interactive shells.
alias pa='php artisan'
alias pas='php artisan serve'
alias pam='php artisan migrate'
alias pamr='php artisan make:request'
alias pamf='php artisan migrate:fresh'
alias pamm='php artisan make:migration'
alias pamc='php artisan make:controller'
alias pams='php artisan make:seeder'
alias pame='php artisan make:event'
alias pamn='php artisan make:notification'
alias model='php artisan make:model'
alias m='php artisan make:model'
alias rayi='composer require spatie/laravel-ray'
alias rayd='composer require spatie/laravel-ray --dev'
alias ray='electron ~/ray/dist/main.js'
alias r='php artisan route:list'
alias res='php artisan make:resource'
alias wire='php artisan make:livewire'
alias work='php artisan queue:work'
alias ws='php artisan websockets:serve'
alias policy='php artisan make:policy'
alias middleware='php artisan make:middleware'
alias mid='php artisan make:middleware'
alias mtest='php artisan pest:test'
alias seed='php artisan db:seed'
alias ccache='php artisan cache:clear'
alias cview='php artisan view:clear'
alias croute='php artisan route:clear'
alias cconfig='php artisan config:clear'
alias wip='git add . && git commit -m “wip” && git push origin master'
alias gst='git status'
alias commit='git add . & git commit -m'
alias npmi='npm install'
alias npmw='npm run watch'
alias npmd='npm run dev'
alias npmp='npm run prod'
alias cls="clear"
alias crq='composer require '
alias crr='composer remove '
alias crd='composer dumpautoload'
alias psr="phpstorm "
alias winpwd='cygpath -aw .'
alias clearlog='rm $(winpwd)/storage/logs/laravel.log'
alias clearlogs='find $(winpwd)/storage/logs -name '*.log' -delete'
# System-wide bashrc file
copilot_what-the-shell () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if C:/Users/elsay/AppData/Roaming/npm/node_modules/@githubnext/github-copilot-cli/cli.js what-the-shell "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
history -s $(history 1 | cut -d' ' -f4-); history -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias '??'='copilot_what-the-shell';
copilot_git-assist () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if C:/Users/elsay/AppData/Roaming/npm/node_modules/@githubnext/github-copilot-cli/cli.js git-assist "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
echo $FIXED_CMD;
history -s $(history 1 | cut -d' ' -f4-); history -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias 'git?'='copilot_git-assist';
copilot_gh-assist () {
TMPFILE=$(mktemp);
trap 'rm -f $TMPFILE' EXIT;
if C:/Users/elsay/AppData/Roaming/npm/node_modules/@githubnext/github-copilot-cli/cli.js gh-assist "$@" --shellout $TMPFILE; then
if [ -e "$TMPFILE" ]; then
FIXED_CMD=$(cat $TMPFILE);
history -s $(history 1 | cut -d' ' -f4-); history -s "$FIXED_CMD";
eval "$FIXED_CMD"
else
echo "Apologies! Extracting command failed"
fi
else
return 1
fi
};
alias 'gh?'='copilot_gh-assist';
alias 'wts'='copilot_what-the-shell';
# Check that we haven't already been sourced.
([[ -z ${CYG_SYS_BASHRC} ]] && CYG_SYS_BASHRC="1") || return
# If not running interactively, don't do anything
[[ "$-" != *i* ]] && return
# If started from sshd, make sure profile is sourced
if [[ -n "$SSH_CONNECTION" ]] && [[ "$PATH" != *:/usr/bin* ]]; then
source /etc/profile
fi
# Warnings
unset _warning_found
for _warning_prefix in '' ${MINGW_PREFIX}; do
for _warning_file in ${_warning_prefix}/etc/profile.d/*.warning{.once,}; do
test -f "${_warning_file}" || continue
_warning="$(command sed 's/^/\t\t/' "${_warning_file}" 2>/dev/null)"
if test -n "${_warning}"; then
if test -z "${_warning_found}"; then
_warning_found='true'
echo
fi
if test -t 1
then printf "\t\e[1;33mwarning:\e[0m\n${_warning}\n\n"
else printf "\twarning:\n${_warning}\n\n"
fi
fi
[[ "${_warning_file}" = *.once ]] && rm -f "${_warning_file}"
done
done
unset _warning_found
unset _warning_prefix
unset _warning_file
unset _warning
# If MSYS2_PS1 is set, use that as default PS1;
# if a PS1 is already set and exported, use that;
# otherwise set a default prompt
# of user@host, MSYSTEM variable, and current_directory
[[ -n "${MSYS2_PS1}" ]] && export PS1="${MSYS2_PS1}"
# if we have the "High Mandatory Level" group, it means we're elevated
#if [[ -n "$(command -v getent)" ]] && id -G | grep -q "$(getent -w group 'S-1-16-12288' | cut -d: -f2)"
# then _ps1_symbol='\[\e[1m\]#\[\e[0m\]'
# else _ps1_symbol='\$'
#fi
case "$(declare -p PS1 2>/dev/null)" in
'declare -x '*) ;; # okay
*)
export PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[35m\]$MSYSTEM\[\e[0m\] \[\e[33m\]\w\[\e[0m\]\n'"${_ps1_symbol}"' '
;;
esac
unset _ps1_symbol
# Uncomment to use the terminal colours set in DIR_COLORS
# eval "$(dircolors -b /etc/DIR_COLORS)"
# Fixup git-bash in non login env
shopt -q login_shell || . /etc/profile.d/git-prompt.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment