mirror of
https://github.com/DazAh/dotfiles
synced 2026-05-22 02:25:48 +01:00
update oh-my-zsh, poetry env and cs setting update
This commit is contained in:
@@ -42,20 +42,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
## Commands
|
||||
|
||||
| Command | Description |
|
||||
| :-------------- | :-------------------------------------------------- |
|
||||
| `tab` | Open the current directory in a new tab |
|
||||
| `split_tab` | Split the current terminal tab horizontally |
|
||||
| `vsplit_tab` | Split the current terminal tab vertically |
|
||||
| `ofd` | Open the current directory in a Finder window |
|
||||
| `pfd` | Return the path of the frontmost Finder window |
|
||||
| `pfs` | Return the current Finder selection |
|
||||
| `cdf` | `cd` to the current Finder directory |
|
||||
| `pushdf` | `pushd` to the current Finder directory |
|
||||
| `quick-look` | Quick-Look a specified file |
|
||||
| `man-preview` | Open a specified man page in Preview app |
|
||||
| `showfiles` | Show hidden files |
|
||||
| `hidefiles` | Hide the hidden files |
|
||||
| `itunes` | Control iTunes. Use `itunes -h` for usage details |
|
||||
| `spotify` | Control Spotify and search by artist, album, track… |
|
||||
| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
|
||||
| Command | Description |
|
||||
| :-------------- | :---------------------------------------------------- |
|
||||
| `tab` | Open the current directory in a new tab |
|
||||
| `split_tab` | Split the current terminal tab horizontally |
|
||||
| `vsplit_tab` | Split the current terminal tab vertically |
|
||||
| `ofd` | Open the current directory in a Finder window |
|
||||
| `pfd` | Return the path of the frontmost Finder window |
|
||||
| `pfs` | Return the current Finder selection |
|
||||
| `cdf` | `cd` to the current Finder directory |
|
||||
| `pushdf` | `pushd` to the current Finder directory |
|
||||
| `quick-look` | Quick-Look a specified file |
|
||||
| `man-preview` | Open a specified man page in Preview app |
|
||||
| `showfiles` | Show hidden files |
|
||||
| `hidefiles` | Hide the hidden files |
|
||||
| `itunes` | DEPRECATED. Use `music` from macOS Catalina on |
|
||||
| `music` | Control Apple Music. Use `music -h` for usage details |
|
||||
| `spotify` | Control Spotify and search by artist, album, track… |
|
||||
| `rmdsstore` | Remove .DS\_Store files recursively in a directory |
|
||||
|
||||
@@ -219,7 +219,19 @@ function vncviewer() {
|
||||
}
|
||||
|
||||
# iTunes control function
|
||||
function itunes() {
|
||||
function itunes music() {
|
||||
local APP_NAME=Music
|
||||
|
||||
autoload is-at-least
|
||||
if is-at-least 10.15 $(sw_vers -productVersion); then
|
||||
if [[ $0 = itunes ]]; then
|
||||
echo >&2 The itunes function name is deprecated. Use \`music\' instead.
|
||||
return 1
|
||||
fi
|
||||
else
|
||||
APP_NAME=iTunes
|
||||
fi
|
||||
|
||||
local opt=$1
|
||||
local playlist=$2
|
||||
shift
|
||||
@@ -236,7 +248,7 @@ function itunes() {
|
||||
opt="$opt track"
|
||||
;;
|
||||
vol)
|
||||
local new_volume volume=$(osascript -e 'tell application "iTunes" to get sound volume')
|
||||
local new_volume volume=$(osascript -e "tell application \"$APP_NAME\" to get sound volume")
|
||||
if [[ $# -eq 0 ]]; then
|
||||
echo "Current volume is ${volume}."
|
||||
return 0
|
||||
@@ -251,26 +263,26 @@ function itunes() {
|
||||
opt="set sound volume to ${new_volume}"
|
||||
;;
|
||||
playlist)
|
||||
# Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
|
||||
if [[ ! -z "$playlist" ]]; then
|
||||
osascript -e 'tell application "iTunes"' -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null;
|
||||
# Inspired by: https://gist.github.com/nakajijapan/ac8b45371064ae98ea7f
|
||||
if [[ ! -z "$playlist" ]]; then
|
||||
osascript -e "tell application \"$APP_NAME\"" -e "set new_playlist to \"$playlist\" as string" -e "play playlist new_playlist" -e "end tell" 2>/dev/null;
|
||||
if [[ $? -eq 0 ]]; then
|
||||
opt="play"
|
||||
else
|
||||
opt="stop"
|
||||
fi
|
||||
else
|
||||
opt="set allPlaylists to (get name of every playlist)"
|
||||
fi
|
||||
;;
|
||||
else
|
||||
opt="set allPlaylists to (get name of every playlist)"
|
||||
fi
|
||||
;;
|
||||
playing|status)
|
||||
local state=`osascript -e 'tell application "iTunes" to player state as string'`
|
||||
local state=`osascript -e "tell application \"$APP_NAME\" to player state as string"`
|
||||
if [[ "$state" = "playing" ]]; then
|
||||
currenttrack=`osascript -e 'tell application "iTunes" to name of current track as string'`
|
||||
currentartist=`osascript -e 'tell application "iTunes" to artist of current track as string'`
|
||||
currenttrack=`osascript -e "tell application \"$APP_NAME\" to name of current track as string"`
|
||||
currentartist=`osascript -e "tell application \"$APP_NAME\" to artist of current track as string"`
|
||||
echo -E "Listening to $fg[yellow]$currenttrack$reset_color by $fg[yellow]$currentartist$reset_color";
|
||||
else
|
||||
echo "iTunes is" $state;
|
||||
echo "$APP_NAME is" $state;
|
||||
fi
|
||||
return 0
|
||||
;;
|
||||
@@ -284,7 +296,7 @@ if [[ ! -z "$playlist" ]]; then
|
||||
|
||||
if [[ -n "$state" && ! "$state" =~ "^(on|off|toggle)$" ]]
|
||||
then
|
||||
print "Usage: itunes shuffle [on|off|toggle]. Invalid option."
|
||||
print "Usage: $0 shuffle [on|off|toggle]. Invalid option."
|
||||
return 1
|
||||
fi
|
||||
|
||||
@@ -305,14 +317,14 @@ EOF
|
||||
esac
|
||||
;;
|
||||
""|-h|--help)
|
||||
echo "Usage: itunes <option>"
|
||||
echo "Usage: $0 <option>"
|
||||
echo "option:"
|
||||
echo "\tlaunch|play|pause|stop|rewind|resume|quit"
|
||||
echo "\tmute|unmute\tcontrol volume set"
|
||||
echo "\tnext|previous\tplay next or previous track"
|
||||
echo "\tshuf|shuffle [on|off|toggle]\tSet shuffled playback. Default: toggle. Note: toggle doesn't support the MiniPlayer."
|
||||
echo "\tvol [0-100|up|down]\tGet or set the volume. 0 to 100 sets the volume. 'up' / 'down' increases / decreases by 10 points. No argument displays current volume."
|
||||
echo "\tplaying|status\tShow what song is currently playing in iTunes."
|
||||
echo "\tplaying|status\tShow what song is currently playing in Music."
|
||||
echo "\tplaylist [playlist name]\t Play specific playlist"
|
||||
echo "\thelp\tshow this message and exit"
|
||||
return 0
|
||||
@@ -322,7 +334,7 @@ EOF
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
osascript -e "tell application \"iTunes\" to $opt"
|
||||
osascript -e "tell application \"$APP_NAME\" to $opt"
|
||||
}
|
||||
|
||||
# Spotify control function
|
||||
|
||||
@@ -148,11 +148,11 @@ if [ $# = 0 ]; then
|
||||
else
|
||||
if [ ! -d /Applications/Spotify.app ] && [ ! -d $HOME/Applications/Spotify.app ]; then
|
||||
echo "The Spotify application must be installed."
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
|
||||
if [ $(osascript -e 'application "Spotify" is running') = "false" ]; then
|
||||
osascript -e 'tell application "Spotify" to activate' || exit 1
|
||||
osascript -e 'tell application "Spotify" to activate' || return 1
|
||||
sleep 2
|
||||
fi
|
||||
fi
|
||||
@@ -170,12 +170,12 @@ while [ $# -gt 0 ]; do
|
||||
if [ -z "${CLIENT_ID}" ]; then
|
||||
cecho "Invalid Client ID, please update ${USER_CONFIG_FILE}";
|
||||
showAPIHelp;
|
||||
exit 1;
|
||||
return 1
|
||||
fi
|
||||
if [ -z "${CLIENT_SECRET}" ]; then
|
||||
cecho "Invalid Client Secret, please update ${USER_CONFIG_FILE}";
|
||||
showAPIHelp;
|
||||
exit 1;
|
||||
return 1
|
||||
fi
|
||||
SHPOTIFY_CREDENTIALS=$(printf "${CLIENT_ID}:${CLIENT_SECRET}" | base64 | tr -d "\n"|tr -d '\r');
|
||||
SPOTIFY_PLAY_URI="";
|
||||
@@ -194,7 +194,7 @@ while [ $# -gt 0 ]; do
|
||||
cecho "Autorization failed, please check ${USER_CONFG_FILE}"
|
||||
cecho "${SPOTIFY_TOKEN_RESPONSE_DATA}"
|
||||
showAPIHelp
|
||||
exit 1
|
||||
return 1
|
||||
fi
|
||||
SPOTIFY_ACCESS_TOKEN=$( \
|
||||
printf "${SPOTIFY_TOKEN_RESPONSE_DATA}" \
|
||||
@@ -307,7 +307,7 @@ while [ $# -gt 0 ]; do
|
||||
|
||||
"quit" ) cecho "Quitting Spotify.";
|
||||
osascript -e 'tell application "Spotify" to quit';
|
||||
exit 0 ;;
|
||||
break ;;
|
||||
|
||||
"next" ) cecho "Going to next track." ;
|
||||
osascript -e 'tell application "Spotify" to next track';
|
||||
@@ -358,7 +358,7 @@ while [ $# -gt 0 ]; do
|
||||
echo " vol down # Decreases the volume by 10%.";
|
||||
echo " vol [amount] # Sets the volume to an amount between 0 and 100.";
|
||||
echo " vol # Shows the current Spotify volume.";
|
||||
exit 1;
|
||||
return 1
|
||||
fi
|
||||
|
||||
osascript -e "tell application \"Spotify\" to set sound volume to $newvol";
|
||||
@@ -468,9 +468,10 @@ while [ $# -gt 0 ]; do
|
||||
"help" )
|
||||
showHelp;
|
||||
break ;;
|
||||
|
||||
* )
|
||||
showHelp;
|
||||
exit 1;
|
||||
return 1 ;;
|
||||
|
||||
esac
|
||||
done
|
||||
|
||||
Reference in New Issue
Block a user